def set_max_hugepages(nr_full): ''' Tries to set the hugepages to the nr_full value and returns the max possible value set. ''' memory.set_num_huge_pages(nr_full) return memory.get_num_huge_pages()
def set_max_hugepages(nr_full): ''' Tries to set the hugepages to the nr_full value and returns the max possible value set. ''' memory.set_num_huge_pages(nr_full) return memory.get_num_huge_pages()
def setUp(self): # Check for root permission if os.geteuid() != 0: exit("You need to have root privileges to run this script." "\nPlease try again, using 'sudo'. Exiting.") # Check for basic utilities sm = SoftwareManager() detected_distro = distro.detect() deps = ['gcc', 'make', 'patch'] if detected_distro.name == "Ubuntu": deps += ['libpthread-stubs0-dev', 'git'] elif detected_distro.name == "SuSE": deps += ['glibc-devel-static', 'git-core'] else: deps += ['glibc-static', 'git'] for package in deps: if not sm.check_installed(package) and not sm.install(package): self.cancel(' %s is needed for the test to be run' % package) kernel.check_version("2.6.16") if detected_distro.name == "Ubuntu": op = glob.glob("/usr/lib/*/libpthread.a") else: op = glob.glob("/usr/lib*/libpthread.a") if not op: self.error("libpthread.a is required!!!" "\nTry installing glibc-static") # Get arguments: self.hugetlbfs_dir = self.params.get('hugetlbfs_dir', default=None) pages_requested = self.params.get('pages_requested', default=20) # Check hugepages: pages_available = 0 if os.path.exists('/proc/sys/vm/nr_hugepages'): Hugepages_support = process.system_output('cat /proc/meminfo', verbose=False, shell=True) if 'HugePages_' not in Hugepages_support: self.error("No Hugepages Configured") memory.set_num_huge_pages(pages_requested) pages_available = memory.get_num_huge_pages() else: self.error("Kernel does not support hugepages") # Check no of hugepages : if pages_available < pages_requested: self.error('%d pages available, < %d pages requested' % (pages_available, pages_requested)) # Check if hugetlbfs is mounted cmd_result = process.run('grep hugetlbfs /proc/mounts', verbose=False) if not cmd_result: if not self.hugetlbfs_dir: self.hugetlbfs_dir = os.path.join(self.tmpdir, 'hugetlbfs') os.makedirs(self.hugetlbfs_dir) process.system('mount -t hugetlbfs none %s' % self.hugetlbfs_dir) git.get_repo('https://github.com/libhugetlbfs/libhugetlbfs.git', destination_dir=self.workdir) os.chdir(self.workdir) patch = self.params.get('patch', default='elflink.patch') process.run('patch -p1 < %s' % self.get_data(patch), shell=True) # FIXME: "redhat" as the distro name for RHEL is deprecated # on Avocado versions >= 50.0. This is a temporary compatibility # enabler for older runners, but should be removed soon if detected_distro.name in ["rhel", "fedora", "redhat", "centos"]: falloc_patch = 'patch -p1 < %s ' % self.get_data('falloc.patch') process.run(falloc_patch, shell=True) build.make(self.workdir, extra_args='BUILDTYPE=NATIVEONLY')
def setUp(self): ''' Build VA Test ''' # Check for basic utilities smm = SoftwareManager() self.scenario_arg = int(self.params.get('scenario_arg', default=1)) self.n_chunks = nr_pages = self.n_chunks2 = self.def_chunks = 0 self.hsizes = [1024, 2] self.hp_file = '/sys/kernel/mm/hugepages/hugepages-%skB/nr_hugepages' page_chunker = memory.meminfo.Hugepagesize.m if distro.detect().arch in ['ppc64', 'ppc64le']: mmu_detect = genio.read_file( '/proc/cpuinfo').strip().splitlines()[-1] # Check for "Radix" as this MMU will be explicit in POWER if 'Radix' not in mmu_detect: self.hsizes = [16] # For now, 16G hugepages are possible only when it is default. # So check and add to the possible pagesize list if page_chunker == 16384: self.hsizes.extend([16384]) if self.scenario_arg not in range(1, 13): self.cancel("Test need to skip as scenario will be 1-12") elif self.scenario_arg in [7, 8, 9]: self.log.info("Using alternate hugepages") if len(self.hsizes) == 1: self.cancel('Scenario is not applicable') if memory.meminfo.Hugepagesize.m == self.hsizes[0]: page_chunker = self.hsizes[1] else: page_chunker = self.hsizes[0] self.exist_pages = memory.get_num_huge_pages() if self.scenario_arg in [10, 11, 12]: self.log.info("Using Multiple hugepages") if len(self.hsizes) == 1: self.cancel('Scenario is not applicable') if memory.meminfo.Hugepagesize.m != self.hsizes[0]: self.hsizes.reverse() # Leaving half size for default pagesize total_mem = (0.9 * memory.meminfo.MemFree.m) / 2 self.def_chunks = int(total_mem / 16384) for hp_size in self.hsizes: nr_pgs = int((total_mem / 2) / hp_size) genio.write_file(self.hp_file % str(hp_size * 1024), str(nr_pgs)) n_pages = genio.read_file(self.hp_file % str(self.hsizes[0] * 1024)).rstrip("\n") n_pages2 = genio.read_file(self.hp_file % str(self.hsizes[1] * 1024)).rstrip("\n") self.n_chunks = (int(n_pages) * self.hsizes[0]) // 16384 self.n_chunks2 = (int(n_pages2) * self.hsizes[1]) // 16384 if self.scenario_arg not in [1, 2, 10, 11, 12]: max_hpages = int((0.9 * memory.meminfo.MemFree.m) / page_chunker) if self.scenario_arg in [3, 4, 5, 6]: memory.set_num_huge_pages(max_hpages) nr_pages = memory.get_num_huge_pages() else: genio.write_file(self.hp_file % str(page_chunker * 1024), str(max_hpages)) nr_pages = genio.read_file( self.hp_file % str(page_chunker * 1024)).rstrip("\n") self.n_chunks = (int(nr_pages) * page_chunker) // 16384 for packages in ['gcc', 'make']: if not smm.check_installed(packages) and not smm.install(packages): self.cancel('%s is needed for the test to be run' % packages) shutil.copyfile(self.get_data('va_test.c'), os.path.join(self.teststmpdir, 'va_test.c')) shutil.copyfile(self.get_data('Makefile'), os.path.join(self.teststmpdir, 'Makefile')) build.make(self.teststmpdir)
def setUp(self): # Check for root permission if os.geteuid() != 0: exit("You need to have root privileges to run this script." "\nPlease try again, using 'sudo'. Exiting.") # Check for basic utilities sm = SoftwareManager() detected_distro = distro.detect() if not sm.check_installed("gcc") and not sm.install("gcc"): self.error('Gcc is needed for the test to be run') if not sm.check_installed("make") and not sm.install("make"): self.error('make is needed for the test to be run') if detected_distro.name == "SuSE": if not sm.check_installed("git-core") and not sm.install("git-" "core"): self.error('git is needed for the test to be run') else: if not sm.check_installed("git") and not sm.install("git"): self.error('git is needed for the test to be run') kernel.check_version("2.6.16") if detected_distro.name == "Ubuntu": op = glob.glob("/usr/lib/*/libpthread.a") else: op = glob.glob("/usr/lib*/libpthread.a") if not op: self.error("libpthread.a is required!!!" "\nTry installing glibc-static") # Get arguments: self.hugetlbfs_dir = self.params.get('hugetlbfs_dir', default=None) pages_requested = self.params.get('pages_requested', default=20) # Check hugepages: pages_available = 0 if os.path.exists('/proc/sys/vm/nr_hugepages'): Hugepages_support = process.system_output('cat /proc/meminfo', verbose=False, shell=True) if 'HugePages_' not in Hugepages_support: self.error("No Hugepages Configured") memory.set_num_huge_pages(pages_requested) pages_available = memory.get_num_huge_pages() else: self.error("Kernel does not support hugepages") # Check no of hugepages : if pages_available < pages_requested: self.error('%d pages available, < %d pages requested' % pages_available, pages_requested) # Check if hugetlbfs is mounted cmd_result = process.run('grep hugetlbfs /proc/mounts', verbose=False) if not cmd_result: if not self.hugetlbfs_dir: self.hugetlbfs_dir = os.path.join(self.tmpdir, 'hugetlbfs') os.makedirs(self.hugetlbfs_dir) process.system('mount -t hugetlbfs none %s' % self.hugetlbfs_dir) data_dir = os.path.abspath(self.datadir) git.get_repo('https://github.com/libhugetlbfs/libhugetlbfs.git', destination_dir=self.srcdir) os.chdir(self.srcdir) patch = self.params.get('patch', default='elflink.patch') process.run('patch -p1 < %s' % data_dir + '/' + patch, shell=True) build.make(self.srcdir, extra_args='BUILDTYPE=NATIVEONLY')
def setUp(self): # Check for root permission if os.geteuid() != 0: exit("You need to have root privileges to run this script." "\nPlease try again, using 'sudo'. Exiting.") # Check for basic utilities sm = SoftwareManager() detected_distro = distro.detect() if not sm.check_installed("gcc") and not sm.install("gcc"): self.error('Gcc is needed for the test to be run') if not sm.check_installed("make") and not sm.install("make"): self.error('make is needed for the test to be run') if detected_distro.name == "SuSE": if not sm.check_installed("git-core") and not sm.install("git-" "core"): self.error('git is needed for the test to be run') else: if not sm.check_installed("git") and not sm.install("git"): self.error('git is needed for the test to be run') kernel.check_version("2.6.16") if detected_distro.name == "Ubuntu": op = glob.glob("/usr/lib/*/libpthread.a") else: op = glob.glob("/usr/lib*/libpthread.a") if not op: self.error("libpthread.a is required!!!" "\nTry installing glibc-static") # Get arguments: self.hugetlbfs_dir = self.params.get('hugetlbfs_dir', default=None) pages_requested = self.params.get('pages_requested', default=20) # Check hugepages: pages_available = 0 if os.path.exists('/proc/sys/vm/nr_hugepages'): Hugepages_support = process.system_output('cat /proc/meminfo', verbose=False, shell=True) if 'HugePages_' not in Hugepages_support: self.error("No Hugepages Configured") memory.set_num_huge_pages(pages_requested) pages_available = memory.get_num_huge_pages() else: self.error("Kernel does not support hugepages") # Check no of hugepages : if pages_available < pages_requested: self.error( '%d pages available, < %d pages requested' % pages_available, pages_requested) # Check if hugetlbfs is mounted cmd_result = process.run('grep hugetlbfs /proc/mounts', verbose=False) if not cmd_result: if not self.hugetlbfs_dir: self.hugetlbfs_dir = os.path.join(self.tmpdir, 'hugetlbfs') os.makedirs(self.hugetlbfs_dir) process.system('mount -t hugetlbfs none %s' % self.hugetlbfs_dir) data_dir = os.path.abspath(self.datadir) git.get_repo('https://github.com/libhugetlbfs/libhugetlbfs.git', destination_dir=self.srcdir) os.chdir(self.srcdir) patch = self.params.get('patch', default='elflink.patch') process.run('patch -p1 < %s' % data_dir + '/' + patch, shell=True) build.make(self.srcdir, extra_args='BUILDTYPE=NATIVEONLY')
def setUp(self): ''' Build VA Test ''' # Check for basic utilities smm = SoftwareManager() self.scenario_arg = int(self.params.get('scenario_arg', default=1)) self.n_chunks = nr_pages = self.n_chunks2 = self.def_chunks = 0 self.hsizes = [1024, 2] page_chunker = memory.meminfo.Hugepagesize.m if distro.detect().arch in ['ppc64', 'ppc64le']: if 'power8' in cpu.get_cpu_arch(): self.hsizes = [16384, 16] if self.scenario_arg not in range(1, 13): self.cancel("Test need to skip as scenario will be 1-12") elif self.scenario_arg in [7, 8, 9]: self.log.info("Using alternate hugepages") if memory.meminfo.Hugepagesize.m == self.hsizes[0]: page_chunker = self.hsizes[1] else: page_chunker = self.hsizes[0] self.exist_pages = memory.get_num_huge_pages() if self.scenario_arg in [10, 11, 12]: self.log.info("Using Multiple hugepages") if memory.meminfo.Hugepagesize.m != self.hsizes[0]: self.hsizes.reverse() # Leaving half size for default pagesize total_mem = (0.9 * memory.meminfo.MemFree.m) / 2 self.def_chunks = int(total_mem / 16384) for hp_size in self.hsizes: nr_pgs = int((total_mem / 2) / hp_size) genio.write_file( '/sys/kernel/mm/hugepages/hugepages-%skB/nr_hugepages' % str(hp_size * 1024), str(nr_pgs)) n_pages = genio.read_file( '/sys/kernel/mm/hugepages/hugepages-%skB/nr_hugepages' % str(self.hsizes[0] * 1024)).rstrip("\n") n_pages2 = genio.read_file( '/sys/kernel/mm/hugepages/hugepages-%skB/nr_hugepages' % str(self.hsizes[1] * 1024)).rstrip("\n") self.n_chunks = (int(n_pages) * self.hsizes[0]) / 16384 self.n_chunks2 = (int(n_pages2) * self.hsizes[1]) / 16384 if self.scenario_arg not in [1, 2, 10, 11, 12]: max_hpages = int((0.9 * memory.meminfo.MemFree.m) / page_chunker) if self.scenario_arg in [3, 4, 5, 6]: memory.set_num_huge_pages(max_hpages) nr_pages = memory.get_num_huge_pages() else: genio.write_file( '/sys/kernel/mm/hugepages/hugepages-%skB/nr_hugepages' % str(page_chunker * 1024), str(max_hpages)) nr_pages = genio.read_file( '/sys/kernel/mm/hugepages/hugepages-%skB/nr_hugepage' 's' % str(page_chunker * 1024)).rstrip("\n") self.n_chunks = (int(nr_pages) * page_chunker) / 16384 for packages in ['gcc', 'make']: if not smm.check_installed(packages) and not smm.install(packages): self.cancel('%s is needed for the test to be run' % packages) shutil.copyfile(os.path.join(self.datadir, 'va_test.c'), os.path.join(self.teststmpdir, 'va_test.c')) shutil.copyfile(os.path.join(self.datadir, 'Makefile'), os.path.join(self.teststmpdir, 'Makefile')) build.make(self.teststmpdir)
def setUp(self): # Check for basic utilities sm = SoftwareManager() detected_distro = distro.detect() deps = ['gcc', 'make', 'patch'] if detected_distro.name == "Ubuntu": deps += ['libpthread-stubs0-dev', 'git'] elif detected_distro.name == "SuSE": deps += ['glibc-devel-static', 'git-core'] else: deps += ['glibc-static', 'git'] for package in deps: if not sm.check_installed(package) and not sm.install(package): self.cancel(' %s is needed for the test to be run' % package) kernel.check_version("2.6.16") if detected_distro.name == "Ubuntu": op = glob.glob("/usr/lib/*/libpthread.a") else: op = glob.glob("/usr/lib*/libpthread.a") if not op: self.cancel("libpthread.a is required!!!" "\nTry installing glibc-static") # Get arguments: self.hugetlbfs_dir = self.params.get('hugetlbfs_dir', default=None) pages_requested = self.params.get('pages_requested', default=20) # Check hugepages: pages_available = 0 if os.path.exists('/proc/sys/vm/nr_hugepages'): Hugepages_support = genio.read_file("/proc/meminfo").rstrip("\n") if 'HugePages_' not in Hugepages_support: self.cancel("No Hugepages Configured") memory.set_num_huge_pages(pages_requested) pages_available = memory.get_num_huge_pages() else: self.cancel("Kernel does not support hugepages") # Check no of hugepages : if pages_available < pages_requested: self.cancel('%d pages available, < %d pages requested' % (pages_available, pages_requested)) # Check if hugetlbfs is mounted cmd_result = process.run( 'grep hugetlbfs /proc/mounts', verbose=False, sudo=True) if not cmd_result: if not self.hugetlbfs_dir: self.hugetlbfs_dir = os.path.join(self.tmpdir, 'hugetlbfs') os.makedirs(self.hugetlbfs_dir) if process.system('mount -t hugetlbfs none %s' % self.hugetlbfs_dir, sudo=True, ignore_status=True): self.cancel("hugetlbfs mount failed") git.get_repo('https://github.com/libhugetlbfs/libhugetlbfs.git', destination_dir=self.workdir) os.chdir(self.workdir) patch = self.params.get('patch', default='elflink.patch') process.run('patch -p1 < %s' % self.get_data(patch), shell=True) build.make(self.workdir, extra_args='BUILDTYPE=NATIVEONLY')
def setUp(self): # Check for root permission if os.geteuid() != 0: exit("You need to have root privileges to run this script." "\nPlease try again, using 'sudo'. Exiting.") # Check for basic utilities sm = SoftwareManager() detected_distro = distro.detect() deps = ['gcc', 'make', 'patch'] if detected_distro.name == "Ubuntu": deps += ['libpthread-stubs0-dev', 'git'] elif detected_distro.name == "SuSE": deps += ['glibc-devel-static', 'git-core'] else: deps += ['glibc-static', 'git'] for package in deps: if not sm.check_installed(package) and not sm.install(package): self.cancel(' %s is needed for the test to be run' % package) kernel.check_version("2.6.16") if detected_distro.name == "Ubuntu": op = glob.glob("/usr/lib/*/libpthread.a") else: op = glob.glob("/usr/lib*/libpthread.a") if not op: self.error("libpthread.a is required!!!" "\nTry installing glibc-static") # Get arguments: self.hugetlbfs_dir = self.params.get('hugetlbfs_dir', default=None) pages_requested = self.params.get('pages_requested', default=20) # Check hugepages: pages_available = 0 if os.path.exists('/proc/sys/vm/nr_hugepages'): Hugepages_support = process.system_output('cat /proc/meminfo', verbose=False, shell=True) if 'HugePages_' not in Hugepages_support: self.error("No Hugepages Configured") memory.set_num_huge_pages(pages_requested) pages_available = memory.get_num_huge_pages() else: self.error("Kernel does not support hugepages") # Check no of hugepages : if pages_available < pages_requested: self.error('%d pages available, < %d pages requested' % (pages_available, pages_requested)) # Check if hugetlbfs is mounted cmd_result = process.run('grep hugetlbfs /proc/mounts', verbose=False) if not cmd_result: if not self.hugetlbfs_dir: self.hugetlbfs_dir = os.path.join(self.tmpdir, 'hugetlbfs') os.makedirs(self.hugetlbfs_dir) process.system('mount -t hugetlbfs none %s' % self.hugetlbfs_dir) data_dir = os.path.abspath(self.datadir) git.get_repo('https://github.com/libhugetlbfs/libhugetlbfs.git', destination_dir=self.srcdir) os.chdir(self.srcdir) patch = self.params.get('patch', default='elflink.patch') process.run('patch -p1 < %s' % data_dir + '/' + patch, shell=True) # FIXME: "redhat" as the distro name for RHEL is deprecated # on Avocado versions >= 50.0. This is a temporary compatibility # enabler for older runners, but should be removed soon if detected_distro.name in ["rhel", "fedora", "redhat"]: falloc_patch = 'patch -p1 < %s ' % ( os.path.join(data_dir, 'falloc.patch')) process.run(falloc_patch, shell=True) build.make(self.srcdir, extra_args='BUILDTYPE=NATIVEONLY')