Re: [PATCH v2 2/3] perf: make build_cpu_topology skip offline/absent CPUs
From: Jan Stancek
Date: Wed Feb 15 2017 - 03:49:03 EST
----- Original Message -----
> From: "Jiri Olsa" <jolsa@xxxxxxxxxx>
> To: "Jan Stancek" <jstancek@xxxxxxxxxx>
> Cc: linux-kernel@xxxxxxxxxxxxxxx, peterz@xxxxxxxxxxxxx, mingo@xxxxxxxxxx, acme@xxxxxxxxxx, "alexander shishkin"
> <alexander.shishkin@xxxxxxxxxxxxxxx>, jolsa@xxxxxxxxxx, mhiramat@xxxxxxxxxx
> Sent: Tuesday, 14 February, 2017 12:01:10 PM
> Subject: Re: [PATCH v2 2/3] perf: make build_cpu_topology skip offline/absent CPUs
>
> On Mon, Feb 13, 2017 at 04:34:35PM +0100, Jan Stancek wrote:
>
> SNIP
>
> > This patch makes build_cpu_topology() skip offline/absent CPUs,
> > by checking their presence against cpu_map built from online CPUs.
> >
> > Signed-off-by: Jan Stancek <jstancek@xxxxxxxxxx>
> > ---
> > tools/perf/util/header.c | 21 +++++++++++++++++----
> > 1 file changed, 17 insertions(+), 4 deletions(-)
> >
> > Changes in v2:
> > - drop out label, use return NULL where possible
> >
> > diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> > index d89c9c7ef4e5..4b0ea4e92e9d 100644
> > --- a/tools/perf/util/header.c
> > +++ b/tools/perf/util/header.c
> > @@ -503,24 +503,31 @@ static void free_cpu_topo(struct cpu_topo *tp)
> >
> > static struct cpu_topo *build_cpu_topology(void)
> > {
> > - struct cpu_topo *tp;
> > + struct cpu_topo *tp = NULL;
> > void *addr;
> > u32 nr, i;
> > size_t sz;
> > long ncpus;
> > - int ret = -1;
> > + int ret = 0;
>
> hum, shoudn't we fail if we dont find any online cpu?
>
> jirka
You're right, there's no reason to change this. I'll send v3.