mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
numa: make -numa parser dynamically allocate CPUs masks
so it won't impose an additional limits on max_cpus limits supported by different targets. It removes global MAX_CPUMASK_BITS constant and need to bump it up whenever max_cpus is being increased for a target above MAX_CPUMASK_BITS value. Use runtime max_cpus value instead to allocate sufficiently sized node_cpu bitmasks in numa parser. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <1479466974-249781-1-git-send-email-imammedo@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> [ehabkost: Added asserts to ensure cpu_index < max_cpus] Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
410e98146f
commit
cdda2018e3
4 changed files with 15 additions and 20 deletions
21
numa.c
21
numa.c
|
@ -266,20 +266,19 @@ static char *enumerate_cpus(unsigned long *cpus, int max_cpus)
|
|||
static void validate_numa_cpus(void)
|
||||
{
|
||||
int i;
|
||||
DECLARE_BITMAP(seen_cpus, MAX_CPUMASK_BITS);
|
||||
unsigned long *seen_cpus = bitmap_new(max_cpus);
|
||||
|
||||
bitmap_zero(seen_cpus, MAX_CPUMASK_BITS);
|
||||
for (i = 0; i < nb_numa_nodes; i++) {
|
||||
if (bitmap_intersects(seen_cpus, numa_info[i].node_cpu,
|
||||
MAX_CPUMASK_BITS)) {
|
||||
if (bitmap_intersects(seen_cpus, numa_info[i].node_cpu, max_cpus)) {
|
||||
bitmap_and(seen_cpus, seen_cpus,
|
||||
numa_info[i].node_cpu, MAX_CPUMASK_BITS);
|
||||
numa_info[i].node_cpu, max_cpus);
|
||||
error_report("CPU(s) present in multiple NUMA nodes: %s",
|
||||
enumerate_cpus(seen_cpus, max_cpus));
|
||||
g_free(seen_cpus);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
bitmap_or(seen_cpus, seen_cpus,
|
||||
numa_info[i].node_cpu, MAX_CPUMASK_BITS);
|
||||
numa_info[i].node_cpu, max_cpus);
|
||||
}
|
||||
|
||||
if (!bitmap_full(seen_cpus, max_cpus)) {
|
||||
|
@ -291,12 +290,17 @@ static void validate_numa_cpus(void)
|
|||
"in NUMA config");
|
||||
g_free(msg);
|
||||
}
|
||||
g_free(seen_cpus);
|
||||
}
|
||||
|
||||
void parse_numa_opts(MachineClass *mc)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_NODES; i++) {
|
||||
numa_info[i].node_cpu = bitmap_new(max_cpus);
|
||||
}
|
||||
|
||||
if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, NULL, NULL)) {
|
||||
exit(1);
|
||||
}
|
||||
|
@ -362,7 +366,7 @@ void parse_numa_opts(MachineClass *mc)
|
|||
numa_set_mem_ranges();
|
||||
|
||||
for (i = 0; i < nb_numa_nodes; i++) {
|
||||
if (!bitmap_empty(numa_info[i].node_cpu, MAX_CPUMASK_BITS)) {
|
||||
if (!bitmap_empty(numa_info[i].node_cpu, max_cpus)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -397,6 +401,7 @@ void numa_post_machine_init(void)
|
|||
|
||||
CPU_FOREACH(cpu) {
|
||||
for (i = 0; i < nb_numa_nodes; i++) {
|
||||
assert(cpu->cpu_index < max_cpus);
|
||||
if (test_bit(cpu->cpu_index, numa_info[i].node_cpu)) {
|
||||
cpu->numa_node = i;
|
||||
}
|
||||
|
@ -558,6 +563,8 @@ int numa_get_node_for_cpu(int idx)
|
|||
{
|
||||
int i;
|
||||
|
||||
assert(idx < max_cpus);
|
||||
|
||||
for (i = 0; i < nb_numa_nodes; i++) {
|
||||
if (test_bit(idx, numa_info[i].node_cpu)) {
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue