Re: [PATCH v3 1/2] perf/bench/numa: Add functions to detect sparse numa nodes

From: Satheesh Rajendran
Date: Tue Nov 14 2017 - 07:48:20 EST


Hi Naveen,Thanks for detailed review, my comments inline.

On Tue, 2017-10-31 at 20:44 +0530, Naveen N. Rao wrote:
> Hi Satheesh,
>
> On 2017/08/21 10:15AM, sathnaga@xxxxxxxxxxxxxxxxxx wrote:
> >
> > From: Satheesh Rajendran <sathnaga@xxxxxxxxxxxxxxxxxx>
> >
> > 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.
> >
> > Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> > Reviewed-by: Srikar Dronamraju <srikar@xxxxxxxxxxxxxxxxxx>
> > Signed-off-by: Satheesh Rajendran <sathnaga@xxxxxxxxxxxxxxxxxx>
> > Signed-off-by: Balamuruhan S <bala24@xxxxxxxxxxxxxxxxxx>
> > ---
> > Âtools/perf/bench/numa.c | 44
> > ++++++++++++++++++++++++++++++++++++++++++++
> > Â1 file changed, 44 insertions(+)
> >
> > diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
> > index 469d65b..2483174 100644
> > --- a/tools/perf/bench/numa.c
> > +++ b/tools/perf/bench/numa.c
> > @@ -215,6 +215,50 @@ static const char * const numa_usage[] = {
> > Â NULL
> > Â};
> >
> > +/*
> > + * To get number of numa nodes present.
> > + */
> > +static int nr_numa_nodes(void)
> > +{
> > + int i, nr_nodes = 0;
> > +
> > + for (i = 0; i < g->p.nr_nodes; i++) {
> > + if (numa_bitmask_isbitset(numa_nodes_ptr, i))
> > + nr_nodes++;
> > + }
> > +
> > + return nr_nodes;
> > +}
> > +
> > +/*Â
> Please run patches through scripts/checkpatch.pl. There is a
> trailingÂ
> whitespace above...
>
Sure
> >
> > + * To check if given numa node is present.
> > + */
> > +static int is_node_present(int node)
> > +{
> > + return numa_bitmask_isbitset(numa_nodes_ptr, node);
> > +}
> > +
> > +/*
> > + * To check given numa node has cpus.
> > + */
> > +static bool node_has_cpus(int node)
> > +{
> > + struct bitmask *cpu = numa_allocate_cpumask();
> > + unsigned int i;
> > +
> > + if (cpu == NULL)
> > + return false; /* lets fall back to nocpus safely
> > */
> > +
> > + if (numa_node_to_cpus(node, cpu) == 0) {
> This can be simplified to:
> if (cpu && !numa_node_to_cpus(node, cpu)) {
>
> >
> > + for (i = 0; i < cpu->size; i++) {
> > + if (numa_bitmask_isbitset(cpu, i))
> > + return true;
> > + }
> > + }
> The indentation on those brackets look to be wrong.
>
Sure
> >
> > +
> > + return false;
> > +}
> > +
> More importantly, you've introduced few functions in this patch, butÂ
> none of those are being used. This is not a useful way to split yourÂ
> patches. In fact, this hurts bisect since trying to build perf with
> justÂ
> this patch applied throws errors.
>
Sure, This can be merged to single patch, will do it in next version.

> You seem to be addressing a few different issues related to perf
> benchÂ
> numa. You might want to split your patch based on the specific
> issue(s)Â
> each change fixes.
>
>
> - Naveen
>
>
Regards,
-Satheesh.
> >
> > Âstatic cpu_set_t bind_to_cpu(int target_cpu)
> > Â{
> > Â cpu_set_t orig_mask, mask;