From 4083da947051f2bdcc13c1868cb8b17b353c636b Mon Sep 17 00:00:00 2001 From: Yuanyuan Zhao Date: Tue, 27 Sep 2022 11:37:20 +0800 Subject: [PATCH] config_tools: offline CPUs owned by User VMs When launch a User VM own pCPUs, offline Service VM vCPUs which use the same pCPUs by launch script. Tracked-On: #8253 Signed-off-by: Yuanyuan Zhao Reviewed-by: Junjie Mao --- misc/config_tools/launch_config/launch_cfg_gen.py | 1 + misc/config_tools/launch_config/launch_script_template.sh | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/misc/config_tools/launch_config/launch_cfg_gen.py b/misc/config_tools/launch_config/launch_cfg_gen.py index 05ed0a396..c6cd581a6 100755 --- a/misc/config_tools/launch_config/launch_cfg_gen.py +++ b/misc/config_tools/launch_config/launch_cfg_gen.py @@ -260,6 +260,7 @@ def generate_for_one_vm(board_etree, hv_scenario_etree, vm_scenario_etree, vm_id script.add_plain_dm_parameter("--windows") script.add_vm_descriptor("vm_type", f"'{eval_xpath(vm_scenario_etree, './/vm_type/text()', 'STANDARD_VM')}'") script.add_vm_descriptor("scheduler", f"'{eval_xpath(hv_scenario_etree, './/SCHEDULER/text()')}'") + script.add_vm_descriptor("own_pcpu", f"'{eval_xpath(vm_scenario_etree, './/own_pcpu/text()')}'") ### # CPU and memory resources diff --git a/misc/config_tools/launch_config/launch_script_template.sh b/misc/config_tools/launch_config/launch_script_template.sh index db11885f3..ca593b946 100644 --- a/misc/config_tools/launch_config/launch_script_template.sh +++ b/misc/config_tools/launch_config/launch_script_template.sh @@ -19,11 +19,15 @@ function offline_cpus() { if [ -z ${processor_id} ]; then continue fi + if [ "${processor_id}" = "0" ]; then + echo "Warning: processor 0 can't be offline, there may be unexpect error!" >> /dev/stderr + continue + fi cpu_path="/sys/devices/system/cpu/cpu${processor_id}" if [ -f ${cpu_path}/online ]; then online=`cat ${cpu_path}/online` echo cpu${processor_id} online=${online} >> /dev/stderr - if [ "${online}" = "1" ] && [ "${processor_id}" != "0" ]; then + if [ "${online}" = "1" ]; then echo 0 > ${cpu_path}/online online=`cat ${cpu_path}/online` # during boot time, cpu hotplug may be disabled by pci_device_probe during a pci module insmod @@ -90,7 +94,7 @@ function add_cpus() { # Each parameter of this function is considered the apicid of processor (as is reported in /proc/cpuinfo) of # a CPU assigned to a post-launched RTVM. - if [ "${vm_type}" = "RTVM" ] || [ "${scheduler}" = "SCHED_NOOP" ]; then + if [ "${vm_type}" = "RTVM" ] || [ "${scheduler}" = "SCHED_NOOP" ] || [ "${own_pcpu}" = "y" ]; then offline_cpus $* fi