dm: use lapic id to set cpu affinity.

Cpu affinty was set by pcpu id which can't be obtained
explictly by user. Use lapic id instead which can be easily
read from `/proc/cpuinfo` as `apicid`.

Tracked-On: #6690
Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@linux.intel.com>
Acked-by: Wang Yu1 <yu1.wang@intel.com>
This commit is contained in:
Yuanyuan Zhao 2021-12-22 21:21:31 +08:00 committed by acrnsi-robot
parent c5537ec4d4
commit 8a44067f8b
2 changed files with 11 additions and 33 deletions

View File

@ -145,7 +145,7 @@ usage(int code)
" %*s [--enable_trusty] [--intr_monitor param_setting]\n"
" %*s [--acpidev_pt HID] [--mmiodev_pt MMIO_Regions]\n"
" %*s [--vtpm2 sock_path] [--virtio_poll interval]\n"
" %*s [--cpu_affinity pCPUs] [--lapic_pt] [--rtvm] [--windows]\n"
" %*s [--cpu_affinity lapic_id] [--lapic_pt] [--rtvm] [--windows]\n"
" %*s [--debugexit] [--logger_setting param_setting]\n"
" %*s [--ssram] <vm>\n"
" -B: bootargs for kernel\n"
@ -159,7 +159,8 @@ usage(int code)
" -v: version\n"
" --ovmf: ovmf file path\n"
" --ssram: Congfiure Software SRAM parameters\n"
" --cpu_affinity: list of pCPUs assigned to this VM\n"
" --cpu_affinity: list of Service VM vCPUs assigned to this User VM, the vCPUs are"
" identified by their local APIC IDs.\n"
" --enable_trusty: enable trusty for guest\n"
" --debugexit: enable debug exit function\n"
" --intr_monitor: enable interrupt storm monitor\n"

View File

@ -47,6 +47,7 @@
#include "pci_core.h"
#include "log.h"
#include "sw_load.h"
#include "acpi.h"
#define MAP_NOCORE 0
#define MAP_ALIGNED_SUPER 0
@ -93,15 +94,11 @@ static void add_one_pcpu(int pcpu_id)
/*
* example options:
* --cpu_affinity 1,2,3
* --cpu_affinity 1-3
* --cpu_affinity 1,3,4-6
* --cpu_affinity 1,3,4-6,9
*/
int acrn_parse_cpu_affinity(char *opt)
{
char *str, *cp, *cp_opt;
int pcpu_id;
int pcpu_start, pcpu_end;
int lapic_id;
cp_opt = cp = strdup(opt);
if (!cp) {
@ -111,12 +108,12 @@ int acrn_parse_cpu_affinity(char *opt)
/* white spaces within the commane line are invalid */
while (cp && isdigit(cp[0])) {
str = strpbrk(cp, ",-");
str = strpbrk(cp, ",");
/* no more entries delimited by ',' or '-' */
/* no more entries delimited by ',' */
if (!str) {
if (!dm_strtoi(cp, NULL, 10, &pcpu_id)) {
add_one_pcpu(pcpu_id);
if (!dm_strtoi(cp, NULL, 10, &lapic_id)) {
add_one_pcpu(lapic_to_pcpu(lapic_id));
}
break;
} else {
@ -125,30 +122,10 @@ int acrn_parse_cpu_affinity(char *opt)
str = strsep(&cp, ",");
/* parse the entry before ',' */
if (dm_strtoi(str, NULL, 10, &pcpu_id)) {
if (dm_strtoi(str, NULL, 10, &lapic_id)) {
goto err;
}
add_one_pcpu(pcpu_id);
}
if (*str == '-') {
str = strsep(&cp, "-");
/* parse the entry before and after '-' respectively */
if (dm_strtoi(str, NULL, 10, &pcpu_start) || dm_strtoi(cp, NULL, 10, &pcpu_end)) {
goto err;
}
if (pcpu_end <= pcpu_start) {
goto err;
}
for (; pcpu_start <= pcpu_end; pcpu_start++) {
add_one_pcpu(pcpu_start);
}
/* skip the ',' after pcpu_end */
str = strsep(&cp, ",");
add_one_pcpu(lapic_to_pcpu(lapic_id));
}
}
}