sched/core: Refactor the task_flags check for worker sleeping in sched_submit_work()
authorWang Jinchao <wangjinchao@xfusion.com>
Sun, 20 Aug 2023 12:53:17 +0000 (20:53 +0800)
committerIngo Molnar <mingo@kernel.org>
Sun, 24 Sep 2023 10:15:06 +0000 (12:15 +0200)
Simplify the conditional logic for checking worker flags
by splitting the original compound `if` statement into
separate `if` and `else if` clauses.

This modification not only retains the previous functionality,
but also reduces a single `if` check, improving code clarity
and potentially enhancing performance.

Signed-off-by: Wang Jinchao <wangjinchao@xfusion.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/ZOIMvURE99ZRAYEj@fedora
kernel/sched/core.c

index 107493469b4e14066af2986fc06c55fe43dcfcb3..84881a582847f04d34989602af8e28f741165203 100644 (file)
@@ -6711,12 +6711,10 @@ static inline void sched_submit_work(struct task_struct *tsk)
         * If a worker goes to sleep, notify and ask workqueue whether it
         * wants to wake up a task to maintain concurrency.
         */
-       if (task_flags & (PF_WQ_WORKER | PF_IO_WORKER)) {
-               if (task_flags & PF_WQ_WORKER)
-                       wq_worker_sleeping(tsk);
-               else
-                       io_wq_worker_sleeping(tsk);
-       }
+       if (task_flags & PF_WQ_WORKER)
+               wq_worker_sleeping(tsk);
+       else if (task_flags & PF_IO_WORKER)
+               io_wq_worker_sleeping(tsk);
 
        /*
         * spinlock and rwlock must not flush block requests.  This will