Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1580478
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2 2/3] perf: make build_cpu_topology skip offline/absent CPUs |
| Date | 2017-02-14 12:10 +0100 |
| Message-ID | <taJ9D-186-9@gated-at.bofh.it> (permalink) |
| References | <taqTn-5xK-17@gated-at.bofh.it> <taqTq-5xK-75@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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@redhat.com>
> ---
> 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
> + struct cpu_map *map;
>
> ncpus = sysconf(_SC_NPROCESSORS_CONF);
> if (ncpus < 0)
> return NULL;
>
> + /* build online CPU map */
> + map = cpu_map__new(NULL);
> + if (map == NULL) {
> + pr_debug("failed to get system cpumap\n");
> + return NULL;
> + }
> +
> nr = (u32)(ncpus & UINT_MAX);
>
> sz = nr * sizeof(char *);
> -
> addr = calloc(1, sizeof(*tp) + 2 * sz);
> if (!addr)
> - return NULL;
> + goto out_free;
>
> tp = addr;
> tp->cpu_nr = nr;
> @@ -530,10 +537,16 @@ static struct cpu_topo *build_cpu_topology(void)
> tp->thread_siblings = addr;
>
> for (i = 0; i < nr; i++) {
> + if (!cpu_map__has(map, i))
> + continue;
> +
> ret = build_cpu_topo(tp, i);
> if (ret < 0)
> break;
> }
> +
> +out_free:
> + cpu_map__put(map);
> if (ret) {
> free_cpu_topo(tp);
> tp = NULL;
> --
> 1.8.3.1
>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH] perf: fix topology test on systems with sparse CPUs Jiri Olsa <jolsa@redhat.com> - 2017-01-30 19:50 +0100
Re: [PATCH] perf: fix topology test on systems with sparse CPUs Jan Stancek <jstancek@redhat.com> - 2017-01-30 20:30 +0100
Re: [PATCH] perf: fix topology test on systems with sparse CPUs Jan Stancek <jstancek@redhat.com> - 2017-01-31 17:10 +0100
Re: [PATCH] perf: fix topology test on systems with sparse CPUs Jiri Olsa <jolsa@redhat.com> - 2017-02-02 12:30 +0100
Re: [PATCH] perf: fix topology test on systems with sparse CPUs Jan Stancek <jstancek@redhat.com> - 2017-02-02 13:10 +0100
Re: [PATCH] perf: fix topology test on systems with sparse CPUs Jiri Olsa <jolsa@redhat.com> - 2017-02-02 14:10 +0100
[PATCH v2 1/3] perf: add cpu__max_present_cpu() Jan Stancek <jstancek@redhat.com> - 2017-02-13 16:40 +0100
[PATCH v2 2/3] perf: make build_cpu_topology skip offline/absent CPUs Jan Stancek <jstancek@redhat.com> - 2017-02-13 16:40 +0100
Re: [PATCH v2 2/3] perf: make build_cpu_topology skip offline/absent CPUs Jiri Olsa <jolsa@redhat.com> - 2017-02-14 12:10 +0100
Re: [PATCH v2 2/3] perf: make build_cpu_topology skip offline/absent CPUs Jan Stancek <jstancek@redhat.com> - 2017-02-15 09:50 +0100
[PATCH v3 1/3] perf: add cpu__max_present_cpu() Jan Stancek <jstancek@redhat.com> - 2017-02-17 12:20 +0100
[PATCH v3 2/3] perf: make build_cpu_topology skip offline/absent CPUs Jan Stancek <jstancek@redhat.com> - 2017-02-17 12:20 +0100
Re: [PATCH v3 2/3] perf: make build_cpu_topology skip offline/absent CPUs Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-17 16:40 +0100
[tip:perf/urgent] perf header: Make build_cpu_topology skip offline/absent CPUs tip-bot for Jan Stancek <tipbot@zytor.com> - 2017-02-21 09:20 +0100
[PATCH v3 3/3] perf: replace _SC_NPROCESSORS_CONF with max_present_cpu in cpu_topology_map Jan Stancek <jstancek@redhat.com> - 2017-02-17 12:20 +0100
Re: [PATCH v3 3/3] perf: replace _SC_NPROCESSORS_CONF with max_present_cpu in cpu_topology_map Jiri Olsa <jolsa@redhat.com> - 2017-02-17 16:10 +0100
[tip:perf/urgent] perf tools: Replace _SC_NPROCESSORS_CONF with max_present_cpu in cpu_topology_map tip-bot for Jan Stancek <tipbot@zytor.com> - 2017-02-21 09:20 +0100
[tip:perf/urgent] perf cpumap: Add cpu__max_present_cpu() tip-bot for Jan Stancek <tipbot@zytor.com> - 2017-02-21 09:20 +0100
Re: [PATCH v2 1/3] perf: add cpu__max_present_cpu() Jiri Olsa <jolsa@redhat.com> - 2017-02-14 12:20 +0100
Re: [PATCH] perf: fix topology test on systems with sparse CPUs Jiri Olsa <jolsa@redhat.com> - 2017-02-02 12:40 +0100
csiph-web