KVM test: KSM (kernel shared memory) overcommit test
PATCH 1/1 KVM test: KSM (kernel shared memory) overcommit test
In reply to a message not in the archiveFIX:
Patch is based on The previous version [PATCH] KVM test: KSM (kernel shared memory) test developed overcommit Lucas Meneghel Rodrigues.
The only fix is change of behavior with large overcommit. Python has a problem in allocating memory even when is still enough space in swap (300MB etc).
Change is on line 150 in file ksm_overcommit.py .
client/tests/kvm/kvm_test_utils.py +35 -1
@@ -22,7 +22,8 @@ More specifically: """ import time, os, logging, re, commands -from autotest_lib.client.common_lib import utils, error +from autotest_lib.client.common_lib import error +from autotest_lib.client.bin import utils import kvm_utils, kvm_vm, kvm_subprocess
@@ -203,3 +204,36 @@ def get_time(session, time_command, time_filter_re, time_format): s = re.findall(time_filter_re, s)[0] guest_time = time.mktime(time.strptime(s, time_format)) return (host_time, guest_time) + + +def get_memory_info(lvms): + """ + Get memory information from host and guests in format: + Host: memfree = XXXM; Guests memsh = {XXX,XXX,...} + + @params lvms: List of VM objects + @return: String with memory info report + """ + if not isinstance(lvms, list): + raise error.TestError("Invalid list passed to get_stat: %s " % lvms) + + try: + meminfo = "Host: memfree = " + meminfo += str(int(utils.freememtotal()) / 1024) + "M; " + meminfo += "swapfree = " + mf = int(utils.read_from_meminfo("SwapFree")) / 1024 + meminfo += str(mf) + "M; " + except Exception, e: + raise error.TestFail("Could not fetch host free memory info, " + "reason: %s" % e) + + meminfo += "Guests memsh = {" + for vm in lvms: + shm = vm.get_shared_meminfo() + if shm is None: + raise error.TestError("Could not get shared meminfo from " + "VM %s" % vm) + meminfo += "%dM; " % shm + meminfo = meminfo[0:-2] + "}" + + return meminfo
client/tests/kvm/kvm_utils.py +16 -0
@@ -713,6 +713,22 @@ def generate_random_string(length): return str +def generate_tmp_file_name(file, ext=None, dir='/tmp/'): + """ + Returns a temporary file name. The file is not created. + """ + while True: + file_name = (file + '-' + time.strftime("%Y%m%d-%H%M%S-") + + generate_random_string(4)) + if ext: + file_name += '.' + ext + file_name = os.path.join(dir, file_name) + if not os.path.exists(file_name): + break + + return file_name + + def format_str_for_message(str): """ Format str so that it can be appended to a message.
client/tests/kvm/kvm_vm.py +17 -0
@@ -760,6 +760,23 @@ class VM: return self.process.get_pid() + def get_shared_meminfo(self): + """ + Returns the VM's shared memory information. + + @return: Shared memory used by VM (MB) + """ + if self.is_dead(): + logging.error("Could not get shared memory info from dead VM.") + return None + + cmd = "cat /proc/%d/statm" % self.params.get('pid_' + self.name) + shm = int(os.popen(cmd).readline().split()[2]) + # statm stores informations in pages, translate it to MB + shm = shm * 4 / 1024 + return shm + + def remote_login(self, nic_index=0, timeout=10): """ Log into the guest via SSH/Telnet/Netcat.
client/tests/kvm/scripts/allocator.py new file +230 -0
230 lines not on this page · raw message
client/tests/kvm/tests/ksm_overcommit.py new file +582 -0
582 lines not on this page · raw message
client/tests/kvm/tests_base.cfg.sample +18 -0
@@ -273,6 +273,24 @@ variants: type = physical_resources_check catch_uuid_cmd = dmidecode | awk -F: '/UUID/ {print $2}' + - ksm_overcommit: + # Don't preprocess any vms as we need to change its params + vms = '' + image_snapshot = yes + kill_vm_gracefully = no + type = ksm_overcommit + ksm_swap = yes + no hugepages + # Overcommit of host memmory + ksm_overcommit_ratio = 3 + # Max paralel runs machine + ksm_parallel_ratio = 4 + variants: + - ksm_serial + ksm_test_size = "serial" + - ksm_parallel + ksm_test_size = "parallel" + # NICs variants: - @rtl8139:
Quoted 6 lines · Jiri Zupka
FIX:
Patch is based on The previous version [PATCH] KVM test: KSM (kernel shared memory) test developed overcommit Lucas Meneghel Rodrigues.
The only fix is change of behavior with large overcommit. Python has a problem in allocating memory even when is still enough space in swap (300MB etc).
Change is on line 150 in fileksm_overcommit.py.
Ok Jiri, thanks, I am going to focus on this test this week so we can get it commited ASAP.
Sorry it's taking long, but it's a large and complex test, and I want to be as careful as possible.
Cheers,
Lucas