Revision ee785fed
b/cpus.c | ||
---|---|---|
36 | 36 |
#include "cpus.h" |
37 | 37 |
#include "qtest.h" |
38 | 38 |
#include "main-loop.h" |
39 |
#include "bitmap.h" |
|
39 | 40 |
|
40 | 41 |
#ifndef _WIN32 |
41 | 42 |
#include "compatfd.h" |
... | ... | |
1159 | 1160 |
|
1160 | 1161 |
for (env = first_cpu; env != NULL; env = env->next_cpu) { |
1161 | 1162 |
for (i = 0; i < nb_numa_nodes; i++) { |
1162 |
if (node_cpumask[i] & (1 << env->cpu_index)) {
|
|
1163 |
if (test_bit(env->cpu_index, node_cpumask[i])) {
|
|
1163 | 1164 |
env->numa_node = i; |
1164 | 1165 |
} |
1165 | 1166 |
} |
b/hw/pc.c | ||
---|---|---|
49 | 49 |
#include "memory.h" |
50 | 50 |
#include "exec-memory.h" |
51 | 51 |
#include "arch_init.h" |
52 |
#include "bitmap.h" |
|
52 | 53 |
|
53 | 54 |
/* output Bochs bios info messages */ |
54 | 55 |
//#define DEBUG_BIOS |
... | ... | |
625 | 626 |
numa_fw_cfg[0] = cpu_to_le64(nb_numa_nodes); |
626 | 627 |
for (i = 0; i < max_cpus; i++) { |
627 | 628 |
for (j = 0; j < nb_numa_nodes; j++) { |
628 |
if (node_cpumask[j] & (1 << i)) {
|
|
629 |
if (test_bit(i, node_cpumask[j])) {
|
|
629 | 630 |
numa_fw_cfg[i + 1] = cpu_to_le64(j); |
630 | 631 |
break; |
631 | 632 |
} |
b/sysemu.h | ||
---|---|---|
134 | 134 |
extern QEMUClock *rtc_clock; |
135 | 135 |
|
136 | 136 |
#define MAX_NODES 64 |
137 |
#define MAX_CPUMASK_BITS 255 |
|
137 | 138 |
extern int nb_numa_nodes; |
138 | 139 |
extern uint64_t node_mem[MAX_NODES]; |
139 |
extern uint64_t node_cpumask[MAX_NODES];
|
|
140 |
extern unsigned long *node_cpumask[MAX_NODES];
|
|
140 | 141 |
|
141 | 142 |
#define MAX_OPTION_ROMS 16 |
142 | 143 |
typedef struct QEMUOptionRom { |
b/vl.c | ||
---|---|---|
28 | 28 |
#include <errno.h> |
29 | 29 |
#include <sys/time.h> |
30 | 30 |
#include <zlib.h> |
31 |
#include "bitmap.h" |
|
31 | 32 |
|
32 | 33 |
/* Needed early for CONFIG_BSD etc. */ |
33 | 34 |
#include "config-host.h" |
... | ... | |
241 | 242 |
|
242 | 243 |
int nb_numa_nodes; |
243 | 244 |
uint64_t node_mem[MAX_NODES]; |
244 |
uint64_t node_cpumask[MAX_NODES];
|
|
245 |
unsigned long *node_cpumask[MAX_NODES];
|
|
245 | 246 |
|
246 | 247 |
uint8_t qemu_uuid[16]; |
247 | 248 |
|
... | ... | |
952 | 953 |
unsigned long long value, endvalue; |
953 | 954 |
int nodenr; |
954 | 955 |
|
956 |
value = endvalue = 0ULL; |
|
957 |
|
|
955 | 958 |
optarg = get_opt_name(option, 128, optarg, ',') + 1; |
956 | 959 |
if (!strcmp(option, "node")) { |
957 | 960 |
if (get_param_value(option, 128, "nodeid", optarg) == 0) { |
... | ... | |
971 | 974 |
} |
972 | 975 |
node_mem[nodenr] = sval; |
973 | 976 |
} |
974 |
if (get_param_value(option, 128, "cpus", optarg) == 0) { |
|
975 |
node_cpumask[nodenr] = 0; |
|
976 |
} else { |
|
977 |
if (get_param_value(option, 128, "cpus", optarg) != 0) { |
|
977 | 978 |
value = strtoull(option, &endptr, 10); |
978 |
if (value >= 64) { |
|
979 |
value = 63; |
|
980 |
fprintf(stderr, "only 64 CPUs in NUMA mode supported.\n"); |
|
979 |
if (*endptr == '-') { |
|
980 |
endvalue = strtoull(endptr+1, &endptr, 10); |
|
981 | 981 |
} else { |
982 |
if (*endptr == '-') { |
|
983 |
endvalue = strtoull(endptr+1, &endptr, 10); |
|
984 |
if (endvalue >= 63) { |
|
985 |
endvalue = 62; |
|
986 |
fprintf(stderr, |
|
987 |
"only 63 CPUs in NUMA mode supported.\n"); |
|
988 |
} |
|
989 |
value = (2ULL << endvalue) - (1ULL << value); |
|
990 |
} else { |
|
991 |
value = 1ULL << value; |
|
992 |
} |
|
982 |
endvalue = value; |
|
983 |
} |
|
984 |
|
|
985 |
if (!(endvalue < MAX_CPUMASK_BITS)) { |
|
986 |
endvalue = MAX_CPUMASK_BITS - 1; |
|
987 |
fprintf(stderr, |
|
988 |
"A max of %d CPUs are supported in a guest\n", |
|
989 |
MAX_CPUMASK_BITS); |
|
993 | 990 |
} |
994 |
node_cpumask[nodenr] = value; |
|
991 |
|
|
992 |
bitmap_set(node_cpumask[nodenr], value, endvalue-value+1); |
|
995 | 993 |
} |
996 | 994 |
nb_numa_nodes++; |
997 | 995 |
} |
... | ... | |
2331 | 2329 |
|
2332 | 2330 |
for (i = 0; i < MAX_NODES; i++) { |
2333 | 2331 |
node_mem[i] = 0; |
2334 |
node_cpumask[i] = 0;
|
|
2332 |
node_cpumask[i] = bitmap_new(MAX_CPUMASK_BITS);
|
|
2335 | 2333 |
} |
2336 | 2334 |
|
2337 | 2335 |
nb_numa_nodes = 0; |
... | ... | |
3468 | 3466 |
} |
3469 | 3467 |
|
3470 | 3468 |
for (i = 0; i < nb_numa_nodes; i++) { |
3471 |
if (node_cpumask[i] != 0)
|
|
3469 |
if (!bitmap_empty(node_cpumask[i], MAX_CPUMASK_BITS)) {
|
|
3472 | 3470 |
break; |
3471 |
} |
|
3473 | 3472 |
} |
3474 | 3473 |
/* assigning the VCPUs round-robin is easier to implement, guest OSes |
3475 | 3474 |
* must cope with this anyway, because there are BIOSes out there in |
... | ... | |
3477 | 3476 |
*/ |
3478 | 3477 |
if (i == nb_numa_nodes) { |
3479 | 3478 |
for (i = 0; i < max_cpus; i++) { |
3480 |
node_cpumask[i % nb_numa_nodes] |= 1 << i;
|
|
3479 |
set_bit(i, node_cpumask[i % nb_numa_nodes]);
|
|
3481 | 3480 |
} |
3482 | 3481 |
} |
3483 | 3482 |
} |
Also available in: Unified diff