From: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: <peterz@infradead.org>, <bsegall@google.com>, <mingo@redhat.com>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sched: Move the wakeup tracepoint from ttwu_do_wakeup() to ttwu_activate().
Date: Tue, 6 May 2014 09:19:51 +0900 [thread overview]
Message-ID: <53682AA7.9060401@cn.fujitsu.com> (raw)
In-Reply-To: <20140505100014.19b46560@gandalf.local.home>
On 05/05/2014 11:00 PM, Steven Rostedt wrote:
> On Mon, 5 May 2014 15:34:07 +0900
> Dongsheng Yang <yangds.fnst@cn.fujitsu.com> wrote:
>
>> The original design of sched:sched_wakeup is to trace the event inserting
>> a task into run queue. It means we can know that the state of this task is
>> changed from "sleeping" to "waiting_cpu". Then we can calculate the delay time
>> from this task on_rq = 1 to running on cpu in `perf sched latency`.
>>
>> But currently, sched:sched_wakeup event is tracing ttwu_do_wakeup() and this
>> function only set the p->state to TASK_RUNNING. This trace point can tell user
>> very little. When get a event of sched:sched_wakeup, user know that kernel call
>> ttwu_do_wakeup() once, but we can not say that task start to wait cpu from now
>> on. Maybe it did not dequeue at all, in this case we will get a wrong latency
>> time calculated by "sched_in_time - wakeup_time".
>>
>> Anyway, current sched:sched_wakeup event can tell user very little.
>> When we get a sched:sched_wakeup:
>> * We can not say a task is inserted into run queue, it is also used for task
>> which is on_rq and only change the task->state to TASK_RUNNING.
>> * We can not say the task->state is changed from {UN}INTERRUPTABLE to RUNNING,
>> sometimes task->state is already changed to RUNNING by other cpu.
>>
>> As explained above, this patch move the trace point of sched:sched_wakeup from
>> ttwu_do_wakeup() to ttwu_activate(), then when we get an event of sched_wakeup,
>> we can say that a task enqueued and started waiting cpu to run.
>>
> tldr;
Yes, it is really loooong, sorry for my terrible expression in english. :(
>
> ttwu_do_wakeup() is called when the task's state is switched back to
> TASK_RUNNING, whether or not the task actually scheduled out. Tracing
> the wakeup event when the task never scheduled out is quite confusing.
> It should only trace the task wake up if the task actually did go to
> sleep. Move the tracepoint from ttwu_do_wakeup() to ttwu_activate()
> where it is called only if the task is really woken up and not just
> have its state changed.
Thanx for your kind comment here, it looks shorter and more clear to me.
I will update my commit message with your suggestion.
Thank you very much! :)
>
> -- Steve
>
>
>> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
>> ---
>> kernel/sched/core.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
>> index 9074c6d..0cae994 100644
>> --- a/kernel/sched/core.c
>> +++ b/kernel/sched/core.c
>> @@ -1420,6 +1420,7 @@ static void ttwu_activate(struct rq *rq, struct task_struct *p, int en_flags)
>> {
>> activate_task(rq, p, en_flags);
>> p->on_rq = 1;
>> + trace_sched_wakeup(p, true);
>>
>> /* if a worker is waking up, notify workqueue */
>> if (p->flags & PF_WQ_WORKER)
>> @@ -1433,7 +1434,6 @@ static void
>> ttwu_do_wakeup(struct rq *rq, struct task_struct *p, int wake_flags)
>> {
>> check_preempt_curr(rq, p, wake_flags);
>> - trace_sched_wakeup(p, true);
>>
>> p->state = TASK_RUNNING;
>> #ifdef CONFIG_SMP
> .
>
next prev parent reply other threads:[~2014-05-06 1:19 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-15 12:32 [PATCH 0/8] perf sched: Add trace event for sched wait Dongsheng Yang
2014-04-15 12:32 ` [PATCH 1/8] sched & trace: Add a trace event for wait Dongsheng Yang
2014-04-15 13:49 ` Peter Zijlstra
2014-04-16 14:23 ` Steven Rostedt
2014-04-15 12:32 ` [PATCH 2/8] sched/wait: Add trace point before add task into wait queue Dongsheng Yang
2014-04-15 12:32 ` [PATCH 3/8] sched/wait: Use __add_wait_queue{_tail}_exclusive() as possible Dongsheng Yang
2014-04-15 13:49 ` Peter Zijlstra
2014-04-16 9:51 ` Dongsheng Yang
2014-04-15 12:32 ` [PATCH 4/8] sched/core: Skip wakeup when task is already running Dongsheng Yang
2014-04-15 13:53 ` Peter Zijlstra
2014-04-16 10:22 ` Dongsheng Yang
2014-04-22 11:56 ` Dongsheng Yang
2014-04-22 13:23 ` Peter Zijlstra
2014-04-22 17:10 ` bsegall
2014-04-22 17:53 ` Steven Rostedt
2014-04-22 18:18 ` Peter Zijlstra
2014-05-05 6:32 ` Dongsheng Yang
2014-05-05 6:34 ` [PATCH] sched: Move the wakeup tracepoint from ttwu_do_wakeup() to ttwu_activate() Dongsheng Yang
2014-05-05 14:00 ` Steven Rostedt
2014-05-06 0:19 ` Dongsheng Yang [this message]
2014-05-06 0:26 ` Dongsheng Yang
2014-05-06 2:06 ` Steven Rostedt
2014-05-06 1:29 ` Dongsheng Yang
2014-05-06 1:52 ` [PATCH] sched: Distinguish sched_wakeup event when wake up a task which did schedule out or not Dongsheng Yang
2014-05-09 0:16 ` Dongsheng Yang
2014-05-09 1:27 ` Steven Rostedt
2014-05-10 15:29 ` Peter Zijlstra
[not found] ` <536F90BE.2080806@gmail.com>
2014-05-11 15:24 ` Fwd: " Dongsheng Yang
2014-05-11 16:35 ` Peter Zijlstra
2014-05-11 18:52 ` Steven Rostedt
2014-05-12 6:47 ` Peter Zijlstra
2014-05-12 8:58 ` Dongsheng Yang
2014-05-12 14:09 ` Steven Rostedt
2014-05-12 15:09 ` Peter Zijlstra
2014-05-12 15:17 ` Steven Rostedt
2014-05-12 15:28 ` Peter Zijlstra
2014-04-15 12:32 ` [PATCH 5/8] perf tools: record and process sched:sched_wait event Dongsheng Yang
2014-04-15 12:32 ` [PATCH 6/8] perf tools: add missing event for perf sched record Dongsheng Yang
2014-04-15 12:32 ` [PATCH 7/8] perf tools: Adapt the TASK_STATE_TO_CHAR_STR to new value in kernel space Dongsheng Yang
2014-04-15 12:32 ` [PATCH 8/8] perf tools: Clarify the output of perf sched map Dongsheng Yang
2014-04-15 13:54 ` [PATCH 0/8] perf sched: Add trace event for sched wait Peter Zijlstra
2014-04-16 10:28 ` Dongsheng Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53682AA7.9060401@cn.fujitsu.com \
--to=yangds.fnst@cn.fujitsu.com \
--cc=bsegall@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox