Skip to content

Commit 02fea0f

Browse files
lyan3wenlingz
authored andcommitted
acrn-config: support generation of per vcpu clos configuraton
Added "vcpu_clos" to configuration XML, here is an example of VM2 with 2 vCPUs: <clos desc="Class of Service for Cache Allocation Technology. Please refer SDM 17.19.2 for details and use with caution."> <vcpu_clos>1</vcpu_clos> <vcpu_clos>0</vcpu_clos> </clos> A macro will be generated in vm_configuration.h: #define VM2_VCPU_CLOS {1U, 0U} And the macro will be used in vm_configuration.c: struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { ... { ... .clos = VM2_VCPU_CLOS, ... } } Tracked-On: #4566 Signed-off-by: Yan, Like <like.yan@intel.com> Reviewed-by: Victor Sun <victor.sun@intel.com>
1 parent 7694386 commit 02fea0f

File tree

5 files changed

+79
-9
lines changed

5 files changed

+79
-9
lines changed

misc/acrn-config/library/common.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
START_HPA_SIZE_LIST = ['0x20000000', '0x40000000', '0x80000000', 'CONFIG_SOS_RAM_SIZE']
2424

2525

26-
MULTI_ITEM = ["guest_flag", "pcpu_id", "input", "block", "network"]
26+
MULTI_ITEM = ["guest_flag", "pcpu_id", "vcpu_clos", "input", "block", "network"]
2727

2828
SIZE_K = 1024
2929
SIZE_M = SIZE_K * 1024
@@ -36,6 +36,7 @@ class MultiItem():
3636
def __init__(self):
3737
self.guest_flag = []
3838
self.pcpu_id = []
39+
self.vcpu_clos = []
3940
self.vir_input = []
4041
self.vir_block = []
4142
self.vir_console = []
@@ -378,6 +379,11 @@ def get_leaf_tag_val(config_file, branch_tag, tag_str=''):
378379
tmp_cpus.append(leaf.text)
379380
continue
380381

382+
# get vcpu_clos for vm
383+
if leaf.tag == "vcpu_clos" and tag_str == "vcpu_clos":
384+
tmp_cpus.append(leaf.text)
385+
continue
386+
381387
# append guest flags for each vm
382388
if tmp_flag and tag_str == "guest_flag":
383389
tmp_tag.append(tmp_flag)
@@ -402,6 +408,10 @@ def get_leaf_value(tmp, tag_str, leaf):
402408
if leaf.tag == "pcpu_id" and tag_str == "pcpu_id":
403409
tmp.multi.pcpu_id.append(leaf.text)
404410

411+
# get vcpu_clos for vm
412+
if leaf.tag == "vcpu_clos" and tag_str == "vcpu_clos":
413+
tmp.multi.vcpu_clos.append(leaf.text)
414+
405415
# get virtio-input for vm
406416
if leaf.tag == "input" and tag_str == "input":
407417
tmp.multi.vir_input.append(leaf.text)
@@ -426,6 +436,10 @@ def get_sub_value(tmp, tag_str, vm_id):
426436
if tmp.multi.pcpu_id and tag_str == "pcpu_id":
427437
tmp.tag[vm_id] = tmp.multi.pcpu_id
428438

439+
# append cpus for vm
440+
if tmp.multi.vcpu_clos and tag_str == "vcpu_clos":
441+
tmp.tag[vm_id] = tmp.multi.vcpu_clos
442+
429443
# append virtio input for vm
430444
if tmp.multi.vir_input and tag_str == "input":
431445
tmp.tag[vm_id] = tmp.multi.vir_input

misc/acrn-config/library/scenario_cfg_lib.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,29 @@ def cpus_assignment(cpus_per_vm, index):
665665
vm_cpu_bmp['cpu_num'] = len(cpus_per_vm[index])
666666
return vm_cpu_bmp
667667

668+
def clos_assignment(clos_per_vm, index):
669+
"""
670+
Get clos id assignment for vm by vm index
671+
:param clos_per_vm: a dictionary by vmid:cpus
672+
:param index: vm index
673+
:return: clos assignment string
674+
"""
675+
vm_clos_bmp = {}
676+
677+
for i in range(len(clos_per_vm[index])):
678+
if i == 0:
679+
if len(clos_per_vm[index]) == 1:
680+
clos_str = "{{{0}U}}".format(clos_per_vm[index][0])
681+
else:
682+
clos_str = "{{{0}U".format(clos_per_vm[index][0])
683+
else:
684+
if i == len(clos_per_vm[index]) - 1:
685+
clos_str = clos_str + ", {0}U}}".format(clos_per_vm[index][i])
686+
else:
687+
clos_str = clos_str + ", {0}U".format(clos_per_vm[index][i])
688+
689+
vm_clos_bmp['clos_map'] = clos_str
690+
return vm_clos_bmp
668691

669692
def get_vuart_info_id(config_file, idx):
670693
"""

misc/acrn-config/scenario_config/scenario_item.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ class VmInfo:
278278
name = {}
279279
load_order = {}
280280
uuid = {}
281-
clos_set = {}
281+
clos_per_vm = {}
282282
guest_flag_idx = {}
283283
cpus_per_vm = {}
284284
severity = {}
@@ -307,7 +307,9 @@ def get_info(self):
307307
self.scenario_info, "guest_flags", "guest_flag")
308308
self.cpus_per_vm = scenario_cfg_lib.get_leaf_tag_map(
309309
self.scenario_info, "vcpu_affinity", "pcpu_id")
310-
self.clos_set = scenario_cfg_lib.get_leaf_tag_map(self.scenario_info, "clos")
310+
self.clos_per_vm = scenario_cfg_lib.get_leaf_tag_map(
311+
self.scenario_info, "clos", "vcpu_clos")
312+
311313
self.severity = scenario_cfg_lib.get_leaf_tag_map(self.scenario_info, "severity")
312314
self.epc_section.get_info()
313315
self.mem_info.get_info()
@@ -323,6 +325,13 @@ def get_cpu_bitmap(self, index):
323325
"""
324326
return scenario_cfg_lib.cpus_assignment(self.cpus_per_vm, index)
325327

328+
def get_clos_bitmap(self, index):
329+
"""
330+
:param index: index list in GUESF_FLAGS
331+
:return: clos per vm and their vm id
332+
"""
333+
return scenario_cfg_lib.clos_assignment(self.clos_per_vm, index)
334+
326335
def check_item(self):
327336
"""
328337
Check all items in this class

misc/acrn-config/scenario_config/vm_configurations_c.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,8 @@ def clos_output(vm_info, i, config):
201201
common_clos_max = min(rdt_res_clos_max)
202202
else:
203203
common_clos_max = 0
204-
if len(rdt_res) != 0 and common_clos_max !=0 and i in vm_info.clos_set:
205-
print("\t\t.clos = {0}U,".format(vm_info.clos_set[i]), file=config)
206-
204+
if len(rdt_res) != 0 and common_clos_max !=0 and i in vm_info.clos_per_vm:
205+
print("\t\t.clos = VM{}_VCPU_CLOS,".format(i), file=config)
207206

208207
def get_guest_flag(flag_index):
209208
"""
@@ -274,7 +273,6 @@ def gen_sdc_source(vm_info, config):
274273
"there is supposed to be the highest severity guest */", file=config)
275274
print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config)
276275
vcpu_affinity_output(vm_info, 0, config)
277-
clos_output(vm_info, 0, config)
278276
print("\t\t.severity = {0},".format(vm_info.severity[0].strip()), file=config)
279277
print("\t\t.memory = {", file=config)
280278
print("\t\t\t.start_hpa = {}UL,".format(vm_info.mem_info.mem_start_hpa[0]), file=config)
@@ -555,9 +553,9 @@ def gen_industry_source(vm_info, config):
555553

556554
vcpu_affinity_output(vm_info, i, config)
557555
print("\t\t.severity = {0},".format(vm_info.severity[i].strip()), file=config)
556+
clos_output(vm_info, i, config)
558557

559558
if i == 0:
560-
clos_output(vm_info, i, config)
561559
print("\t\t.memory = {", file=config)
562560
print("\t\t\t.start_hpa = 0UL,", file=config)
563561
print("\t\t\t.size = CONFIG_SOS_RAM_SIZE,", file=config)

misc/acrn-config/scenario_config/vm_configurations_h.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#
55

66
import scenario_cfg_lib
7+
import board_cfg_lib
78

89
VM_HEADER_DEFINE = scenario_cfg_lib.HEADER_LICENSE + r"""
910
#ifndef VM_CONFIGURATIONS_H
@@ -35,6 +36,24 @@ def cpu_affinity_output(vm_info, i, config):
3536
print("#define VM{0}_CONFIG_VCPU_AFFINITY\t\t{1}".format(
3637
i, cpu_bits['cpu_map']), file=config)
3738

39+
def clos_config_output(vm_info, i, config):
40+
"""
41+
Output the macro vcpu affinity
42+
:param vm_info: the data structure have all the xml items values
43+
:param i: the index of vm id
44+
:param config: file pointor to store the information
45+
"""
46+
(rdt_res, rdt_res_clos_max, _) = board_cfg_lib.clos_info_parser(scenario_cfg_lib.BOARD_INFO_FILE)
47+
if len(rdt_res_clos_max) != 0:
48+
common_clos_max = min(rdt_res_clos_max)
49+
else:
50+
common_clos_max = 0
51+
52+
if common_clos_max == 0:
53+
return
54+
55+
clos_config = vm_info.get_clos_bitmap(i)
56+
print("#define VM{0}_VCPU_CLOS\t\t{1}".format(i, clos_config['clos_map']), file=config)
3857

3958
def scenario_vm_num(load_type_cnt, config):
4059

@@ -70,16 +89,19 @@ def gen_sdc_header(vm_info, config):
7089
print("#if CONFIG_MAX_KATA_VM_NUM > 0", file=config)
7190
# Set VM1 vcpu
7291
cpu_affinity_output(vm_info, 1, config)
92+
clos_config_output(vm_info, 1, config)
7393
# KATA VM
7494
cpu_affinity_output(vm_info, 2, config)
95+
clos_config_output(vm_info, 2, config)
7596
#else:
7697
print("#else", file=config)
7798
# Only two VMs in SDC config, setup vcpu affinity for VM1
7899
cpu_affinity_output(vm_info, 1, config)
100+
clos_config_output(vm_info, 1, config)
79101
print("#endif", file=config)
80102
else:
81103
cpu_affinity_output(vm_info, 1, config)
82-
104+
clos_config_output(vm_info, 1, config)
83105
print("", file=config)
84106
print("{0}".format(VM_END_DEFINE), file=config)
85107

@@ -108,6 +130,7 @@ def gen_sdc2_header(vm_info, config):
108130
print("", file=config)
109131
for i in range(scenario_cfg_lib.VM_COUNT):
110132
cpu_affinity_output(vm_info, i, config)
133+
clos_config_output(vm_info, i, config)
111134
print("", file=config)
112135
print("{0}".format(VM_END_DEFINE), file=config)
113136

@@ -157,6 +180,7 @@ def gen_logical_partition_header(vm_info, config):
157180

158181
cpu_bits = vm_info.get_cpu_bitmap(i)
159182
cpu_affinity_output(vm_info, i, config)
183+
clos_config_output(vm_info, i, config)
160184
print("#define VM{0}_CONFIG_MEM_START_HPA\t\t{1}UL".format(
161185
i, vm_info.mem_info.mem_start_hpa[i]), file=config)
162186
print("#define VM{0}_CONFIG_MEM_SIZE\t\t\t{1}UL".format(
@@ -225,6 +249,7 @@ def gen_industry_header(vm_info, config):
225249
print("", file=config)
226250
for i in range(scenario_cfg_lib.VM_COUNT):
227251
cpu_affinity_output(vm_info, i, config)
252+
clos_config_output(vm_info, i, config)
228253
print("", file=config)
229254
print("{0}".format(VM_END_DEFINE), file=config)
230255

@@ -249,6 +274,7 @@ def gen_hybrid_header(vm_info, config):
249274
print("", file=config)
250275
for i in range(scenario_cfg_lib.VM_COUNT):
251276
cpu_affinity_output(vm_info, i, config)
277+
clos_config_output(vm_info, i, config)
252278

253279
print("#define VM0_CONFIG_MEM_START_HPA\t{0}UL".format(
254280
vm_info.mem_info.mem_start_hpa[0]), file=config)

0 commit comments

Comments
 (0)