[PATCH 4/8] sched/core: Skip wakeup when task is already running.

From: Dongsheng Yang
Date: Tue Apr 15 2014 - 09:34:24 EST


From: Dongsheng <yangds.fnst@xxxxxxxxxxxxxx>

It is pointless to wake up a running task. Currently, we can
see it in perf sched latency.

# perf sched record sleep 10
[ perf record: Woken up 2 times to write data ]
[ perf record: Captured and wrote 21.170 MB perf.data (~924950 samples) ]
# perf sched latency |tail
ksoftirqd/13:57 | 0.011 ms | 1 | avg: 0.003 ms | max: 0.003 ms | max at: 254123.512011 s
khelper:6423 | 0.059 ms | 3 | avg: 0.003 ms | max: 0.005 ms | max at: 254124.947110 s
ksoftirqd/3:17 | 0.042 ms | 2 | avg: 0.003 ms | max: 0.003 ms | max at: 254126.478175 s
automount:6465 | 0.480 ms | 1 | avg: 0.000 ms | max: 0.000 ms | max at: 0.000000 s
automount:6618 | 0.465 ms | 1 | avg: 0.000 ms | max: 0.000 ms | max at: 0.000000 s
-----------------------------------------------------------------------------------------
TOTAL: | 3535.020 ms | 28477 |
---------------------------------------------------
INFO: 0.922% state machine bugs (259 out of 28092)

Signed-off-by: Dongsheng <yangds.fnst@xxxxxxxxxxxxxx>
---
kernel/sched/core.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 268a45e..fc6b644 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1416,6 +1416,9 @@ static void ttwu_activate(struct rq *rq, struct task_struct *p, int en_flags)
static void
ttwu_do_wakeup(struct rq *rq, struct task_struct *p, int wake_flags)
{
+ if (p->state == TASK_RUNNING)
+ return;
+
check_preempt_curr(rq, p, wake_flags);
trace_sched_wakeup(p, true);

--
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/