mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-28 16:27:01 +00:00
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:
parent
c5537ec4d4
commit
8a44067f8b
@ -145,7 +145,7 @@ usage(int code)
|
|||||||
" %*s [--enable_trusty] [--intr_monitor param_setting]\n"
|
" %*s [--enable_trusty] [--intr_monitor param_setting]\n"
|
||||||
" %*s [--acpidev_pt HID] [--mmiodev_pt MMIO_Regions]\n"
|
" %*s [--acpidev_pt HID] [--mmiodev_pt MMIO_Regions]\n"
|
||||||
" %*s [--vtpm2 sock_path] [--virtio_poll interval]\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 [--debugexit] [--logger_setting param_setting]\n"
|
||||||
" %*s [--ssram] <vm>\n"
|
" %*s [--ssram] <vm>\n"
|
||||||
" -B: bootargs for kernel\n"
|
" -B: bootargs for kernel\n"
|
||||||
@ -159,7 +159,8 @@ usage(int code)
|
|||||||
" -v: version\n"
|
" -v: version\n"
|
||||||
" --ovmf: ovmf file path\n"
|
" --ovmf: ovmf file path\n"
|
||||||
" --ssram: Congfiure Software SRAM parameters\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"
|
" --enable_trusty: enable trusty for guest\n"
|
||||||
" --debugexit: enable debug exit function\n"
|
" --debugexit: enable debug exit function\n"
|
||||||
" --intr_monitor: enable interrupt storm monitor\n"
|
" --intr_monitor: enable interrupt storm monitor\n"
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
#include "pci_core.h"
|
#include "pci_core.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "sw_load.h"
|
#include "sw_load.h"
|
||||||
|
#include "acpi.h"
|
||||||
|
|
||||||
#define MAP_NOCORE 0
|
#define MAP_NOCORE 0
|
||||||
#define MAP_ALIGNED_SUPER 0
|
#define MAP_ALIGNED_SUPER 0
|
||||||
@ -93,15 +94,11 @@ static void add_one_pcpu(int pcpu_id)
|
|||||||
/*
|
/*
|
||||||
* example options:
|
* example options:
|
||||||
* --cpu_affinity 1,2,3
|
* --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)
|
int acrn_parse_cpu_affinity(char *opt)
|
||||||
{
|
{
|
||||||
char *str, *cp, *cp_opt;
|
char *str, *cp, *cp_opt;
|
||||||
int pcpu_id;
|
int lapic_id;
|
||||||
int pcpu_start, pcpu_end;
|
|
||||||
|
|
||||||
cp_opt = cp = strdup(opt);
|
cp_opt = cp = strdup(opt);
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
@ -111,12 +108,12 @@ int acrn_parse_cpu_affinity(char *opt)
|
|||||||
|
|
||||||
/* white spaces within the commane line are invalid */
|
/* white spaces within the commane line are invalid */
|
||||||
while (cp && isdigit(cp[0])) {
|
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 (!str) {
|
||||||
if (!dm_strtoi(cp, NULL, 10, &pcpu_id)) {
|
if (!dm_strtoi(cp, NULL, 10, &lapic_id)) {
|
||||||
add_one_pcpu(pcpu_id);
|
add_one_pcpu(lapic_to_pcpu(lapic_id));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@ -125,30 +122,10 @@ int acrn_parse_cpu_affinity(char *opt)
|
|||||||
str = strsep(&cp, ",");
|
str = strsep(&cp, ",");
|
||||||
|
|
||||||
/* parse the entry before ',' */
|
/* parse the entry before ',' */
|
||||||
if (dm_strtoi(str, NULL, 10, &pcpu_id)) {
|
if (dm_strtoi(str, NULL, 10, &lapic_id)) {
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
add_one_pcpu(pcpu_id);
|
add_one_pcpu(lapic_to_pcpu(lapic_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, ",");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user