perf target: Add cpu flag to sample_type if target has cpu
authorNamhyung Kim <[email protected]>
Mon, 21 May 2012 01:42:07 +0000 (10:42 +0900)
committerArnaldo Carvalho de Melo <[email protected]>
Tue, 22 May 2012 15:37:12 +0000 (12:37 -0300)
Add PERF_SAMPLE_CPU flag into attr->sample_type if an user specified any
of cpu target (either system-wide or cpu list).

It will show correct values when cpu sort key is given for perf top and
perf report.

Signed-off-by: Namhyung Kim <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/builtin-top.c
tools/perf/util/evsel.c

index 3e981a710c4d2f9323317d34ae128e2f29a6c826..18bd226f9f2b0cd226a45fd3e75c6465764c605a 100644 (file)
@@ -900,6 +900,9 @@ static void perf_top__start_counters(struct perf_top *top)
                        attr->read_format |= PERF_FORMAT_ID;
                }
 
+               if (perf_target__has_cpu(&top->target))
+                       attr->sample_type |= PERF_SAMPLE_CPU;
+
                if (symbol_conf.use_callchain)
                        attr->sample_type |= PERF_SAMPLE_CALLCHAIN;
 
index f4f427ce4d641446747bfa196c333020ef22644f..9abd8ac508e2c2ccd67986635eed9301f537db5e 100644 (file)
@@ -108,7 +108,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts,
        if (opts->call_graph)
                attr->sample_type       |= PERF_SAMPLE_CALLCHAIN;
 
-       if (opts->target.system_wide)
+       if (perf_target__has_cpu(&opts->target))
                attr->sample_type       |= PERF_SAMPLE_CPU;
 
        if (opts->period)