sched/core, workqueues: Distangle worker accounting from rq lock
authorThomas Gleixner <tglx@linutronix.de>
Wed, 13 Mar 2019 16:55:48 +0000 (17:55 +0100)
committerIngo Molnar <mingo@kernel.org>
Tue, 16 Apr 2019 14:55:15 +0000 (16:55 +0200)
commit6d25be5782e482eb93e3de0c94d0a517879377d0
tree4130e400ad5e37303f02e98cb2ade08c2e810c26
parente2abb398115e9c33f3d1e25bf6d1d08badc58b13
sched/core, workqueues: Distangle worker accounting from rq lock

The worker accounting for CPU bound workers is plugged into the core
scheduler code and the wakeup code. This is not a hard requirement and
can be avoided by keeping track of the state in the workqueue code
itself.

Keep track of the sleeping state in the worker itself and call the
notifier before entering the core scheduler. There might be false
positives when the task is woken between that call and actually
scheduling, but that's not really different from scheduling and being
woken immediately after switching away. When nr_running is updated when
the task is retunrning from schedule() then it is later compared when it
is done from ttwu().

[ bigeasy: preempt_disable() around wq_worker_sleeping() by Daniel Bristot de Oliveira ]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/ad2b29b5715f970bffc1a7026cabd6ff0b24076a.1532952814.git.bristot@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/sched/core.c
kernel/workqueue.c
kernel/workqueue_internal.h