From: Wang Jinchao Date: Sun, 20 Aug 2023 12:53:17 +0000 (+0800) Subject: sched/core: Refactor the task_flags check for worker sleeping in sched_submit_work() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=3eafe225995c67f8c179011ec2d6e4c12b32a53d;p=linux.git sched/core: Refactor the task_flags check for worker sleeping in sched_submit_work() 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 Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/ZOIMvURE99ZRAYEj@fedora --- diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 107493469b4e1..84881a582847f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -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