Received: from eggs.gnu.org ([2001:4830:134:3::10]:38898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c93nU-0003MZ-Po for qemu-devel@nongnu.org; Tue, 22 Nov 2016 00:39:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c93nR-0003Wk-EV for qemu-devel@nongnu.org; Tue, 22 Nov 2016 00:39:12 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:36609) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c93nR-0003VD-4V for qemu-devel@nongnu.org; Tue, 22 Nov 2016 00:39:09 -0500 Received: by mail-pf0-x242.google.com with SMTP id c4so643361pfb.3 for ; Mon, 21 Nov 2016 21:39:08 -0800 (PST) References: <1479466974-249781-1-git-send-email-imammedo@redhat.com> From: Alexey Kardashevskiy Message-ID: Date: Tue, 22 Nov 2016 16:39:01 +1100 MIME-Version: 1.0 In-Reply-To: <1479466974-249781-1-git-send-email-imammedo@redhat.com> Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH for-2.9] numa: make -numa parser dynamically allocate CPUs masks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov , qemu-devel@nongnu.org Cc: Greg Kurz , David Gibson , Eduardo Habkost , Paolo Bonzini On 18/11/16 22:02, Igor Mammedov wrote: > 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 > --- > v1: > - replace bitmap_free() with g_free() > - drop bitmap_zero() as bitmap_new() returns already zerroed out one > > CC: Alexey Kardashevskiy Tested-by: Alexey Kardashevskiy > CC: Greg Kurz > CC: David Gibson > CC: Eduardo Habkost > CC: Paolo Bonzini > --- > include/sysemu/numa.h | 2 +- > include/sysemu/sysemu.h | 7 ------- > numa.c | 18 +++++++++++------- > vl.c | 5 ----- > 4 files changed, 12 insertions(+), 20 deletions(-) > > diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h > index 4da808a..8f09dcf 100644 > --- a/include/sysemu/numa.h > +++ b/include/sysemu/numa.h > @@ -17,7 +17,7 @@ struct numa_addr_range { > > typedef struct node_info { > uint64_t node_mem; > - DECLARE_BITMAP(node_cpu, MAX_CPUMASK_BITS); > + unsigned long *node_cpu; > struct HostMemoryBackend *node_memdev; > bool present; > QLIST_HEAD(, numa_addr_range) addr; /* List to store address ranges */ > diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h > index 66c6f15..cccde56 100644 > --- a/include/sysemu/sysemu.h > +++ b/include/sysemu/sysemu.h > @@ -168,13 +168,6 @@ extern int mem_prealloc; > #define MAX_NODES 128 > #define NUMA_NODE_UNASSIGNED MAX_NODES > > -/* The following shall be true for all CPUs: > - * cpu->cpu_index < max_cpus <= MAX_CPUMASK_BITS > - * > - * Note that cpu->get_arch_id() may be larger than MAX_CPUMASK_BITS. > - */ > -#define MAX_CPUMASK_BITS 288 > - > #define MAX_OPTION_ROMS 16 > typedef struct QEMUOptionRom { > const char *name; > diff --git a/numa.c b/numa.c > index 9c09e45..1b6fa78 100644 > --- a/numa.c > +++ b/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; > } > } > diff --git a/vl.c b/vl.c > index d77dd86..37790e5 100644 > --- a/vl.c > +++ b/vl.c > @@ -1277,11 +1277,6 @@ static void smp_parse(QemuOpts *opts) > > max_cpus = qemu_opt_get_number(opts, "maxcpus", cpus); > > - if (max_cpus > MAX_CPUMASK_BITS) { > - error_report("unsupported number of maxcpus"); > - exit(1); > - } > - > if (max_cpus < cpus) { > error_report("maxcpus must be equal to or greater than smp"); > exit(1); > -- Alexey