From patchwork Wed Dec 28 17:08:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 709378 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tpfNs0WFnz9t1C for ; Thu, 29 Dec 2016 04:09:49 +1100 (AEDT) Received: from localhost ([::1]:60188 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMHjW-0005SE-UY for incoming@patchwork.ozlabs.org; Wed, 28 Dec 2016 12:09:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMHia-0004sn-9y for qemu-devel@nongnu.org; Wed, 28 Dec 2016 12:08:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cMHiX-0001pf-5b for qemu-devel@nongnu.org; Wed, 28 Dec 2016 12:08:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58310) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cMHiW-0001pS-W5 for qemu-devel@nongnu.org; Wed, 28 Dec 2016 12:08:45 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0AAAD3B70B; Wed, 28 Dec 2016 17:08:44 +0000 (UTC) Received: from localhost (ovpn-116-29.gru2.redhat.com [10.97.116.29]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBSH8glB011041; Wed, 28 Dec 2016 12:08:43 -0500 Date: Wed, 28 Dec 2016 15:08:42 -0200 From: Eduardo Habkost To: Igor Mammedov Message-ID: <20161228170842.GB23551@thinpad.lan.raisama.net> References: <1479466974-249781-1-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1479466974-249781-1-git-send-email-imammedo@redhat.com> X-Fnord: you can see the fnord User-Agent: Mutt/1.7.1 (2016-10-04) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 28 Dec 2016 17:08:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: Re: [Qemu-devel] [PATCH for-2.9] numa: make -numa parser dynamically allocate CPUs masks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Paolo Bonzini , Greg Kurz , qemu-devel@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" On Fri, Nov 18, 2016 at 12:02:54PM +0100, 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 Reviewed-by: Eduardo Habkost As the cpu_index assignment code isn't obviously safe against setting cpu_index > max_cpus, I would like to squash this into the patch. Is that OK for you? diff --git a/numa.c b/numa.c index 1b6fa78..33f2fd4 100644 --- a/numa.c +++ b/numa.c @@ -401,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; } @@ -559,6 +560,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;