We already have sched_update_worker() which calls the "I woke up" handler for io-wq and workqueue threads, rename it to sched_in_update(). The code that is called when the threads are going to sleep is moved into an identical helper, sched_out_update(), so that it mirrors the schedule in side. No functional changes in this patch. Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> --- kernel/sched/core.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 1a9983da4408..c7bab13f9caa 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4102,11 +4102,8 @@ void __noreturn do_task_dead(void) cpu_relax(); } -static inline void sched_submit_work(struct task_struct *tsk) +static void sched_out_update(struct task_struct *tsk) { - if (!tsk->state) - return; - /* * If a worker went to sleep, notify and ask workqueue whether * it wants to wake up a task to maintain concurrency. @@ -4122,6 +4119,24 @@ static inline void sched_submit_work(struct task_struct *tsk) io_wq_worker_sleeping(tsk); preempt_enable_no_resched(); } +} + +static void sched_in_update(struct task_struct *tsk) +{ + if (tsk->flags & (PF_WQ_WORKER | PF_IO_WORKER)) { + if (tsk->flags & PF_WQ_WORKER) + wq_worker_running(tsk); + else + io_wq_worker_running(tsk); + } +} + +static inline void sched_submit_work(struct task_struct *tsk) +{ + if (!tsk->state) + return; + + sched_out_update(tsk); if (tsk_is_pi_blocked(tsk)) return; @@ -4134,16 +4149,6 @@ static inline void sched_submit_work(struct task_struct *tsk) blk_schedule_flush_plug(tsk); } -static void sched_update_worker(struct task_struct *tsk) -{ - if (tsk->flags & (PF_WQ_WORKER | PF_IO_WORKER)) { - if (tsk->flags & PF_WQ_WORKER) - wq_worker_running(tsk); - else - io_wq_worker_running(tsk); - } -} - asmlinkage __visible void __sched schedule(void) { struct task_struct *tsk = current; @@ -4154,7 +4159,7 @@ asmlinkage __visible void __sched schedule(void) __schedule(false); sched_preempt_enable_no_resched(); } while (need_resched()); - sched_update_worker(tsk); + sched_in_update(tsk); } EXPORT_SYMBOL(schedule); -- 2.25.1