Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1540886 > unrolled thread
| Started by | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| First post | 2016-12-13 09:10 +0100 |
| Last post | 2016-12-20 20:30 +0100 |
| Articles | 11 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 1/2] perf sched timehist: Fix --idle-hist when no callchains Namhyung Kim <namhyung@kernel.org> - 2016-12-13 09:10 +0100
[PATCH 2/2] perf sched timehist: Fix invalid runtime in the idle hist Namhyung Kim <namhyung@kernel.org> - 2016-12-13 09:10 +0100
Re: [PATCH 2/2] perf sched timehist: Fix invalid runtime in the idle hist Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-13 11:40 +0100
Re: [PATCH 2/2] perf sched timehist: Fix invalid runtime in the idle hist Namhyung Kim <namhyung@kernel.org> - 2016-12-13 12:00 +0100
Re: [PATCH 2/2] perf sched timehist: Fix invalid runtime in the idle hist Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-13 14:20 +0100
[tip:perf/urgent] perf sched timehist: Add -I/--idle-hist option tip-bot for Namhyung Kim <tipbot@zytor.com> - 2016-12-20 20:30 +0100
Re: [PATCH 1/2] perf sched timehist: Fix --idle-hist when no callchains Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-13 11:40 +0100
Re: [PATCH 1/2] perf sched timehist: Fix --idle-hist when no callchains Namhyung Kim <namhyung@kernel.org> - 2016-12-13 12:00 +0100
Re: [PATCH 1/2] perf sched timehist: Fix --idle-hist when no callchains Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-13 13:10 +0100
Re: [PATCH 1/2] perf sched timehist: Fix --idle-hist when no callchains Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-13 14:10 +0100
[tip:perf/urgent] perf sched timehist: Save callchain when entering idle tip-bot for Namhyung Kim <tipbot@zytor.com> - 2016-12-20 20:30 +0100
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2016-12-13 09:10 +0100 |
| Subject | [PATCH 1/2] perf sched timehist: Fix --idle-hist when no callchains |
| Message-ID | <sNQjT-7cA-3@gated-at.bofh.it> |
When idle hist is enabled, the itr->last_thread should be set so that
it can find which thread run before idle task. But it was only set in
the save_idle_callchain(). This makes idle task doesn't show up in
the output when callchain is not recorded.
Before:
$ perf sched timehist --idle-hist
Samples do not have callchains.
time cpu task name wait time sch delay run time
[tid/pid] (msec) (msec) (msec)
--------------- ------ -------------------- --------- --------- ---------
197731.753834 [0001] perf[27469] 0.000 0.000 0.000
197731.753915 [0003] migration/3[23] 0.000 0.000 0.000
197731.754335 [0002] firefox[17773/17739] 0.000 0.000 0.000
197731.754486 [0001] sleep[27470] 0.000 0.000 0.000
197731.754981 [0002] firefox[17773/17739] 0.000 0.000 0.000
197731.755994 [0002] firefox[17773/17739] 0.000 0.000 0.000
...
After:
197731.753834 [0001] perf[27469] 0.000 0.000 0.000
197731.753914 [0001] <idle> 0.000 0.000 0.079
197731.753915 [0003] migration/3[23] 0.000 0.000 0.000
197731.754335 [0002] firefox[17773/17739] 0.000 0.000 0.000
197731.754486 [0001] sleep[27470] 0.000 0.000 0.000
197731.754903 [0002] <idle> 0.047 0.000 0.567
197731.754981 [0002] firefox[17773/17739] 0.000 0.000 0.567
197731.755922 [0002] <idle> 0.078 0.000 0.941
197731.755994 [0002] firefox[17773/17739] 0.000 0.000 0.941
197731.756625 [0003] <idle> 0.123 0.000 2.709
...
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/builtin-sched.c | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 0750e938a656..405a91d0515f 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -2102,26 +2102,12 @@ static struct thread *get_idle_thread(int cpu)
return idle_threads[cpu];
}
-static void save_idle_callchain(struct thread *thread,
+static void save_idle_callchain(struct idle_thread_runtime *itr,
struct perf_sample *sample)
{
- struct thread *idle;
- struct idle_thread_runtime *itr;
-
if (!symbol_conf.use_callchain || sample->callchain == NULL)
return;
- idle = get_idle_thread(sample->cpu);
- if (idle == NULL) {
- pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu);
- return;
- }
-
- itr = thread__priv(idle);
- if (itr == NULL)
- return;
-
- itr->last_thread = thread;
callchain_cursor__copy(&itr->cursor, &callchain_cursor);
}
@@ -2179,9 +2165,24 @@ static struct thread *timehist_get_thread(struct perf_sched *sched,
save_task_callchain(sched, sample, evsel, machine);
if (sched->idle_hist) {
+ struct thread *idle;
+ struct idle_thread_runtime *itr;
+
+ idle = get_idle_thread(sample->cpu);
+ if (idle == NULL) {
+ pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu);
+ return NULL;
+ }
+
+ itr = thread__priv(idle);
+ if (itr == NULL)
+ return NULL;
+
+ itr->last_thread = thread;
+
/* copy task callchain when entering to idle */
if (perf_evsel__intval(evsel, sample, "next_pid") == 0)
- save_idle_callchain(thread, sample);
+ save_idle_callchain(itr, sample);
}
}
--
2.10.2
[toc] | [next] | [standalone]
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2016-12-13 09:10 +0100 |
| Subject | [PATCH 2/2] perf sched timehist: Fix invalid runtime in the idle hist |
| Message-ID | <sNQjU-7cA-17@gated-at.bofh.it> |
| In reply to | #1540886 |
When --idle-hist option is used, run/wait time and sched delay value
should be shown for idle task only. But due to internal accounting, a
last thread has same value of next idle task's and it was shown.
In the below example, firefox after idle task has same run time of
idle task's.
$ perf sched timehist --idle-hist
Samples do not have callchains.
time cpu task name wait time sch delay run time
[tid/pid] (msec) (msec) (msec)
--------------- ------ -------------------- --------- --------- ---------
197731.754335 [0002] firefox[17773/17739] 0.000 0.000 0.000
197731.754486 [0001] sleep[27470] 0.000 0.000 0.000
197731.754903 [0002] <idle> 0.047 0.000 0.567
197731.754981 [0002] firefox[17773/17739] 0.000 0.000 0.567
197731.755922 [0002] <idle> 0.078 0.000 0.941
197731.755994 [0002] firefox[17773/17739] 0.000 0.000 0.941
<SNIP>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/builtin-sched.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 405a91d0515f..64a0959bccd7 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -2439,6 +2439,15 @@ static int timehist_sched_change_event(struct perf_tool *tool,
goto out;
timehist_update_runtime_stats(last_tr, t, tprev);
+ /*
+ * remove delta time of last thread as it's not updated
+ * and otherwise it will show an invalid value next
+ * time. we only care total run time and run stat.
+ */
+ last_tr->dt_run = 0;
+ last_tr->dt_wait = 0;
+ last_tr->dt_delay = 0;
+
if (itr->cursor.nr)
callchain_append(&itr->callchain, &itr->cursor,
t - tprev);
--
2.10.2
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-12-13 11:40 +0100 |
| Subject | Re: [PATCH 2/2] perf sched timehist: Fix invalid runtime in the idle hist |
| Message-ID | <sNSF4-8vJ-7@gated-at.bofh.it> |
| In reply to | #1540888 |
Em Tue, Dec 13, 2016 at 05:06:32PM +0900, Namhyung Kim escreveu: > When --idle-hist option is used, run/wait time and sched delay value > should be shown for idle task only. But due to internal accounting, a > last thread has same value of next idle task's and it was shown. > > In the below example, firefox after idle task has same run time of > idle task's. Same as last message, is this something I can fold into a patch yet in my perf/core branch? - Arnaldo > $ perf sched timehist --idle-hist > Samples do not have callchains. > time cpu task name wait time sch delay run time > [tid/pid] (msec) (msec) (msec) > --------------- ------ -------------------- --------- --------- --------- > 197731.754335 [0002] firefox[17773/17739] 0.000 0.000 0.000 > 197731.754486 [0001] sleep[27470] 0.000 0.000 0.000 > 197731.754903 [0002] <idle> 0.047 0.000 0.567 > 197731.754981 [0002] firefox[17773/17739] 0.000 0.000 0.567 > 197731.755922 [0002] <idle> 0.078 0.000 0.941 > 197731.755994 [0002] firefox[17773/17739] 0.000 0.000 0.941 > <SNIP> > > Signed-off-by: Namhyung Kim <namhyung@kernel.org> > --- > tools/perf/builtin-sched.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c > index 405a91d0515f..64a0959bccd7 100644 > --- a/tools/perf/builtin-sched.c > +++ b/tools/perf/builtin-sched.c > @@ -2439,6 +2439,15 @@ static int timehist_sched_change_event(struct perf_tool *tool, > goto out; > > timehist_update_runtime_stats(last_tr, t, tprev); > + /* > + * remove delta time of last thread as it's not updated > + * and otherwise it will show an invalid value next > + * time. we only care total run time and run stat. > + */ > + last_tr->dt_run = 0; > + last_tr->dt_wait = 0; > + last_tr->dt_delay = 0; > + > if (itr->cursor.nr) > callchain_append(&itr->callchain, &itr->cursor, > t - tprev); > -- > 2.10.2
[toc] | [prev] | [next] | [standalone]
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2016-12-13 12:00 +0100 |
| Subject | Re: [PATCH 2/2] perf sched timehist: Fix invalid runtime in the idle hist |
| Message-ID | <sNSYp-aO-5@gated-at.bofh.it> |
| In reply to | #1540977 |
On Tue, Dec 13, 2016 at 07:32:36AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Dec 13, 2016 at 05:06:32PM +0900, Namhyung Kim escreveu:
> > When --idle-hist option is used, run/wait time and sched delay value
> > should be shown for idle task only. But due to internal accounting, a
> > last thread has same value of next idle task's and it was shown.
> >
> > In the below example, firefox after idle task has same run time of
> > idle task's.
>
> Same as last message, is this something I can fold into a patch yet in
> my perf/core branch?
Yep,
Fixes: 78de3657008b ("perf sched timehist: Add -I/--idle-hist option")
I guess it makes a conflict on the callchain code. In case it doesn't
look obvious to resolve, please let me know..
Thanks,
Namhyung
>
> - Arnaldo
>
> > $ perf sched timehist --idle-hist
> > Samples do not have callchains.
> > time cpu task name wait time sch delay run time
> > [tid/pid] (msec) (msec) (msec)
> > --------------- ------ -------------------- --------- --------- ---------
> > 197731.754335 [0002] firefox[17773/17739] 0.000 0.000 0.000
> > 197731.754486 [0001] sleep[27470] 0.000 0.000 0.000
> > 197731.754903 [0002] <idle> 0.047 0.000 0.567
> > 197731.754981 [0002] firefox[17773/17739] 0.000 0.000 0.567
> > 197731.755922 [0002] <idle> 0.078 0.000 0.941
> > 197731.755994 [0002] firefox[17773/17739] 0.000 0.000 0.941
> > <SNIP>
> >
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> > tools/perf/builtin-sched.c | 9 +++++++++
> > 1 file changed, 9 insertions(+)
> >
> > diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> > index 405a91d0515f..64a0959bccd7 100644
> > --- a/tools/perf/builtin-sched.c
> > +++ b/tools/perf/builtin-sched.c
> > @@ -2439,6 +2439,15 @@ static int timehist_sched_change_event(struct perf_tool *tool,
> > goto out;
> >
> > timehist_update_runtime_stats(last_tr, t, tprev);
> > + /*
> > + * remove delta time of last thread as it's not updated
> > + * and otherwise it will show an invalid value next
> > + * time. we only care total run time and run stat.
> > + */
> > + last_tr->dt_run = 0;
> > + last_tr->dt_wait = 0;
> > + last_tr->dt_delay = 0;
> > +
> > if (itr->cursor.nr)
> > callchain_append(&itr->callchain, &itr->cursor,
> > t - tprev);
> > --
> > 2.10.2
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-12-13 14:20 +0100 |
| Subject | Re: [PATCH 2/2] perf sched timehist: Fix invalid runtime in the idle hist |
| Message-ID | <sNV9U-1DV-31@gated-at.bofh.it> |
| In reply to | #1540982 |
Em Tue, Dec 13, 2016 at 07:54:42PM +0900, Namhyung Kim escreveu:
> On Tue, Dec 13, 2016 at 07:32:36AM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Tue, Dec 13, 2016 at 05:06:32PM +0900, Namhyung Kim escreveu:
> > > When --idle-hist option is used, run/wait time and sched delay value
> > > should be shown for idle task only. But due to internal accounting, a
> > > last thread has same value of next idle task's and it was shown.
> > >
> > > In the below example, firefox after idle task has same run time of
> > > idle task's.
> >
> > Same as last message, is this something I can fold into a patch yet in
> > my perf/core branch?
>
> Yep,
>
> Fixes: 78de3657008b ("perf sched timehist: Add -I/--idle-hist option")
>
> I guess it makes a conflict on the callchain code. In case it doesn't
> look obvious to resolve, please let me know..
Ok, fixed up, after building it, before 'rebase --continue', we get:
time cpu task name wait time sch delay run time
[tid/pid] (msec) (msec) (msec)
--------------- ------ -------------------- --------- --------- ---------
47548.582141 [0000] perf[17869] 0.000 0.000 0.000
47548.583814 [0003] rcu_sched[7] 0.000 0.000 0.000
47548.583825 [0003] <idle> 0.005 0.000 0.010
47548.583826 [0002] rcuos/0[9] 0.000 0.000 0.000
47548.583828 [0003] rcu_sched[7] 0.000 0.000 0.000
47548.587797 [0003] <idle> 0.002 0.000 3.969
47548.587799 [0003] rcu_sched[7] 0.000 0.000 0.000
47548.587799 [0002] <idle> 0.011 0.000 3.973
47548.587808 [0002] rcuos/0[9] 0.000 0.000 0.000
47548.594979 [0002] <idle> 0.008 0.000 7.171
47548.595014 [0002] Timer[4869/4832] 0.000 0.000 0.000
47548.595064 [0001] firefox[4832] 0.000 0.000 0.000
47548.603831 [0002] <idle> 0.034 0.000 8.817
47548.603874 [0001] <idle> 0.054 0.000 8.809
Which matches what you state as being the fix (task runtime after idle task).
git rebase --continue next...
- Arnaldo
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Namhyung Kim <tipbot@zytor.com> |
|---|---|
| Date | 2016-12-20 20:30 +0100 |
| Subject | [tip:perf/urgent] perf sched timehist: Add -I/--idle-hist option |
| Message-ID | <sQygS-1i9-19@gated-at.bofh.it> |
| In reply to | #1540888 |
Commit-ID: 07235f84ece6b66f43334881806aad3467cf3d84
Gitweb: http://git.kernel.org/tip/07235f84ece6b66f43334881806aad3467cf3d84
Author: Namhyung Kim <namhyung@kernel.org>
AuthorDate: Thu, 8 Dec 2016 23:47:54 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 15 Dec 2016 16:25:45 -0300
perf sched timehist: Add -I/--idle-hist option
The --idle-hist option is to analyze system idle state so which process
makes cpu to go idle. If this option is specified, non-idle events will
be skipped and processes switching to/from idle will be shown.
This option is mostly useful when used with --summary(-only) option. In
the idle-time summary view, idle time is accounted to previous thread
which is run before idle task.
The example output looks like following:
Idle-time summary
comm parent sched-out idle-time min-idle avg-idle max-idle stddev migrations
(count) (msec) (msec) (msec) (msec) %
--------------------------------------------------------------------------------------------
rcu_preempt[7] 2 95 550.872 0.011 5.798 23.146 7.63 0
migration/1[16] 2 1 15.558 15.558 15.558 15.558 0.00 0
khugepaged[39] 2 1 3.062 3.062 3.062 3.062 0.00 0
kworker/0:1H[124] 2 2 4.728 0.611 2.364 4.116 74.12 0
systemd-journal[167] 1 1 4.510 4.510 4.510 4.510 0.00 0
kworker/u16:3[558] 2 13 74.737 0.080 5.749 12.960 21.96 0
irq/34-iwlwifi[628] 2 21 118.403 0.032 5.638 23.990 24.00 0
kworker/u17:0[673] 2 1 3.523 3.523 3.523 3.523 0.00 0
dbus-daemon[722] 1 1 6.743 6.743 6.743 6.743 0.00 0
ifplugd[741] 1 1 58.826 58.826 58.826 58.826 0.00 0
wpa_supplicant[1490] 1 1 13.302 13.302 13.302 13.302 0.00 0
wpa_actiond[1492] 1 2 4.064 0.168 2.032 3.896 91.72 0
dockerd[1500] 1 1 0.055 0.055 0.055 0.055 0.00 0
...
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
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-6-namhyung@kernel.org
Link: http://lkml.kernel.org/r/20161213080632.19099-2-namhyung@kernel.org
[ Merged fix sent by Namhyumg, as posted in the second Link: tag ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Documentation/perf-sched.txt | 4 +++
tools/perf/builtin-sched.c | 46 +++++++++++++++++++++++++++++----
2 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/tools/perf/Documentation/perf-sched.txt b/tools/perf/Documentation/perf-sched.txt
index 7775b1e..7617396 100644
--- a/tools/perf/Documentation/perf-sched.txt
+++ b/tools/perf/Documentation/perf-sched.txt
@@ -132,6 +132,10 @@ OPTIONS for 'perf sched timehist'
--migrations::
Show migration events.
+-I::
+--idle-hist::
+ Show idle-related events only.
+
--time::
Only analyze samples within given time window: <start>,<stop>. Times
have the format seconds.microseconds. If start is not given (i.e., time
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index c8e7848..0b14265 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -2421,7 +2421,36 @@ static int timehist_sched_change_event(struct perf_tool *tool,
t = ptime->end;
}
- timehist_update_runtime_stats(tr, t, tprev);
+ if (!sched->idle_hist || thread->tid == 0) {
+ timehist_update_runtime_stats(tr, t, tprev);
+
+ if (sched->idle_hist) {
+ struct idle_thread_runtime *itr = (void *)tr;
+ struct thread_runtime *last_tr;
+
+ BUG_ON(thread->tid != 0);
+
+ if (itr->last_thread == NULL)
+ goto out;
+
+ /* add current idle time as last thread's runtime */
+ last_tr = thread__get_runtime(itr->last_thread);
+ if (last_tr == NULL)
+ goto out;
+
+ timehist_update_runtime_stats(last_tr, t, tprev);
+ /*
+ * remove delta time of last thread as it's not updated
+ * and otherwise it will show an invalid value next
+ * time. we only care total run time and run stat.
+ */
+ last_tr->dt_run = 0;
+ last_tr->dt_wait = 0;
+ last_tr->dt_delay = 0;
+
+ itr->last_thread = NULL;
+ }
+ }
if (!sched->summary_only)
timehist_print_sample(sched, sample, &al, thread, t);
@@ -2543,9 +2572,15 @@ static void timehist_print_summary(struct perf_sched *sched,
if (comm_width < 30)
comm_width = 30;
- printf("\nRuntime summary\n");
- printf("%*s parent sched-in ", comm_width, "comm");
- printf(" run-time min-run avg-run max-run stddev migrations\n");
+ if (sched->idle_hist) {
+ printf("\nIdle-time summary\n");
+ printf("%*s parent sched-out ", comm_width, "comm");
+ printf(" idle-time min-idle avg-idle max-idle stddev migrations\n");
+ } else {
+ printf("\nRuntime summary\n");
+ printf("%*s parent sched-in ", comm_width, "comm");
+ printf(" run-time min-run avg-run max-run stddev migrations\n");
+ }
printf("%*s (count) ", comm_width, "");
printf(" (msec) (msec) (msec) (msec) %%\n");
printf("%.117s\n", graph_dotted_line);
@@ -2561,7 +2596,7 @@ static void timehist_print_summary(struct perf_sched *sched,
printf("<no terminated tasks>\n");
/* CPU idle stats not tracked when samples were skipped */
- if (sched->skipped_samples)
+ if (sched->skipped_samples && !sched->idle_hist)
return;
printf("\nIdle stats:\n");
@@ -3107,6 +3142,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_BOOLEAN('w', "wakeups", &sched.show_wakeups, "Show wakeup events"),
OPT_BOOLEAN('M', "migrations", &sched.show_migrations, "Show migration events"),
OPT_BOOLEAN('V', "cpu-visual", &sched.show_cpu_visual, "Add CPU visual"),
+ OPT_BOOLEAN('I', "idle-hist", &sched.idle_hist, "Show idle events only"),
OPT_STRING(0, "time", &sched.time_str, "str",
"Time span for analysis (start,stop)"),
OPT_PARENT(sched_options)
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-12-13 11:40 +0100 |
| Subject | Re: [PATCH 1/2] perf sched timehist: Fix --idle-hist when no callchains |
| Message-ID | <sNSF4-8vJ-9@gated-at.bofh.it> |
| In reply to | #1540886 |
Em Tue, Dec 13, 2016 at 05:06:31PM +0900, Namhyung Kim escreveu:
> When idle hist is enabled, the itr->last_thread should be set so that
> it can find which thread run before idle task. But it was only set in
> the save_idle_callchain(). This makes idle task doesn't show up in
> the output when callchain is not recorded.
It is important to provide a Fixes: tag so that I can check if the
problem was introduced by some patch still not sent to Ingo, in which
case I could try and merge them, is this the case here?
- Arnaldo
> Before:
>
> $ perf sched timehist --idle-hist
> Samples do not have callchains.
> time cpu task name wait time sch delay run time
> [tid/pid] (msec) (msec) (msec)
> --------------- ------ -------------------- --------- --------- ---------
> 197731.753834 [0001] perf[27469] 0.000 0.000 0.000
> 197731.753915 [0003] migration/3[23] 0.000 0.000 0.000
> 197731.754335 [0002] firefox[17773/17739] 0.000 0.000 0.000
> 197731.754486 [0001] sleep[27470] 0.000 0.000 0.000
> 197731.754981 [0002] firefox[17773/17739] 0.000 0.000 0.000
> 197731.755994 [0002] firefox[17773/17739] 0.000 0.000 0.000
> ...
>
> After:
>
> 197731.753834 [0001] perf[27469] 0.000 0.000 0.000
> 197731.753914 [0001] <idle> 0.000 0.000 0.079
> 197731.753915 [0003] migration/3[23] 0.000 0.000 0.000
> 197731.754335 [0002] firefox[17773/17739] 0.000 0.000 0.000
> 197731.754486 [0001] sleep[27470] 0.000 0.000 0.000
> 197731.754903 [0002] <idle> 0.047 0.000 0.567
> 197731.754981 [0002] firefox[17773/17739] 0.000 0.000 0.567
> 197731.755922 [0002] <idle> 0.078 0.000 0.941
> 197731.755994 [0002] firefox[17773/17739] 0.000 0.000 0.941
> 197731.756625 [0003] <idle> 0.123 0.000 2.709
> ...
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/builtin-sched.c | 33 +++++++++++++++++----------------
> 1 file changed, 17 insertions(+), 16 deletions(-)
>
> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index 0750e938a656..405a91d0515f 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -2102,26 +2102,12 @@ static struct thread *get_idle_thread(int cpu)
> return idle_threads[cpu];
> }
>
> -static void save_idle_callchain(struct thread *thread,
> +static void save_idle_callchain(struct idle_thread_runtime *itr,
> struct perf_sample *sample)
> {
> - struct thread *idle;
> - struct idle_thread_runtime *itr;
> -
> if (!symbol_conf.use_callchain || sample->callchain == NULL)
> return;
>
> - idle = get_idle_thread(sample->cpu);
> - if (idle == NULL) {
> - pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu);
> - return;
> - }
> -
> - itr = thread__priv(idle);
> - if (itr == NULL)
> - return;
> -
> - itr->last_thread = thread;
> callchain_cursor__copy(&itr->cursor, &callchain_cursor);
> }
>
> @@ -2179,9 +2165,24 @@ static struct thread *timehist_get_thread(struct perf_sched *sched,
>
> save_task_callchain(sched, sample, evsel, machine);
> if (sched->idle_hist) {
> + struct thread *idle;
> + struct idle_thread_runtime *itr;
> +
> + idle = get_idle_thread(sample->cpu);
> + if (idle == NULL) {
> + pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu);
> + return NULL;
> + }
> +
> + itr = thread__priv(idle);
> + if (itr == NULL)
> + return NULL;
> +
> + itr->last_thread = thread;
> +
> /* copy task callchain when entering to idle */
> if (perf_evsel__intval(evsel, sample, "next_pid") == 0)
> - save_idle_callchain(thread, sample);
> + save_idle_callchain(itr, sample);
> }
> }
>
> --
> 2.10.2
[toc] | [prev] | [next] | [standalone]
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2016-12-13 12:00 +0100 |
| Subject | Re: [PATCH 1/2] perf sched timehist: Fix --idle-hist when no callchains |
| Message-ID | <sNSYq-aO-19@gated-at.bofh.it> |
| In reply to | #1540978 |
Hi Arnaldo,
On Tue, Dec 13, 2016 at 07:32:02AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Dec 13, 2016 at 05:06:31PM +0900, Namhyung Kim escreveu:
> > When idle hist is enabled, the itr->last_thread should be set so that
> > it can find which thread run before idle task. But it was only set in
> > the save_idle_callchain(). This makes idle task doesn't show up in
> > the output when callchain is not recorded.
>
> It is important to provide a Fixes: tag so that I can check if the
> problem was introduced by some patch still not sent to Ingo, in which
> case I could try and merge them, is this the case here?
Yes,
Fixes: b50c3ab0f1cc ("perf sched timehist: Save callchain when entering idle")
Thanks,
Namhyung
>
> > Before:
> >
> > $ perf sched timehist --idle-hist
> > Samples do not have callchains.
> > time cpu task name wait time sch delay run time
> > [tid/pid] (msec) (msec) (msec)
> > --------------- ------ -------------------- --------- --------- ---------
> > 197731.753834 [0001] perf[27469] 0.000 0.000 0.000
> > 197731.753915 [0003] migration/3[23] 0.000 0.000 0.000
> > 197731.754335 [0002] firefox[17773/17739] 0.000 0.000 0.000
> > 197731.754486 [0001] sleep[27470] 0.000 0.000 0.000
> > 197731.754981 [0002] firefox[17773/17739] 0.000 0.000 0.000
> > 197731.755994 [0002] firefox[17773/17739] 0.000 0.000 0.000
> > ...
> >
> > After:
> >
> > 197731.753834 [0001] perf[27469] 0.000 0.000 0.000
> > 197731.753914 [0001] <idle> 0.000 0.000 0.079
> > 197731.753915 [0003] migration/3[23] 0.000 0.000 0.000
> > 197731.754335 [0002] firefox[17773/17739] 0.000 0.000 0.000
> > 197731.754486 [0001] sleep[27470] 0.000 0.000 0.000
> > 197731.754903 [0002] <idle> 0.047 0.000 0.567
> > 197731.754981 [0002] firefox[17773/17739] 0.000 0.000 0.567
> > 197731.755922 [0002] <idle> 0.078 0.000 0.941
> > 197731.755994 [0002] firefox[17773/17739] 0.000 0.000 0.941
> > 197731.756625 [0003] <idle> 0.123 0.000 2.709
> > ...
> >
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> > tools/perf/builtin-sched.c | 33 +++++++++++++++++----------------
> > 1 file changed, 17 insertions(+), 16 deletions(-)
> >
> > diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> > index 0750e938a656..405a91d0515f 100644
> > --- a/tools/perf/builtin-sched.c
> > +++ b/tools/perf/builtin-sched.c
> > @@ -2102,26 +2102,12 @@ static struct thread *get_idle_thread(int cpu)
> > return idle_threads[cpu];
> > }
> >
> > -static void save_idle_callchain(struct thread *thread,
> > +static void save_idle_callchain(struct idle_thread_runtime *itr,
> > struct perf_sample *sample)
> > {
> > - struct thread *idle;
> > - struct idle_thread_runtime *itr;
> > -
> > if (!symbol_conf.use_callchain || sample->callchain == NULL)
> > return;
> >
> > - idle = get_idle_thread(sample->cpu);
> > - if (idle == NULL) {
> > - pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu);
> > - return;
> > - }
> > -
> > - itr = thread__priv(idle);
> > - if (itr == NULL)
> > - return;
> > -
> > - itr->last_thread = thread;
> > callchain_cursor__copy(&itr->cursor, &callchain_cursor);
> > }
> >
> > @@ -2179,9 +2165,24 @@ static struct thread *timehist_get_thread(struct perf_sched *sched,
> >
> > save_task_callchain(sched, sample, evsel, machine);
> > if (sched->idle_hist) {
> > + struct thread *idle;
> > + struct idle_thread_runtime *itr;
> > +
> > + idle = get_idle_thread(sample->cpu);
> > + if (idle == NULL) {
> > + pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu);
> > + return NULL;
> > + }
> > +
> > + itr = thread__priv(idle);
> > + if (itr == NULL)
> > + return NULL;
> > +
> > + itr->last_thread = thread;
> > +
> > /* copy task callchain when entering to idle */
> > if (perf_evsel__intval(evsel, sample, "next_pid") == 0)
> > - save_idle_callchain(thread, sample);
> > + save_idle_callchain(itr, sample);
> > }
> > }
> >
> > --
> > 2.10.2
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-12-13 13:10 +0100 |
| Subject | Re: [PATCH 1/2] perf sched timehist: Fix --idle-hist when no callchains |
| Message-ID | <sNU49-11F-29@gated-at.bofh.it> |
| In reply to | #1540986 |
Em Tue, Dec 13, 2016 at 07:49:44PM +0900, Namhyung Kim escreveu:
> Hi Arnaldo,
>
> On Tue, Dec 13, 2016 at 07:32:02AM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Tue, Dec 13, 2016 at 05:06:31PM +0900, Namhyung Kim escreveu:
> > > When idle hist is enabled, the itr->last_thread should be set so that
> > > it can find which thread run before idle task. But it was only set in
> > > the save_idle_callchain(). This makes idle task doesn't show up in
> > > the output when callchain is not recorded.
> >
> > It is important to provide a Fixes: tag so that I can check if the
> > problem was introduced by some patch still not sent to Ingo, in which
> > case I could try and merge them, is this the case here?
>
> Yes,
>
> Fixes: b50c3ab0f1cc ("perf sched timehist: Save callchain when entering idle")
Thanks, will try and merge this and the other one so that we remove
those as bisection problems when looking for problems in this area.
- Arnaldo
> Thanks,
> Namhyung
>
>
> >
> > > Before:
> > >
> > > $ perf sched timehist --idle-hist
> > > Samples do not have callchains.
> > > time cpu task name wait time sch delay run time
> > > [tid/pid] (msec) (msec) (msec)
> > > --------------- ------ -------------------- --------- --------- ---------
> > > 197731.753834 [0001] perf[27469] 0.000 0.000 0.000
> > > 197731.753915 [0003] migration/3[23] 0.000 0.000 0.000
> > > 197731.754335 [0002] firefox[17773/17739] 0.000 0.000 0.000
> > > 197731.754486 [0001] sleep[27470] 0.000 0.000 0.000
> > > 197731.754981 [0002] firefox[17773/17739] 0.000 0.000 0.000
> > > 197731.755994 [0002] firefox[17773/17739] 0.000 0.000 0.000
> > > ...
> > >
> > > After:
> > >
> > > 197731.753834 [0001] perf[27469] 0.000 0.000 0.000
> > > 197731.753914 [0001] <idle> 0.000 0.000 0.079
> > > 197731.753915 [0003] migration/3[23] 0.000 0.000 0.000
> > > 197731.754335 [0002] firefox[17773/17739] 0.000 0.000 0.000
> > > 197731.754486 [0001] sleep[27470] 0.000 0.000 0.000
> > > 197731.754903 [0002] <idle> 0.047 0.000 0.567
> > > 197731.754981 [0002] firefox[17773/17739] 0.000 0.000 0.567
> > > 197731.755922 [0002] <idle> 0.078 0.000 0.941
> > > 197731.755994 [0002] firefox[17773/17739] 0.000 0.000 0.941
> > > 197731.756625 [0003] <idle> 0.123 0.000 2.709
> > > ...
> > >
> > > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > > ---
> > > tools/perf/builtin-sched.c | 33 +++++++++++++++++----------------
> > > 1 file changed, 17 insertions(+), 16 deletions(-)
> > >
> > > diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> > > index 0750e938a656..405a91d0515f 100644
> > > --- a/tools/perf/builtin-sched.c
> > > +++ b/tools/perf/builtin-sched.c
> > > @@ -2102,26 +2102,12 @@ static struct thread *get_idle_thread(int cpu)
> > > return idle_threads[cpu];
> > > }
> > >
> > > -static void save_idle_callchain(struct thread *thread,
> > > +static void save_idle_callchain(struct idle_thread_runtime *itr,
> > > struct perf_sample *sample)
> > > {
> > > - struct thread *idle;
> > > - struct idle_thread_runtime *itr;
> > > -
> > > if (!symbol_conf.use_callchain || sample->callchain == NULL)
> > > return;
> > >
> > > - idle = get_idle_thread(sample->cpu);
> > > - if (idle == NULL) {
> > > - pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu);
> > > - return;
> > > - }
> > > -
> > > - itr = thread__priv(idle);
> > > - if (itr == NULL)
> > > - return;
> > > -
> > > - itr->last_thread = thread;
> > > callchain_cursor__copy(&itr->cursor, &callchain_cursor);
> > > }
> > >
> > > @@ -2179,9 +2165,24 @@ static struct thread *timehist_get_thread(struct perf_sched *sched,
> > >
> > > save_task_callchain(sched, sample, evsel, machine);
> > > if (sched->idle_hist) {
> > > + struct thread *idle;
> > > + struct idle_thread_runtime *itr;
> > > +
> > > + idle = get_idle_thread(sample->cpu);
> > > + if (idle == NULL) {
> > > + pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu);
> > > + return NULL;
> > > + }
> > > +
> > > + itr = thread__priv(idle);
> > > + if (itr == NULL)
> > > + return NULL;
> > > +
> > > + itr->last_thread = thread;
> > > +
> > > /* copy task callchain when entering to idle */
> > > if (perf_evsel__intval(evsel, sample, "next_pid") == 0)
> > > - save_idle_callchain(thread, sample);
> > > + save_idle_callchain(itr, sample);
> > > }
> > > }
> > >
> > > --
> > > 2.10.2
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-12-13 14:10 +0100 |
| Subject | Re: [PATCH 1/2] perf sched timehist: Fix --idle-hist when no callchains |
| Message-ID | <sNV0d-1Az-13@gated-at.bofh.it> |
| In reply to | #1540986 |
Em Tue, Dec 13, 2016 at 07:49:44PM +0900, Namhyung Kim escreveu:
> Hi Arnaldo,
>
> On Tue, Dec 13, 2016 at 07:32:02AM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Tue, Dec 13, 2016 at 05:06:31PM +0900, Namhyung Kim escreveu:
> > > When idle hist is enabled, the itr->last_thread should be set so that
> > > it can find which thread run before idle task. But it was only set in
> > > the save_idle_callchain(). This makes idle task doesn't show up in
> > > the output when callchain is not recorded.
> >
> > It is important to provide a Fixes: tag so that I can check if the
> > problem was introduced by some patch still not sent to Ingo, in which
> > case I could try and merge them, is this the case here?
>
> Yes,
>
> Fixes: b50c3ab0f1cc ("perf sched timehist: Save callchain when entering idle")
Ok, merged this fix with b50c3ab0f1cc, adding a second Link tag pointing
to this fix, now to the second fix...
- Arnaldo
> Thanks,
> Namhyung
>
>
> >
> > > Before:
> > >
> > > $ perf sched timehist --idle-hist
> > > Samples do not have callchains.
> > > time cpu task name wait time sch delay run time
> > > [tid/pid] (msec) (msec) (msec)
> > > --------------- ------ -------------------- --------- --------- ---------
> > > 197731.753834 [0001] perf[27469] 0.000 0.000 0.000
> > > 197731.753915 [0003] migration/3[23] 0.000 0.000 0.000
> > > 197731.754335 [0002] firefox[17773/17739] 0.000 0.000 0.000
> > > 197731.754486 [0001] sleep[27470] 0.000 0.000 0.000
> > > 197731.754981 [0002] firefox[17773/17739] 0.000 0.000 0.000
> > > 197731.755994 [0002] firefox[17773/17739] 0.000 0.000 0.000
> > > ...
> > >
> > > After:
> > >
> > > 197731.753834 [0001] perf[27469] 0.000 0.000 0.000
> > > 197731.753914 [0001] <idle> 0.000 0.000 0.079
> > > 197731.753915 [0003] migration/3[23] 0.000 0.000 0.000
> > > 197731.754335 [0002] firefox[17773/17739] 0.000 0.000 0.000
> > > 197731.754486 [0001] sleep[27470] 0.000 0.000 0.000
> > > 197731.754903 [0002] <idle> 0.047 0.000 0.567
> > > 197731.754981 [0002] firefox[17773/17739] 0.000 0.000 0.567
> > > 197731.755922 [0002] <idle> 0.078 0.000 0.941
> > > 197731.755994 [0002] firefox[17773/17739] 0.000 0.000 0.941
> > > 197731.756625 [0003] <idle> 0.123 0.000 2.709
> > > ...
> > >
> > > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > > ---
> > > tools/perf/builtin-sched.c | 33 +++++++++++++++++----------------
> > > 1 file changed, 17 insertions(+), 16 deletions(-)
> > >
> > > diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> > > index 0750e938a656..405a91d0515f 100644
> > > --- a/tools/perf/builtin-sched.c
> > > +++ b/tools/perf/builtin-sched.c
> > > @@ -2102,26 +2102,12 @@ static struct thread *get_idle_thread(int cpu)
> > > return idle_threads[cpu];
> > > }
> > >
> > > -static void save_idle_callchain(struct thread *thread,
> > > +static void save_idle_callchain(struct idle_thread_runtime *itr,
> > > struct perf_sample *sample)
> > > {
> > > - struct thread *idle;
> > > - struct idle_thread_runtime *itr;
> > > -
> > > if (!symbol_conf.use_callchain || sample->callchain == NULL)
> > > return;
> > >
> > > - idle = get_idle_thread(sample->cpu);
> > > - if (idle == NULL) {
> > > - pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu);
> > > - return;
> > > - }
> > > -
> > > - itr = thread__priv(idle);
> > > - if (itr == NULL)
> > > - return;
> > > -
> > > - itr->last_thread = thread;
> > > callchain_cursor__copy(&itr->cursor, &callchain_cursor);
> > > }
> > >
> > > @@ -2179,9 +2165,24 @@ static struct thread *timehist_get_thread(struct perf_sched *sched,
> > >
> > > save_task_callchain(sched, sample, evsel, machine);
> > > if (sched->idle_hist) {
> > > + struct thread *idle;
> > > + struct idle_thread_runtime *itr;
> > > +
> > > + idle = get_idle_thread(sample->cpu);
> > > + if (idle == NULL) {
> > > + pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu);
> > > + return NULL;
> > > + }
> > > +
> > > + itr = thread__priv(idle);
> > > + if (itr == NULL)
> > > + return NULL;
> > > +
> > > + itr->last_thread = thread;
> > > +
> > > /* copy task callchain when entering to idle */
> > > if (perf_evsel__intval(evsel, sample, "next_pid") == 0)
> > > - save_idle_callchain(thread, sample);
> > > + save_idle_callchain(itr, sample);
> > > }
> > > }
> > >
> > > --
> > > 2.10.2
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Namhyung Kim <tipbot@zytor.com> |
|---|---|
| Date | 2016-12-20 20:30 +0100 |
| Subject | [tip:perf/urgent] perf sched timehist: Save callchain when entering idle |
| Message-ID | <sQygS-1i9-21@gated-at.bofh.it> |
| In reply to | #1540886 |
Commit-ID: 699b5b920db04a6ff5c03a519e4c182aeb350952
Gitweb: http://git.kernel.org/tip/699b5b920db04a6ff5c03a519e4c182aeb350952
Author: Namhyung Kim <namhyung@kernel.org>
AuthorDate: Thu, 8 Dec 2016 23:47:52 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 15 Dec 2016 16:25:44 -0300
perf sched timehist: Save callchain when entering idle
In order to investigate the idleness reason, it is necessary to keep the
callchains when entering idle. This can be identified by the
sched:sched_switch event having the next_pid field as 0.
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-4-namhyung@kernel.org
Link: http://lkml.kernel.org/r/20161213080632.19099-1-namhyung@kernel.org
[ Merged fix from Namhyung, see second Link: tag ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-sched.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index e108b0f..dc83b80 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -200,6 +200,7 @@ struct perf_sched {
/* options for timehist command */
bool summary;
bool summary_only;
+ bool idle_hist;
bool show_callchain;
unsigned int max_stack;
bool show_cpu_visual;
@@ -2101,6 +2102,15 @@ static struct thread *get_idle_thread(int cpu)
return idle_threads[cpu];
}
+static void save_idle_callchain(struct idle_thread_runtime *itr,
+ struct perf_sample *sample)
+{
+ if (!symbol_conf.use_callchain || sample->callchain == NULL)
+ return;
+
+ callchain_cursor__copy(&itr->cursor, &callchain_cursor);
+}
+
/*
* handle runtime stats saved per thread
*/
@@ -2154,6 +2164,26 @@ static struct thread *timehist_get_thread(struct perf_sched *sched,
}
save_task_callchain(sched, sample, evsel, machine);
+ if (sched->idle_hist) {
+ struct thread *idle;
+ struct idle_thread_runtime *itr;
+
+ idle = get_idle_thread(sample->cpu);
+ if (idle == NULL) {
+ pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu);
+ return NULL;
+ }
+
+ itr = thread__priv(idle);
+ if (itr == NULL)
+ return NULL;
+
+ itr->last_thread = thread;
+
+ /* copy task callchain when entering to idle */
+ if (perf_evsel__intval(evsel, sample, "next_pid") == 0)
+ save_idle_callchain(itr, sample);
+ }
}
return thread;
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web