Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1545304
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 03/29] perf sched timehist: Introduce struct idle_time_data |
| Date | 2016-12-20 18:20 +0100 |
| Message-ID | <sQwf0-8sT-33@gated-at.bofh.it> (permalink) |
| References | <sQw5j-8nS-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Namhyung Kim <namhyung@kernel.org>
The struct idle_time_data is to keep idle stats with callchains entering
to the idle task. The normal thread_runtime calculation is done
transparently since it extends the struct thread_runtime.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: David Ahern <dsahern@gmail.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20161208144755.16673-3-namhyung@kernel.org
[ Align struct field names ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-sched.c | 37 +++++++++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 966eddce1609..e108b0f6a246 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -230,6 +230,15 @@ struct evsel_runtime {
u32 ncpu; /* highest cpu slot allocated */
};
+/* per cpu idle time data */
+struct idle_thread_runtime {
+ struct thread_runtime tr;
+ struct thread *last_thread;
+ struct rb_root sorted_root;
+ struct callchain_root callchain;
+ struct callchain_cursor cursor;
+};
+
/* track idle times per cpu */
static struct thread **idle_threads;
static int idle_max_cpu;
@@ -1997,13 +2006,31 @@ static void save_task_callchain(struct perf_sched *sched,
}
}
+static int init_idle_thread(struct thread *thread)
+{
+ struct idle_thread_runtime *itr;
+
+ thread__set_comm(thread, idle_comm, 0);
+
+ itr = zalloc(sizeof(*itr));
+ if (itr == NULL)
+ return -ENOMEM;
+
+ init_stats(&itr->tr.run_stats);
+ callchain_init(&itr->callchain);
+ callchain_cursor_reset(&itr->cursor);
+ thread__set_priv(thread, itr);
+
+ return 0;
+}
+
/*
* Track idle stats per cpu by maintaining a local thread
* struct for the idle task on each cpu.
*/
static int init_idle_threads(int ncpu)
{
- int i;
+ int i, ret;
idle_threads = zalloc(ncpu * sizeof(struct thread *));
if (!idle_threads)
@@ -2017,7 +2044,9 @@ static int init_idle_threads(int ncpu)
if (idle_threads[i] == NULL)
return -ENOMEM;
- thread__set_comm(idle_threads[i], idle_comm, 0);
+ ret = init_idle_thread(idle_threads[i]);
+ if (ret < 0)
+ return ret;
}
return 0;
@@ -2064,8 +2093,8 @@ static struct thread *get_idle_thread(int cpu)
idle_threads[cpu] = thread__new(0, 0);
if (idle_threads[cpu]) {
- idle_threads[cpu]->tid = 0;
- thread__set_comm(idle_threads[cpu], idle_comm, 0);
+ if (init_idle_thread(idle_threads[cpu]) < 0)
+ return NULL;
}
}
--
2.9.3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-20 18:10 +0100 [PATCH 13/29] perf record: Force ignore_missing_thread for uid option Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-20 18:20 +0100 [PATCH 06/29] perf sched timehist: Add -I/--idle-hist option Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-20 18:20 +0100 [PATCH 21/29] perf trace: Check if MAP_32BIT is defined (again) Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-20 18:20 +0100 [PATCH 05/29] perf sched timehist: Skip non-idle events when necessary Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-20 18:20 +0100 [PATCH 07/29] perf sched timehist: Show callchains for idle stat Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-20 18:20 +0100 [PATCH 09/29] perf mem: Fix --all-user/--all-kernel options Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-20 18:20 +0100 [PATCH 03/29] perf sched timehist: Introduce struct idle_time_data Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-20 18:20 +0100 [PATCH 08/29] perf tools: Remove some needless __maybe_unused Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-20 18:20 +0100 [PATCH 20/29] samples/bpf: Make perf_event_read() static Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-20 18:20 +0100 [PATCH 10/29] perf evsel: Use variable instead of repeating lengthy FD macro Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-20 18:20 +0100 Re: [GIT PULL 00/29] perf/core improvements and fixes Ingo Molnar <mingo@kernel.org> - 2016-12-20 20:20 +0100
csiph-web