33
33
34
34
import OpTestConfiguration
35
35
import OpTestLogger
36
+ from common import OpTestInstallUtil
36
37
from common .OpTestSystem import OpSystemState
37
38
38
39
log = OpTestLogger .optest_logger_glob .get_logger (__name__ )
@@ -45,7 +46,6 @@ def setUp(self):
45
46
46
47
conf = OpTestConfiguration .conf
47
48
self .cv_SYSTEM = conf .system ()
48
- self .cv_SYSTEM .goto_state (OpSystemState .OFF )
49
49
self .bmc_type = conf .args .bmc_type
50
50
self .machine_config = json .loads (conf .args .machine_config )
51
51
if self .bmc_type == "FSP_PHYP" or self .bmc_type == "EBMC_PHYP" :
@@ -65,6 +65,7 @@ def runTest(self):
65
65
status = LparConfig (self .cv_HMC ,self .system_name ,self .lpar_name ,self .lpar_prof ,self .machine_config ['lpar' ]).LparSetup ()
66
66
if status :
67
67
self .fail (status )
68
+
68
69
if self .machine_config .__contains__ ('cec' ):
69
70
if not self .cv_HMC .lpar_vios :
70
71
self .skipTest ("Please pass lpar_vios in config file." )
@@ -80,8 +81,22 @@ def runTest(self):
80
81
self .fail (status )
81
82
else :
82
83
self .skipTest ("Not implemented for other CEC settings" )
83
- else :
84
- self .skipTest ("Not Supported Config" )
84
+
85
+ if self .machine_config .__contains__ ('os' ):
86
+ config_value = self .machine_config ['os' ]
87
+ valid_size = ['2M' , '1G' , '16M' , '16G' ]
88
+ if 'hugepage' in config_value :
89
+ hugepage_size = re .findall (
90
+ "hugepage=[0-9]+[A-Z]" , str (self .machine_config ))[0 ].split ('=' )[1 ]
91
+ if str (hugepage_size ) not in valid_size :
92
+ self .skipTest ("%s is not valid hugepage size, "
93
+ "valid hugepage sizes are 1G, 2M, 16M, 16G" % hugepage_size )
94
+ status = OsConfig (self .cv_HMC , self .system_name , self .lpar_name ,
95
+ self .lpar_prof , self .machine_config ['os' ]).OsHugepageSetup ()
96
+ if status :
97
+ self .fail (status )
98
+ else :
99
+ self .skipTest ("Not implemented for other OS settings" )
85
100
86
101
87
102
class LparConfig ():
@@ -100,8 +115,9 @@ def __init__(self, cv_HMC=None, system_name= None,
100
115
self .lpar_name = lpar_name
101
116
self .lpar_prof = lpar_prof
102
117
self .machine_config = machin_config
103
-
104
-
118
+ conf = OpTestConfiguration .conf
119
+ self .cv_SYSTEM = conf .system ()
120
+ self .cv_SYSTEM .goto_state (OpSystemState .OFF )
105
121
106
122
def LparSetup (self ):
107
123
'''
@@ -114,7 +130,7 @@ def LparSetup(self):
114
130
desired_proc_units=2.0
115
131
overcommit_ratio=3
116
132
'''
117
-
133
+ proc_mode = None
118
134
if "cpu=shared" in self .machine_config :
119
135
conf = OpTestConfiguration .conf
120
136
try : self .sharing_mode = conf .args .sharing_mode
@@ -255,10 +271,11 @@ def LparSetup(self):
255
271
(self .system_name , self .lpar_name , self .lpar_prof ))
256
272
time .sleep (5 )
257
273
curr_proc_mode = self .cv_HMC .get_proc_mode ()
258
- if proc_mode in curr_proc_mode :
259
- log .info ("System booted with %s mode" % proc_mode )
260
- else :
261
- return "Failed to boot in %s mode" % proc_mode
274
+ if proc_mode :
275
+ if proc_mode in curr_proc_mode :
276
+ log .info ("System booted with %s mode" % proc_mode )
277
+ else :
278
+ return "Failed to boot in %s mode" % proc_mode
262
279
263
280
264
281
class RestoreLAPRConfig (MachineConfig ):
@@ -308,4 +325,102 @@ def CecSetup_lmb(self):
308
325
return "Failed to boot with LMB %s" % self .lmb_size
309
326
self .cv_HMC .run_command ("chsysstate -r lpar -m %s -o on -n %s -f %s" %
310
327
(self .system_name , self .lpar_name , self .lpar_prof ))
311
- time .sleep (5 )
328
+ time .sleep (5 )
329
+
330
+
331
+ class OsConfig ():
332
+ '''
333
+ This Class assign huge page in the system based on MMU either Radix or hash and validate
334
+ MMU is Radix : 2M or 1 GB Huge page
335
+ MMU HASH : 16M or 16GB
336
+ pass hgpgsize to machine_config in config file
337
+ '''
338
+
339
+ def __init__ (self , cv_HMC = None , system_name = None ,
340
+ lpar_name = None , lpar_prof = None , machine_config = None ):
341
+ self .cv_HMC = cv_HMC
342
+ self .system_name = system_name
343
+ self .lpar_name = lpar_name
344
+ self .lpar_prof = lpar_prof
345
+ self .machine_config = machine_config
346
+ conf = OpTestConfiguration .conf
347
+ self .cv_SYSTEM = conf .system ()
348
+ self .cv_HOST = conf .host ()
349
+ self .c = self .cv_HMC .get_host_console ()
350
+ self .mmulist = self .c .run_command ("tail /proc/cpuinfo | grep MMU" )
351
+ self .mmu = str (self .mmulist [0 ]).split (':' )[1 ].strip ()
352
+ self .obj = OpTestInstallUtil .InstallUtil ()
353
+ self .os_level = self .cv_HOST .host_get_OS_Level ()
354
+
355
+
356
+ def OsHugepageSetup (self ):
357
+
358
+ filename_part1 = "cat /sys/kernel/mm/hugepages/hugepages-"
359
+ filename_part2 = "kB/nr_hugepages"
360
+ if "hugepage=16G" in self .machine_config :
361
+ self .size_hgpg = "16G"
362
+ self .num_hgpg = self .cv_HMC .get_16gb_hugepage_size ()
363
+ self .no_hgpg = int (self .num_hgpg [0 ])
364
+ if self .no_hgpg != 0 :
365
+ self .configure_os_16gb_hugepage ()
366
+ con = self .cv_SYSTEM .cv_HOST .get_ssh_connection ()
367
+ assign_hp = con .run_command ("%s%s%s" % (
368
+ filename_part1 , "16777216" , filename_part2 ))[0 ]
369
+ else :
370
+ return "16gb hugepages are not configured in CEC"
371
+ else :
372
+ exist_cfg = self .cv_HMC .get_lpar_cfg ()
373
+ self .des_mem = int (exist_cfg .get ('desired_mem' ))
374
+ self .percentile = int (self .des_mem * 0.1 )
375
+ if 'Radix' in self .mmu :
376
+ if "hugepage=16M" in self .machine_config :
377
+ self .fail ("16M is not supported in Radix" )
378
+ elif "hugepage=2M" in self .machine_config :
379
+ self .size_hgpg = "2M"
380
+ self .no_hgpg = int (self .percentile / 2 )
381
+ elif "hugepage=1G" in self .machine_config :
382
+ self .size_hgpg = "1G"
383
+ self .no_hgpg = int (self .percentile / 1024 )
384
+
385
+ elif 'Hash' in self .mmu and "hugepage=16M" in self .machine_config :
386
+ self .size_hgpg = "16M"
387
+ self .no_hgpg = int (self .percentile / 16 )
388
+ self .obj .update_kernel_cmdline (self .os_level ,
389
+ "hugepagesz=%s hugepages=%s" % (
390
+ self .size_hgpg , self .no_hgpg ),
391
+ "" ,
392
+ reboot = True ,
393
+ reboot_cmd = True )
394
+ con = self .cv_SYSTEM .cv_HOST .get_ssh_connection ()
395
+ if self .size_hgpg == "2M" :
396
+ assign_hp = con .run_command ("%s%s%s" % (
397
+ filename_part1 , "2048" , filename_part2 ))[0 ]
398
+ elif self .size_hgpg == "1G" :
399
+ assign_hp = con .run_command ("%s%s%s" % (
400
+ filename_part1 , "1048576" , filename_part2 ))[0 ]
401
+ elif self .size_hgpg == "16M" :
402
+ assign_hp = con .run_command ("%s%s%s" % (
403
+ filename_part1 , "16384" , filename_part2 ))[0 ]
404
+ if str (self .no_hgpg ) != assign_hp :
405
+ msg = "Expected %s: But found %s" % (self .no_hgpg , assign_hp )
406
+ return msg
407
+ else :
408
+ log .info ("%s Hugepage validation successful!" % self .size_hgpg )
409
+
410
+
411
+ def configure_os_16gb_hugepage (self ):
412
+ if 'Radix' in self .mmu :
413
+ self .obj .update_kernel_cmdline (self .os_level ,
414
+ "default_hugepagesz=16G hugepagesz=16G hugepages=%s disable_radix=1" % int (
415
+ self .num_hgpg [0 ]),
416
+ "" ,
417
+ reboot = True ,
418
+ reboot_cmd = True )
419
+
420
+ elif 'Hash' in self .mmu :
421
+ self .obj .update_kernel_cmdline (self .os_level ,
422
+ "default_hugepagesz=16G hugepagesz=16G hugepages=%s" % int (
423
+ self .num_hgpg [0 ]),
424
+ "" ,
425
+ reboot = True ,
426
+ reboot_cmd = True )
0 commit comments