提交 cf1f4574 编写于 作者: I Ingo Molnar

perf record, top: Implement --freq

Support frequency-based profiling and make it the default.

(Also add a Hz printout in perf top.)

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 f250c030
...@@ -27,6 +27,7 @@ static int fd[MAX_NR_CPUS][MAX_COUNTERS]; ...@@ -27,6 +27,7 @@ static int fd[MAX_NR_CPUS][MAX_COUNTERS];
static int nr_cpus = 0; static int nr_cpus = 0;
static unsigned int page_size; static unsigned int page_size;
static unsigned int mmap_pages = 128; static unsigned int mmap_pages = 128;
static int freq = 0;
static int output; static int output;
static const char *output_name = "perf.data"; static const char *output_name = "perf.data";
static int group = 0; static int group = 0;
...@@ -347,9 +348,10 @@ static void create_counter(int counter, int cpu, pid_t pid) ...@@ -347,9 +348,10 @@ static void create_counter(int counter, int cpu, pid_t pid)
attr.config = event_id[counter]; attr.config = event_id[counter];
attr.sample_period = event_count[counter]; attr.sample_period = event_count[counter];
attr.sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID; attr.sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID;
attr.freq = freq;
attr.mmap = track; attr.mmap = track;
attr.comm = track; attr.comm = track;
attr.inherit = (cpu < 0) && inherit; attr.inherit = (cpu < 0) && inherit;
track = 0; /* only the first counter needs these */ track = 0; /* only the first counter needs these */
...@@ -520,6 +522,8 @@ static const struct option options[] = { ...@@ -520,6 +522,8 @@ static const struct option options[] = {
"output file name"), "output file name"),
OPT_BOOLEAN('i', "inherit", &inherit, OPT_BOOLEAN('i', "inherit", &inherit,
"child tasks inherit counters"), "child tasks inherit counters"),
OPT_INTEGER('F', "freq", &freq,
"profile at this frequency"),
OPT_INTEGER('m', "mmap-pages", &mmap_pages, OPT_INTEGER('m', "mmap-pages", &mmap_pages,
"number of mmap data pages"), "number of mmap data pages"),
OPT_END() OPT_END()
...@@ -540,6 +544,10 @@ int cmd_record(int argc, const char **argv, const char *prefix) ...@@ -540,6 +544,10 @@ int cmd_record(int argc, const char **argv, const char *prefix)
event_id[0] = 0; event_id[0] = 0;
} }
if (freq) {
default_interval = freq;
freq = 1;
}
for (counter = 0; counter < nr_counters; counter++) { for (counter = 0; counter < nr_counters; counter++) {
if (event_count[counter]) if (event_count[counter])
continue; continue;
......
...@@ -74,8 +74,8 @@ static int nr_cpus = 0; ...@@ -74,8 +74,8 @@ static int nr_cpus = 0;
static unsigned int realtime_prio = 0; static unsigned int realtime_prio = 0;
static int group = 0; static int group = 0;
static unsigned int page_size; static unsigned int page_size;
static unsigned int mmap_pages = 16; static unsigned int mmap_pages = 16;
static int freq = 0; static int freq = 0;
static char *sym_filter; static char *sym_filter;
static unsigned long filter_start; static unsigned long filter_start;
...@@ -212,8 +212,13 @@ static void print_sym_table(void) ...@@ -212,8 +212,13 @@ static void print_sym_table(void)
events_per_sec, events_per_sec,
100.0 - (100.0*((events_per_sec-kevents_per_sec)/events_per_sec))); 100.0 - (100.0*((events_per_sec-kevents_per_sec)/events_per_sec)));
if (nr_counters == 1) if (nr_counters == 1) {
printf("%d ", event_count[0]); printf("%d", event_count[0]);
if (freq)
printf("Hz ");
else
printf(" ");
}
for (counter = 0; counter < nr_counters; counter++) { for (counter = 0; counter < nr_counters; counter++) {
if (counter) if (counter)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册