Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1304853
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 28/59] perf cpumap: Fix cpu conversion in cpu_map__from_entries |
| Date | 2016-01-08 19:30 +0100 |
| Message-ID | <qOJXs-29h-7@gated-at.bofh.it> (permalink) |
| References | <qOJE5-21e-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Jiri Olsa <jolsa@kernel.org>
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 a0717b93d8f5..fa935093a599 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;
--
2.1.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[GIT PULL 00/59] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 24/59] perf script: Process stat config event Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 40/59] tools lib: Sync tools/lib/find_bit.c with the kernel Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 49/59] perf tools: Add overhead/overhead_children keys defaults via string Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 39/59] tools lib: Move find_next_bit.c to tools/lib/ Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 42/59] perf top: Decay periods in callchains Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 15/59] tools build feature: Fix feature_check_display_code typo Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 23/59] perf script: Process cpu/threads maps Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 43/59] perf report: Change default to use event group view Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 05/59] perf tools: Pass evlist to setup_sorting() Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 10/59] perf tools: Support shortcuts for events in dynamic sort keys Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 13/59] perf tools: Add 'trace_fields' dynamic sort key Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 59/59] perf evlist: Add --trace-fields option to show trace fields Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 52/59] perf report: Show random usage tip on the help line Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 48/59] perf tools: Remove list entry from struct sort_entry Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 14/59] perf tools: Make 'trace' or 'trace_fields' sort key default for tracepoint events Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 25/59] perf script: Add process_stat/process_stat_interval scripting interface Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 41/59] tools lib: Move bitmap.[ch] from tools/perf/ to tools/{lib,include}/ Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 02/59] perf hist: Save raw_data/size for tracepoint events Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 08/59] perf tools: Add 'trace' sort key Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 09/59] perf report/top: Add --raw-trace option Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 45/59] perf tools: Add missing headers in perf's MANIFEST Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:10 +0100
[PATCH 57/59] perf libdw: Check for mmaps also in MAP__VARIABLE tree Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 56/59] perf unwind: Check for mmaps also in MAP__VARIABLE tree Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 53/59] perf evlist: Make perf_evlist__open() open evsels with their cpus and threads (like perf record does) Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 58/59] perf record: Store data mmaps for dwarf unwind Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 47/59] perf tools: Include all tools/lib directory for tags/cscope/TAGS targets Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 54/59] perf evlist: Remove perf_evlist__(enable|disable)_event functions Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 51/59] perf hists: Export a couple of hist functions Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 12/59] perf tools: Skip dynamic fields not defined for current event Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 03/59] tools lib traceevent: Factor out and export print_event_field[s]() Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 38/59] perf tests: Give a bit more information on the CQM test failure path Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 37/59] perf tests: No need to set attr.sample_freq for tracking !PERF_RECORD_SAMPLE Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 11/59] perf tools: Support '<event>.*' dynamic sort key Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 04/59] perf top: Create the evlist sooner Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 46/59] perf script: Align event name properly Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 50/59] perf diff: Use perf_hpp__register_sort_field interface Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 18/59] tools build feature: Use value assignment form for FEATURE-DUMP file Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 35/59] perf test: No need for setting attr.sample_freq on the RECORD test Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 33/59] perf evlist: Introduce perf_evlist__new_dummy constructor Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 36/59] perf python: Add missing files to binding link list Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 55/59] perf unwind: Use find_map function in access_dso_mem Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:20 +0100
[PATCH 19/59] perf build: Use FEATURE-DUMP in bpf subproject Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 28/59] perf cpumap: Fix cpu conversion in cpu_map__from_entries Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 29/59] perf script: Display stat events by default Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 07/59] perf tools: Try to show pretty printed output for dynamic sort keys Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 16/59] tools build feature: Move dwarf post unwind choice output into perf Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 20/59] perf tools: Add all matching dynamic sort keys for field name Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 26/59] perf script: Add stat default handlers Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 44/59] perf tools: Do not show trace command if it's not compiled in Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 27/59] perf script: Add python support for stat events Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 21/59] perf report: Add documentation for dynamic sort keys Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 30/59] perf script: Add stat-cpi.py script Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 34/59] perf test: Use "dummy" events in the PERF_RECORD_ test Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 17/59] tools build feature: Introduce feature_assign macro Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 31/59] perf pmu: fix alias->snapshot missing initialization bug Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 32/59] perf tests: No need to set attr.sample_freq in the perf time to TSC test Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 01/59] perf hist: Pass struct sample to __hists__add_entry() Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 06/59] perf tools: Add dynamic sort key for tracepoint events Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
[PATCH 22/59] perf stat record: Keep sample_type 0 for pipe session Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-08 19:30 +0100
Re: [GIT PULL 00/59] perf/core improvements and fixes Ingo Molnar <mingo@kernel.org> - 2016-01-09 17:30 +0100
csiph-web