From 93ea0075dd3bd64890db5009f7da88dba856b515 Mon Sep 17 00:00:00 2001 From: Kunhui-Li Date: Wed, 25 Aug 2021 11:06:11 +0800 Subject: [PATCH] config_tools: update the regex pattern of offline cpu The pattern matching logic (used by 'tr') is erroneous in the launch script generation logic. While its purpose is to return the CPU number from the 'cpuX' string (where 'X' is the CPU number), it does it incorrectly for any multiple of 10. Examples: - Processing 'cpu10' returns 1 (instead of 10) - Processing 'cpu20' returns 2 (instead of 20) This patch changes the [1-99] pattern matching to [0-9] which fixes it. This error led to the incorrect CPU cores being used (and offlined) for some VMs which could lead to confusing problems especially when an exclusive use of that CPU core was assumed and expected (e.g. RTVM). when CONFIG_BOOTPARAM_HOTPLUG_CPU0 is turned on in the kernel, there is a risk that we try to offline cpu0. So we also add extra check for cpu0 to aviod the risk. Tracked-On: #6482 Signed-off-by: Kunhui-Li --- misc/config_tools/launch_config/com.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/config_tools/launch_config/com.py b/misc/config_tools/launch_config/com.py index 00871b797..be137d411 100644 --- a/misc/config_tools/launch_config/com.py +++ b/misc/config_tools/launch_config/com.py @@ -95,9 +95,9 @@ def off_line_cpus(args, vmid, uos_type, config): print(" for j in {}; do".format(' '.join([str(i) for i in pcpu_id_list])), file=config) print(' if [ "cpu"$j = $i ]; then', file=config) print(' online=`cat ${cpu_path}/$i/online`', file=config) - print(' idx=`echo $i | tr -cd "[1-99]"`', file=config) + print(' idx=`echo $i | tr -cd "[0-9]"`', file=config) print(' echo $i online=$online', file=config) - print(' if [ "$online" = "1" ]; then', file=config) + print(' if [ "$online" = "1" ] && [ "$idx" != "0" ]; then', file=config) print(" echo 0 > ${cpu_path}/$i/online", file=config) print(" online=`cat ${cpu_path}/$i/online`", file=config) print(" # during boot time, cpu hotplug may be disabled by pci_device_probe during a pci module insmod", file=config)