Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754145AbdHUR3t (ORCPT ); Mon, 21 Aug 2017 13:29:49 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:37776 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753843AbdHUR3r (ORCPT ); Mon, 21 Aug 2017 13:29:47 -0400 Subject: Re: [PATCH 1/2] perf/bench/numa: Add functions to detect sparse numa nodes From: Satheesh Rajendran To: Arnaldo Carvalho de Melo Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, srikar@linux.vnet.ibm.com, bala24@linux.vnet.ibm.com In-Reply-To: <20170810192213.GE3900@kernel.org> References: <1502350129-10489-1-git-send-email-sathnaga@linux.vnet.ibm.com> <20170810192213.GE3900@kernel.org> Content-Type: text/plain; charset="UTF-8" Date: Thu, 17 Aug 2017 18:00:47 +0530 Mime-Version: 1.0 X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 17082117-0004-0000-0000-000012CDB785 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007586; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000223; SDB=6.00905625; UDB=6.00453828; IPR=6.00685828; BA=6.00005545; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016793; XFM=3.00000015; UTC=2017-08-21 17:29:44 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082117-0005-0000-0000-000080CCEB6B Message-Id: <1502973047.9759.11.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-08-21_12:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708210275 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3038 Lines: 105 Thanks Arnaldo for the detailed review :-) Will address them and send across v2. On Thu, 2017-08-10 at 16:22 -0300, Arnaldo Carvalho de Melo wrote: > Em Thu, Aug 10, 2017 at 12:58:49PM +0530, sathnaga@linux.vnet.ibm.com > escreveu: > > > > From: Satheesh Rajendran > > > > Added functions 1) to get a count of all nodes that are exposed to > > userspace. These nodes could be memoryless cpu nodes or cpuless > > memory > > nodes, 2) to check given node is present and 3) to check given > > node has cpus > > > > This information can be used to handle sparse/discontiguous nodes. > > > > Reviewed-by: Srikar Dronamraju > > Signed-off-by: Satheesh Rajendran > > Signed-off-by: Balamuruhan S > > --- > >  tools/perf/bench/numa.c | 35 +++++++++++++++++++++++++++++++++++ > >  1 file changed, 35 insertions(+) > > > > diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c > > index 469d65b..efd7595 100644 > > --- a/tools/perf/bench/numa.c > > +++ b/tools/perf/bench/numa.c > > @@ -215,6 +215,41 @@ static const char * const numa_usage[] = { > >   NULL > >  }; > >   > > +static int nr_numa_nodes(void) > > +{ > > + int node = 0, i; > > + > > +        for (i = 0; i < g->p.nr_nodes; i++) { > > + if (numa_bitmask_isbitset(numa_nodes_ptr, i)) > > + node++; > > + } > > + return node; > Humm, can you rename 'node' to 'nr_nodes'? > Sure, will Change it. > > > > +} > > + > > +static bool is_node_present(int node) > > +{ > > + if (numa_bitmask_isbitset(numa_nodes_ptr, node)) > > + return true; > > + else > > + return false; > > +} > Why four lines instead of just one? Isn't this equivalent: > Sure. > static bool is_node_present(int node) > { > return numa_bitmask_isbitset(numa_nodes_ptr, node); > } > > ? > > > + > > +static bool is_node_hascpu(int node) > Can you rename this function, the name is confusing :-\ > > Based on the documentation for this function, that you left only in > the > changelog (please put it just before the function, as a comment, I > think > it should be named node_has_cpus()? > make sense, will change it. > > > > +{ > > + struct bitmask *cpu; > > + unsigned int i; > > + > > + cpu = numa_allocate_cpumask(); > Please put the line with the initialization together with the > declaration, making it: > > struct bitmask *cpu = numa_allocate_cpumask(); > > Also, this is a "alloc" function, I bet it can fail? If so, check it > and > return something useful if it fails, which probably will be difficult > since this function returns bool? > Sure, will check return false as failsafe. > > > > > + if (numa_node_to_cpus(node, cpu) == 0) { > > + for (i = 0; i < cpu->size; i++) { > > + if (numa_bitmask_isbitset(cpu, i)) > > + return true; > > + } > > + } else > > + return false; // lets fall back to nocpus safely > > + return false; > > +} > > + > >  static cpu_set_t bind_to_cpu(int target_cpu) > >  { > >   cpu_set_t orig_mask, mask;