public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>, lkml <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Michael Petlan <mpetlan@redhat.com>,
	Joe Mario <jmario@redhat.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Andi Kleen <ak@linux.intel.com>
Subject: Re: [PATCH 2/3] perf tools: Add perf_env__numa_node function
Date: Mon, 2 Sep 2019 16:16:47 +0200	[thread overview]
Message-ID: <20190902141647.GC19702@krava> (raw)
In-Reply-To: <20190902135710.GB8396@kernel.org>

On Mon, Sep 02, 2019 at 10:57:10AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Sep 02, 2019 at 02:12:54PM +0200, Jiri Olsa escreveu:
> > To speed up cpu to node lookup, adding perf_env__numa_node
> > function, that creates cpu array on the first lookup, that
> > holds numa nodes for each stored cpu.
> > 
> > Link: http://lkml.kernel.org/n/tip-qqwxklhissf3yjyuaszh6480@git.kernel.org
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  tools/perf/util/env.c | 35 +++++++++++++++++++++++++++++++++++
> >  tools/perf/util/env.h |  6 ++++++
> >  2 files changed, 41 insertions(+)
> > 
> > diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
> > index 3baca06786fb..6385961e45df 100644
> > --- a/tools/perf/util/env.c
> > +++ b/tools/perf/util/env.c
> > @@ -179,6 +179,7 @@ void perf_env__exit(struct perf_env *env)
> >  	zfree(&env->sibling_threads);
> >  	zfree(&env->pmu_mappings);
> >  	zfree(&env->cpu);
> > +	zfree(&env->numa_map);
> >  
> >  	for (i = 0; i < env->nr_numa_nodes; i++)
> >  		perf_cpu_map__put(env->numa_nodes[i].map);
> > @@ -338,3 +339,37 @@ const char *perf_env__arch(struct perf_env *env)
> >  
> >  	return normalize_arch(arch_name);
> >  }
> > +
> > +
> > +int perf_env__numa_node(struct perf_env *env, int cpu)
> > +{
> > +	if (!env->nr_numa_map) {
> > +		struct numa_node *nn;
> > +		int i, nr = 0;
> > +
> > +		for (i = 0; i < env->nr_numa_nodes; i++) {
> > +			nn = &env->numa_nodes[i];
> > +			nr = max(nr, perf_cpu_map__max(nn->map));
> > +		}
> > +
> > +		nr++;
> > +		env->numa_map = zalloc(nr * sizeof(int));
> 
> Why do you use zalloc()...
> 
> > +		if (!env->numa_map)
> > +			return -1;
> 
> Only to right after allocating it set all entries to -1?
> 
> That zalloc() should be downgraded to a plain malloc(), right?
> 
> The setting to -1 is because we may have holes in the array, right? I
> think this deserves a comment here as well.

yea, I added that later on and missed the zalloc above ;-)

I'll send new version

thanks,
jirka

  reply	other threads:[~2019-09-02 14:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-02 12:12 [PATCH 0/3] perf stat: Add --per-numa option Jiri Olsa
2019-09-02 12:12 ` [PATCH 1/3] libperf: Add perf_cpu_map__max function Jiri Olsa
2019-09-02 13:57   ` Arnaldo Carvalho de Melo
2019-09-20 16:21   ` [tip: perf/urgent] libperf: Adopt perf_cpu_map__max() function tip-bot2 for Jiri Olsa
2019-09-02 12:12 ` [PATCH 2/3] perf tools: Add perf_env__numa_node function Jiri Olsa
2019-09-02 13:57   ` Arnaldo Carvalho de Melo
2019-09-02 14:16     ` Jiri Olsa [this message]
2019-09-02 12:12 ` [PATCH 3/3] perf stat: Add --per-numa agregation support Jiri Olsa
2019-09-02 15:13   ` Alexey Budankov
2019-09-02 15:43     ` Arnaldo Carvalho de Melo
2019-09-02 17:46       ` Jiri Olsa
  -- strict thread matches above, loose matches on Subject: below --
2019-09-04  7:34 [PATCHv2 0/3] perf stat: Add --per-node option Jiri Olsa
2019-09-04  7:34 ` [PATCH 2/3] perf tools: Add perf_env__numa_node function Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190902141647.GC19702@krava \
    --to=jolsa@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jmario@redhat.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mpetlan@redhat.com \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox