sched/core: Cleanup leftovers in __schedule()
v3 cover sched/core: Cleanup leftovers in __schedule()
Changes since v2:
- rebased on top of tip/sched/core
Changes since v1:
- cover letter BLURB added :)
- forgotten Suggested-by Oleg field added to patch 1
- raw_smp_processor_id() returned instead of mistaken smp_processor_id()
- kbuild excess function parameter 'cpu' description warning fixed
Alexander Gordeev (2):
sched/core: Get rid of 'cpu' argument in wq_worker_sleeping() sched/core: Get rid of 'cpu' local variable in __schedule()
kernel/sched/core.c | 6 ++---- kernel/workqueue.c | 5 ++--- kernel/workqueue_internal.h | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v3 1/2 sched/core: Get rid of 'cpu' argument in wq_worker_sleeping()
Given that wq_worker_sleeping() could only be called for a CPU it is running on, we do not need passing a CPU ID as an argument.
--- kernel/sched/core.c | 2 +- kernel/workqueue.c | 5 ++--- kernel/workqueue_internal.h | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-)
kernel/sched/core.c +1 -1
@@ -3183,7 +3183,7 @@ static void __sched notrace __schedule(bool preempt)if (prev->flags &PF_WQ_WORKER ) {struct task_struct *to_wakeup; - to_wakeup =wq_worker_sleeping (prev, cpu); + to_wakeup =wq_worker_sleeping (prev);if (to_wakeup)try_to_wake_up_local (to_wakeup); }
kernel/workqueue.c +2 -3
@@ -858,7 +858,6 @@ void wq_worker_waking_up(struct task_struct *task, int cpu)/** * wq_worker_sleeping - a worker is going to sleep * @task: task going to sleep -* @cpu: CPU in question, must be the current CPU number * * This function is called during schedule() when a busy worker is * going to sleep. Worker on the same cpu can be woken up by
@@ -870,7 +869,7 @@ void wq_worker_waking_up(struct task_struct *task, int cpu)* Return: * Worker task on @cpu to wake up, %NULL if none. */ -struct task_struct *wq_worker_sleeping (struct task_struct *task,int cpu) +struct task_struct *wq_worker_sleeping (struct task_struct *task) {struct worker *worker =kthread_data (task), *to_wakeup =NULL ;struct worker_pool *pool;
@@ -886,7 +885,7 @@ struct task_struct *wq_worker_sleeping(struct task_struct *task, int cpu) pool = worker->pool;/* this can only happen on the local cpu */ -if (WARN_ON_ONCE (cpu !=raw_smp_processor_id () || pool->cpu != cpu)) +if (WARN_ON_ONCE (pool->cpu !=raw_smp_processor_id ()))return NULL ;/*
kernel/workqueue_internal.h +1 -1
@@ -69,6 +69,6 @@ static inline struct worker *current_wq_worker(void)* sched/core.c and workqueue.c. */ void wq_worker_waking_up (struct task_struct *task,int cpu); -struct task_struct *wq_worker_sleeping (struct task_struct *task,int cpu); +struct task_struct *wq_worker_sleeping (struct task_struct *task);#endif /* _KERNEL_WORKQUEUE_INTERNAL_H */
Signature · 1 line
1.8.3.1
Peter Zijlstra
maintainerRe: [PATCH v3 1/2] sched/core: Get rid of 'cpu' argument in wq_worker_sleeping()
This really should also have been Cc'ed to TJ, doing so now.
Quoted 72 lines · Alexander Gordeev
Given that
wq_worker_sleeping()could only be called for a CPU it is running on, we do not need passing a CPU ID as an argument.Suggested-by Oleg Nesterov <[email protected]>Cc Oleg Nesterov <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Alexander Gordeev <[email protected]>--- kernel/sched/core.c | 2 +- kernel/workqueue.c | 5 ++--- kernel/workqueue_internal.h | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-)kernel/sched/core.c +1
-1@@ -3183,7 +3183,7 @@ static void __sched notrace __schedule(bool preempt)if (prev->flags &PF_WQ_WORKER ) {struct task_struct *to_wakeup; - to_wakeup =wq_worker_sleeping (prev, cpu); + to_wakeup =wq_worker_sleeping (prev);if (to_wakeup)try_to_wake_up_local (to_wakeup); }kernel/workqueue.c +2
-3@@ -858,7 +858,6 @@ void wq_worker_waking_up(struct task_struct *task, int cpu)/** * wq_worker_sleeping - a worker is going to sleep * @task: task going to sleep -* @cpu: CPU in question, must be the current CPU number * * This function is called during schedule() when a busy worker is * going to sleep. Worker on the same cpu can be woken up by @@ -870,7 +869,7 @@ void wq_worker_waking_up(struct task_struct *task, int cpu)* Return: * Worker task on @cpu to wake up, %NULL if none. */ -struct task_struct *wq_worker_sleeping (struct task_struct *task,int cpu) +struct task_struct *wq_worker_sleeping (struct task_struct *task) {struct worker *worker =kthread_data (task), *to_wakeup =NULL ;struct worker_pool *pool;@@ -886,7 +885,7 @@ struct task_struct *wq_worker_sleeping(struct task_struct *task, int cpu) pool = worker->pool;/* this can only happen on the local cpu */ -if (WARN_ON_ONCE (cpu !=raw_smp_processor_id () || pool->cpu != cpu)) +if (WARN_ON_ONCE (pool->cpu !=raw_smp_processor_id ()))return NULL ;/* kernel/workqueue_internal.h +1
-1@@ -69,6 +69,6 @@ static inline struct worker *current_wq_worker(void)* sched/core.c and workqueue.c. */ void wq_worker_waking_up (struct task_struct *task,int cpu); -struct task_struct *wq_worker_sleeping (struct task_struct *task,int cpu); +struct task_struct *wq_worker_sleeping (struct task_struct *task);#endif /* _KERNEL_WORKQUEUE_INTERNAL_H */ Signature · 1 line
1.8.3.1
Re: [PATCH v3 1/2] sched/core: Get rid of 'cpu' argument in wq_worker_sleeping()
Quoted 12 lines · Peter Zijlstra
This really should also have been Cc'ed to TJ, doing so now.
Quoted 8 lines · Alexander Gordeev
Given that
wq_worker_sleeping()could only be called for a CPU it is running on, we do not need passing a CPU ID as an argument.Suggested-by Oleg Nesterov <[email protected]>Cc Oleg Nesterov <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Alexander Gordeev <[email protected]>
I'll route this through wq/for-4.6.
Thanks.
Signature · 1 line
tejun
PATCH v3 2/2 sched/core: Get rid of 'cpu' local variable in __schedule()
In reply to Alexander GordeevThis update is a continuation of commit 3223d05 ("sched/core:
Remove dead statement in __schedule()") and completes the removal of a dead code with a removal of an unnecessary 'cpu' local variable - as it is only used to acquire the current runqueue.
--- kernel/sched/core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
kernel/sched/core.c +1 -3
@@ -3131,10 +3131,8 @@ static void __sched notrace __schedule(bool preempt)struct task_struct *prev, *next;unsigned long *switch_count;struct rq *rq; -int cpu; - cpu =smp_processor_id (); - rq =cpu_rq (cpu); + rq =this_rq (); prev = rq->curr;/*
Signature · 1 line
1.8.3.1
Peter Zijlstra
maintainerRe: [PATCH v3 2/2] sched/core: Get rid of 'cpu' local variable in __schedule()
Quoted 1 line · Alexander Gordeev
This update is a continuation of commit 3223d05 ("sched/core:
Please put
[core]
abbrev = 12
Into your .gitconfig, 7 char SHA1s are no good.
If TJ acks the first, I can fix up this time, so no need to repost just yet.