How to use set_hugepage method in lisa

Best Python code snippet using lisa_python

setup_dpdk_env.py

Source:setup_dpdk_env.py Github

copy

Full Screen

...19 bus_info = proc_shell(exe_str)20 bus_info = bus_info.split("\n")[0]21 return proc_shell("cat /sys/bus/pci/devices/" + bus_info + "/numa_node").split("\n")[0]2223def set_hugepage(numa_node, nr_hugepages):24 if None == nr_hugepages:25 nr_hugepages = 1024026 if None != numa_node:27 proc_shell("echo "+ str(nr_hugepages) + \28 " > /sys/devices/system/node/node" + str(numa_node) + "/hugepages/hugepages-2048kB/nr_hugepages")2930def bind_uio(RTE_SDK, RTE_TARGET, nic):31 if 0 == len(proc_shell('lsmod | grep uio')):32 proc_shell('modprobe uio')33 if 0 == len(proc_shell('lsmod | grep igb_uio')):34 proc_shell('insmod ' + RTE_SDK + '/' + RTE_TARGET + '/kmod/igb_uio.ko')35 if 0 < len(proc_shell('lsmod | grep igb_uio')):36 proc_shell('ifconfig ' + nic + ' down')37 proc_shell(RTE_SDK + '/tools/dpdk-devbind.py --bind=igb_uio ' + nic)3839if __name__ == "__main__":40 if len(sys.argv) > 2:41 print("USAGE: %s conf_file" % sys.argv[0])42 sys.exit(1)43 if False == os.path.exists(ENV_CONF_PATH):44 if 2 == len(sys.argv):45 conf_file = sys.argv[1]46 else:47 conf_file = ENV_CONF_PATH48 if None == conf_file:49 print('ERR: conf file not exist')50 sys.exit(1)5152 config = configparser.ConfigParser()53 config.read(conf_file)54 RTE_SDK = None55 RTE_TARGET = None56 has_var_section = config.has_section('VAR')57 if has_var_section:58 RTE_SDK=config.get('VAR', 'RTE_SDK')59 RTE_TARGET=config.get('VAR', 'RTE_TARGET')6061 #if RTE var not exist, get from system env var62 if None == RTE_SDK or 0 == len(RTE_SDK):63 RTE_SDK = os.environ.get('RTE_SDK')64 RTE_TARGET = os.environ.get('RTE_TARGET')65 if None == RTE_SDK or 0 == len(RTE_SDK):66 print('ERR: RTE_SDK or RTE_TARGET undefined')67 sys.exit(1)6869 nic = [None, None]70 nr_hugepages = [None, None]71 numa_node = [None, None]72 for i in range(0,2):73 nic[i] = config.get('NIC'+ str(i+1), 'name')74 if config.has_option('NIC' + str(i+1), 'nr_hugepages'):75 nr_hugepages[i] = int(config.get('NIC' + str(i+1), 'nr_hugepages'))76 if None != nic[i] and 0 < len(proc_shell('ifconfig ' + nic[i])):77 numa_node[i] = int(get_numa_node(nic[i]))78 set_hugepage(numa_node[i], nr_hugepages[i])79 bind_uio(RTE_SDK, RTE_TARGET, nic[i])80 81 if (None == numa_node[0]) and (None != numa_node[1]):82 set_hugepage(1 - numa_node[1], 1024)83 if (None == numa_node[1]) and (None != numa_node[0]):84 set_hugepage(1 - numa_node[0], 1024)85 if (numa_node[1] == numa_node[0]) and (None != numa_node[0]):86 set_hugepage(1 - numa_node[0], 1024)8788 proc_shell('mkdir /mnt/huge ; mount -t hugetlbfs nodev /mnt/huge')8990 #write RTE env var to conf file, in case of reboot91 if False == has_var_section:92 config = configparser.RawConfigParser()93 config.add_section('VAR')94 config.set('VAR', 'RTE_TARGET', RTE_TARGET)95 config.set('VAR', 'RTE_SDK', RTE_SDK)96 with open(conf_file, 'ab') as configfile: ...

Full Screen

Full Screen

hugepage_reset.py

Source:hugepage_reset.py Github

copy

Full Screen

...18 :param test: QEMU test object.19 :param params: Dictionary with test parameters.20 :param env: Dictionary with the test environment.21 """22 def set_hugepage():23 """Set nr_hugepages"""24 for h_size in (origin_nr - 2, origin_nr + 2):25 hp_config.target_hugepages = h_size26 hp_config.set_hugepages()27 if params.get('on_numa_node'):28 logging.info('Set hugepage size %s to target node %s',29 h_size, target_node)30 hp_config.set_node_num_huge_pages(h_size, target_node,31 hugepage_size)32 origin_nr = int(params['origin_nr'])33 host_numa_node = utils_misc.NumaInfo()34 mem = int(float(utils_misc.normalize_data_size("%sM" % params["mem"])))35 if params.get('on_numa_node'):36 for target_node in host_numa_node.get_online_nodes_withmem():37 node_mem_free = host_numa_node.read_from_node_meminfo(38 target_node, 'MemFree')39 if int(node_mem_free) > mem:40 params['target_nodes'] = target_node41 params["qemu_command_prefix"] = ("numactl --membind=%s" %42 target_node)43 params['target_num_node%s' % target_node] = origin_nr44 break45 logging.info(46 'The free memory of node %s is %s, is not enough for'47 ' guest memory: %s', target_node, node_mem_free, mem)48 else:49 test.cancel("No node on your host has sufficient free memory for "50 "this test.")51 hp_config = test_setup.HugePageConfig(params)52 hp_config.target_hugepages = origin_nr53 logging.info('Setup hugepage number to %s', origin_nr)54 hp_config.setup()55 hugepage_size = utils_memory.get_huge_page_size()56 params['start_vm'] = "yes"57 vm_name = params['main_vm']58 env_process.preprocess_vm(test, params, env, vm_name)59 vm = env.get_vm(vm_name)60 params['stress_args'] = '--vm %s --vm-bytes 256M --timeout 30s' % (61 mem // 512)62 logging.info('Loading stress on guest.')63 stress = utils_test.VMStress(vm, 'stress', params)64 stress.load_stress_tool()65 time.sleep(30)66 stress.unload_stress()67 set_hugepage()68 hp_config.cleanup()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful