acrn-config: add cpu_affinity for SOS VM

Add cpu_affinity setup for SOS VM. Cpu affinity must be set in
scenario XML, except if no pre-launched VM on the scenario and
all pCPUs will be assigned to SOS VM in that case;

Tracked-On: #5077
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
This commit is contained in:
Victor Sun 2020-07-31 11:37:49 +08:00 committed by wenlingz
parent 2d53bb7123
commit 36732d4797
16 changed files with 85 additions and 8 deletions

View File

@ -240,6 +240,7 @@ def vm_cpu_affinity_check(config_file, id_cpus_per_vm_dic, item):
else:
use_cpus.append(cpu)
sos_vm_cpus = []
pre_launch_cpus = []
post_launch_cpus = []
for vm_i, vm_type in common.VM_TYPES.items():
@ -251,6 +252,9 @@ def vm_cpu_affinity_check(config_file, id_cpus_per_vm_dic, item):
elif VM_DB[vm_type]['load_type'] == "POST_LAUNCHED_VM":
cpus = [x for x in id_cpus_per_vm_dic[vm_i] if not None]
post_launch_cpus.extend(cpus)
elif VM_DB[vm_type]['load_type'] == "SOS_VM":
cpus = [x for x in id_cpus_per_vm_dic[vm_i] if not None]
sos_vm_cpus.extend(cpus)
# duplicate cpus assign the same VM check
cpus_vm_i = id_cpus_per_vm_dic[vm_i]
@ -261,6 +265,10 @@ def vm_cpu_affinity_check(config_file, id_cpus_per_vm_dic, item):
return err_dic
if pre_launch_cpus:
if "SOS_VM" in common.VM_TYPES and not sos_vm_cpus:
key = "SOS VM cpu_affinity"
err_dic[key] = "Should assign CPU id for SOS VM"
for pcpu in pre_launch_cpus:
if pre_launch_cpus.count(pcpu) >= 2:
key = "Pre launched VM cpu_affinity"
@ -475,6 +483,10 @@ def cpus_assignment(cpus_per_vm, index):
:return: cpu assignment string
"""
vm_cpu_bmp = {}
if "SOS_VM" == common.VM_TYPES[index]:
if index not in cpus_per_vm:
sos_extend_all_cpus = board_cfg_lib.get_processor_info()
cpus_per_vm[index] = sos_extend_all_cpus
for i in range(len(cpus_per_vm[index])):
if i == 0:

View File

@ -193,11 +193,11 @@ def cpu_affinity_output(vm_info, i, config):
:param i: the index of vm id
:param config: file pointor to store the information
"""
if "SOS_VM" == scenario_cfg_lib.VM_DB[vm_info.load_vm[i]]['load_type']:
return
cpu_bits = vm_info.get_cpu_bitmap(i)
print("\t\t.cpu_affinity = VM{}_CONFIG_CPU_AFFINITY,".format(i), file=config)
if "SOS_VM" == common.VM_TYPES[i]:
print("\t\t.cpu_affinity = SOS_VM_CONFIG_CPU_AFFINITY,", file=config)
else:
print("\t\t.cpu_affinity = VM{}_CONFIG_CPU_AFFINITY,".format(i), file=config)
def clos_output(scenario_items, i, config):

View File

@ -30,12 +30,15 @@ def cpu_affinity_output(vm_info, i, config):
:param i: the index of vm id
:param config: file pointor to store the information
"""
if "SOS_VM" == scenario_cfg_lib.VM_DB[vm_info.load_vm[i]]['load_type']:
return
cpu_bits = vm_info.get_cpu_bitmap(i)
print("#define VM{0}_CONFIG_CPU_AFFINITY {1}".format(
i, cpu_bits['cpu_map']), file=config)
if "SOS_VM" == common.VM_TYPES[i]:
print("", file=config)
print("#define SOS_VM_CONFIG_CPU_AFFINITY {0}".format(
cpu_bits['cpu_map']), file=config)
else:
print("#define VM{0}_CONFIG_CPU_AFFINITY {1}".format(
i, cpu_bits['cpu_map']), file=config)
def clos_config_output(scenario_items, i, config):
"""
@ -120,8 +123,10 @@ def gen_sos_header(scenario_items, config):
print("\t\t\t\t\tSOS_IDLE\t\\", file=config)
print("\t\t\t\t\tSOS_BOOTARGS_DIFF", file=config)
vm_info = scenario_items['vm']
for vm_i,vm_type in common.VM_TYPES.items():
if vm_type == 'SOS_VM':
cpu_affinity_output(vm_info, vm_i, config)
clos_config_output(scenario_items, vm_i, config)
print("", file=config)

View File

@ -109,6 +109,11 @@
<guest_flags desc="Select all applicable flags for the VM" multiselect="true">
<guest_flag>0</guest_flag>
</guest_flags>
<cpu_affinity desc="List of pCPU that this VM's vCPUs are pinned to.">
<pcpu_id>0</pcpu_id>
<pcpu_id>1</pcpu_id>
<pcpu_id>2</pcpu_id>
</cpu_affinity>
<clos configurable="0" desc="Class of Service for Cache Allocation Technology. Please refer SDM 17.19.2 for details and use with caution.">
<vcpu_clos>0</vcpu_clos>
</clos>

View File

@ -109,6 +109,11 @@
<guest_flags desc="Select all applicable flags for the VM" multiselect="true">
<guest_flag>0</guest_flag>
</guest_flags>
<cpu_affinity desc="List of pCPU that this VM's vCPUs are pinned to.">
<pcpu_id>0</pcpu_id>
<pcpu_id>1</pcpu_id>
<pcpu_id>2</pcpu_id>
</cpu_affinity>
<clos configurable="0" desc="Class of Service for Cache Allocation Technology. Please refer SDM 17.19.2 for details and use with caution.">
<vcpu_clos>0</vcpu_clos>
</clos>

View File

@ -117,6 +117,11 @@
<guest_flags desc="Select all applicable flags for the VM" multiselect="true">
<guest_flag>0</guest_flag>
</guest_flags>
<cpu_affinity desc="List of pCPU that this VM's vCPUs are pinned to.">
<pcpu_id>0</pcpu_id>
<pcpu_id>1</pcpu_id>
<pcpu_id>2</pcpu_id>
</cpu_affinity>
<clos configurable="0" desc="Class of Service for Cache Allocation Technology. Please refer SDM 17.19.2 for details and use with caution.">
<vcpu_clos>0</vcpu_clos>
</clos>

View File

@ -107,6 +107,11 @@
<guest_flags desc="Select all applicable flags for the VM" multiselect="true">
<guest_flag>0</guest_flag>
</guest_flags>
<cpu_affinity desc="List of pCPU that this VM's vCPUs are pinned to.">
<pcpu_id>0</pcpu_id>
<pcpu_id>1</pcpu_id>
<pcpu_id>2</pcpu_id>
</cpu_affinity>
<clos configurable="0" desc="Class of Service for Cache Allocation Technology. Please refer SDM 17.19.2 for details and use with caution.">
<vcpu_clos>0</vcpu_clos>
</clos>

View File

@ -105,6 +105,10 @@
<guest_flags desc="Select all applicable flags for the VM" multiselect="true">
<guest_flag>0</guest_flag>
</guest_flags>
<cpu_affinity desc="List of pCPU that this VM's vCPUs are pinned to.">
<pcpu_id>0</pcpu_id>
<pcpu_id>1</pcpu_id>
</cpu_affinity>
<clos configurable="0" desc="Class of Service for Cache Allocation Technology. Please refer SDM 17.19.2 for details and use with caution.">
<vcpu_clos>0</vcpu_clos>
</clos>

View File

@ -109,6 +109,11 @@
<guest_flags desc="Select all applicable flags for the VM" multiselect="true">
<guest_flag>0</guest_flag>
</guest_flags>
<cpu_affinity desc="List of pCPU that this VM's vCPUs are pinned to.">
<pcpu_id>0</pcpu_id>
<pcpu_id>1</pcpu_id>
<pcpu_id>2</pcpu_id>
</cpu_affinity>
<clos configurable="0" desc="Class of Service for Cache Allocation Technology. Please refer SDM 17.19.2 for details and use with caution.">
<vcpu_clos>0</vcpu_clos>
</clos>

View File

@ -105,6 +105,11 @@
<guest_flags desc="Select all applicable flags for the VM" multiselect="true">
<guest_flag>0</guest_flag>
</guest_flags>
<cpu_affinity desc="List of pCPU that this VM's vCPUs are pinned to.">
<pcpu_id>0</pcpu_id>
<pcpu_id>1</pcpu_id>
<pcpu_id>2</pcpu_id>
</cpu_affinity>
<clos configurable="0" desc="Class of Service for Cache Allocation Technology. Please refer SDM 17.19.2 for details and use with caution.">
<vcpu_clos>0</vcpu_clos>
</clos>

View File

@ -5,6 +5,9 @@
<guest_flags desc="Select all applicable flags for the VM" multiselect="true">
<guest_flag></guest_flag>
</guest_flags>
<cpu_affinity desc="List of pCPU that this VM's vCPUs are pinned to.">
<pcpu_id></pcpu_id>
</cpu_affinity>
<clos configurable="0" desc="Class of Service for Cache Allocation Technology. Please refer SDM 17.19.2 for details and use with caution.">
<vcpu_clos>0</vcpu_clos>
</clos>

View File

@ -105,6 +105,11 @@
<guest_flags desc="Select all applicable flags for the VM" multiselect="true">
<guest_flag>0</guest_flag>
</guest_flags>
<cpu_affinity desc="List of pCPU that this VM's vCPUs are pinned to.">
<pcpu_id>0</pcpu_id>
<pcpu_id>1</pcpu_id>
<pcpu_id>2</pcpu_id>
</cpu_affinity>
<clos configurable="0" desc="Class of Service for Cache Allocation Technology. Please refer SDM 17.19.2 for details and use with caution.">
<vcpu_clos>0</vcpu_clos>
</clos>

View File

@ -105,6 +105,11 @@
<guest_flags desc="Select all applicable flags for the VM" multiselect="true">
<guest_flag>0</guest_flag>
</guest_flags>
<cpu_affinity desc="List of pCPU that this VM's vCPUs are pinned to.">
<pcpu_id>0</pcpu_id>
<pcpu_id>1</pcpu_id>
<pcpu_id>2</pcpu_id>
</cpu_affinity>
<clos configurable="0" desc="Class of Service for Cache Allocation Technology. Please refer SDM 17.19.2 for details and use with caution.">
<vcpu_clos>0</vcpu_clos>
</clos>

View File

@ -106,6 +106,10 @@
<guest_flags desc="Select all applicable flags for the VM" multiselect="true">
<guest_flag>0</guest_flag>
</guest_flags>
<cpu_affinity desc="List of pCPU that this VM's vCPUs are pinned to.">
<pcpu_id>0</pcpu_id>
<pcpu_id>1</pcpu_id>
</cpu_affinity>
<clos configurable="0" desc="Class of Service for Cache Allocation Technology. Please refer SDM 17.19.2 for details and use with caution.">
<vcpu_clos>0</vcpu_clos>
</clos>

View File

@ -105,6 +105,11 @@
<guest_flags desc="Select all applicable flags for the VM" multiselect="true">
<guest_flag>0</guest_flag>
</guest_flags>
<cpu_affinity desc="List of pCPU that this VM's vCPUs are pinned to.">
<pcpu_id>0</pcpu_id>
<pcpu_id>1</pcpu_id>
<pcpu_id>2</pcpu_id>
</cpu_affinity>
<clos configurable="0" desc="Class of Service for Cache Allocation Technology. Please refer SDM 17.19.2 for details and use with caution.">
<vcpu_clos>0</vcpu_clos>
</clos>

View File

@ -106,6 +106,10 @@
<guest_flags desc="Select all applicable flags for the VM" multiselect="true">
<guest_flag>0</guest_flag>
</guest_flags>
<cpu_affinity desc="List of pCPU that this VM's vCPUs are pinned to.">
<pcpu_id>0</pcpu_id>
<pcpu_id>1</pcpu_id>
</cpu_affinity>
<clos configurable="0" desc="Class of Service for Cache Allocation Technology. Please refer SDM 17.19.2 for details and use with caution.">
<vcpu_clos>0</vcpu_clos>
</clos>