@@ -24,6 +24,7 @@ def run(test, params, env):
24
24
25
25
qemu_path = utils_misc .get_qemu_binary (params )
26
26
memhog_cmd = params .get ("memhog_cmd" )
27
+ threshold = params .get_numeric ("threshold" )
27
28
rss_values = []
28
29
29
30
for status in ["on" , "on-fault" ]:
@@ -69,31 +70,31 @@ def run(test, params, env):
69
70
)
70
71
test .log .info ("The qemu-kvm command: %s" , qemu_cmd_memhog )
71
72
72
- try :
73
- with aexpect .run_bg (qemu_cmd_memhog ) as _ :
74
- qemu_pid = process .get_children_pids (_ .get_pid ())[0 ]
75
- rss_cmd = "ps -p %s -o rss=" % qemu_pid
76
- time .sleep (5 )
77
- previous_rss_value = int (process .getoutput (rss_cmd , shell = True ))
73
+ with aexpect .run_bg (qemu_cmd_memhog ) as _ :
74
+ qemu_pid = process .get_children_pids (_ .get_pid ())[0 ]
75
+ rss_cmd = "ps -p %s -o rss=" % qemu_pid
76
+ time .sleep (5 )
77
+ previous_rss_value = int (process .getoutput (rss_cmd , shell = True ))
78
78
79
- # Calculates a suitable amount of memory for memhog
80
- swap_free = str (swap_free ) + "K"
81
- swap_normalized = math .ceil (
82
- float (utils_misc .normalize_data_size (swap_free , "G" ))
83
- )
84
- memhog_value = math .ceil (vm_memory_normalized + (swap_normalized * 1.25 ))
85
- memhog_cmd = memhog_cmd % memhog_value
86
- memhog_cmd = aexpect .run_bg (memhog_cmd )
79
+ # Calculates a suitable amount of memory for memhog
80
+ swap_free = str (swap_free ) + "K"
81
+ swap_normalized = math .ceil (
82
+ float (utils_misc .normalize_data_size (swap_free , "G" ))
83
+ )
84
+ memhog_value = math .ceil (vm_memory_normalized + (swap_normalized * 1.25 ))
85
+ memhog_cmd = memhog_cmd % memhog_value
86
+ memhog_cmd = aexpect .run_bg (memhog_cmd )
87
87
88
- while memhog_cmd .is_alive ():
89
- rss_value = int (process .getoutput (rss_cmd , shell = True ))
90
- if rss_value < previous_rss_value :
91
- test .log .debug (
92
- "previous_rss_value: %d and the rss_value: %d" ,
93
- previous_rss_value ,
94
- rss_value ,
95
- )
96
- test .error ("The RSS value has decreased, memory is not locked!" )
97
- previous_rss_value = rss_value
98
- except Exception as e :
99
- test .error ("An error ocurred: %s" % str (e ))
88
+ while memhog_cmd .is_alive ():
89
+ rss_value = int (process .getoutput (rss_cmd , shell = True ))
90
+ if (
91
+ rss_value < previous_rss_value
92
+ and (previous_rss_value - rss_value ) >= threshold
93
+ ):
94
+ test .log .debug (
95
+ "previous_rss_value: %d and the rss_value: %d" ,
96
+ previous_rss_value ,
97
+ rss_value ,
98
+ )
99
+ test .error ("The RSS value has decreased, memory is not locked!" )
100
+ previous_rss_value = rss_value
0 commit comments