From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, mingo@kernel.org, namhyung@kernel.org,
a.p.zijlstra@chello.nl, acme@kernel.org, dsahern@gmail.com,
kan.liang@intel.com, tglx@linutronix.de,
linux-kernel@vger.kernel.org, jolsa@kernel.org, hpa@zytor.com
Subject: [tip:perf/core] perf cpumap: Fix cpu conversion in cpu_map__from_entries
Date: Sat, 9 Jan 2016 08:31:32 -0800 [thread overview]
Message-ID: <tip-15d2b9956b41ffb5961b897bf61cdc09f722dfbf@git.kernel.org> (raw)
In-Reply-To: <1452077397-31958-2-git-send-email-jolsa@kernel.org>
Commit-ID: 15d2b9956b41ffb5961b897bf61cdc09f722dfbf
Gitweb: http://git.kernel.org/tip/15d2b9956b41ffb5961b897bf61cdc09f722dfbf
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 6 Jan 2016 11:49:55 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 6 Jan 2016 20:11:16 -0300
perf cpumap: Fix cpu conversion in cpu_map__from_entries
We can't convert u16 cpu_map_entries::cpu[x] value directly to int,
because it could hold -1, which would be converted as 65535.
Adding special treatment for -1, which is not real cpu number, to be
converted to (int -1).
Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1452077397-31958-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/cpumap.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index a0717b9..fa93509 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -188,8 +188,17 @@ static struct cpu_map *cpu_map__from_entries(struct cpu_map_entries *cpus)
if (map) {
unsigned i;
- for (i = 0; i < cpus->nr; i++)
- map->map[i] = (int)cpus->cpu[i];
+ for (i = 0; i < cpus->nr; i++) {
+ /*
+ * Special treatment for -1, which is not real cpu number,
+ * and we need to use (int) -1 to initialize map[i],
+ * otherwise it would become 65535.
+ */
+ if (cpus->cpu[i] == (u16) -1)
+ map->map[i] = -1;
+ else
+ map->map[i] = (int) cpus->cpu[i];
+ }
}
return map;
next prev parent reply other threads:[~2016-01-09 16:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-06 10:49 [PATCHv9 0/3] perf stat: Add scripting support Jiri Olsa
2016-01-06 10:49 ` [PATCH 1/3] perf tools: Fix cpu conversion in cpu_map__from_entries Jiri Olsa
2016-01-09 16:31 ` tip-bot for Jiri Olsa [this message]
2016-01-06 10:49 ` [PATCH 2/3] perf script: Display stat events by default Jiri Olsa
2016-01-09 16:31 ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-01-06 10:49 ` [PATCH 3/3] perf script: Add stat-cpi.py script Jiri Olsa
2016-01-09 16:32 ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-01-06 14:18 ` [PATCHv9 0/3] perf stat: Add scripting support Arnaldo Carvalho de Melo
2016-01-06 14:38 ` Jiri Olsa
2016-01-06 15:05 ` Arnaldo Carvalho de Melo
2016-01-06 15:39 ` 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=tip-15d2b9956b41ffb5961b897bf61cdc09f722dfbf@git.kernel.org \
--to=tipbot@zytor.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=dsahern@gmail.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=tglx@linutronix.de \
/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