* [PATCH 0/2] sched/core: Cleanup leftovers in __schedule()
@ 2016-02-28 16:40 Alexander Gordeev
2016-02-28 16:40 ` [PATCH 1/2] sched/core: Get rid of 'cpu' argument in wq_worker_sleeping() Alexander Gordeev
2016-02-28 16:40 ` [PATCH 2/2] sched/core: Get rid of 'cpu' variable in __schedule() Alexander Gordeev
0 siblings, 2 replies; 5+ messages in thread
From: Alexander Gordeev @ 2016-02-28 16:40 UTC (permalink / raw)
To: linux-kernel; +Cc: Alexander Gordeev
*** BLURB HERE ***
Alexander Gordeev (2):
sched/core: Get rid of 'cpu' argument in wq_worker_sleeping()
sched/core: Get rid of 'cpu' variable in __schedule()
kernel/sched/core.c | 7 ++-----
kernel/workqueue.c | 4 ++--
kernel/workqueue_internal.h | 2 +-
3 files changed, 5 insertions(+), 8 deletions(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] sched/core: Get rid of 'cpu' argument in wq_worker_sleeping()
2016-02-28 16:40 [PATCH 0/2] sched/core: Cleanup leftovers in __schedule() Alexander Gordeev
@ 2016-02-28 16:40 ` Alexander Gordeev
2016-02-28 17:47 ` kbuild test robot
2016-02-29 19:09 ` Oleg Nesterov
2016-02-28 16:40 ` [PATCH 2/2] sched/core: Get rid of 'cpu' variable in __schedule() Alexander Gordeev
1 sibling, 2 replies; 5+ messages in thread
From: Alexander Gordeev @ 2016-02-28 16:40 UTC (permalink / raw)
To: linux-kernel; +Cc: Alexander Gordeev, Oleg Nesterov, Peter Zijlstra
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.
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
kernel/sched/core.c | 2 +-
kernel/workqueue.c | 4 ++--
kernel/workqueue_internal.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 9503d59..4e56a4d 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3257,7 +3257,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);
}
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 7ff5dc7..967a1ab 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -870,7 +870,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 +886,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 != smp_processor_id()))
return NULL;
/*
diff --git a/kernel/workqueue_internal.h b/kernel/workqueue_internal.h
index 4521587..8635417 100644
--- a/kernel/workqueue_internal.h
+++ b/kernel/workqueue_internal.h
@@ -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 */
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] sched/core: Get rid of 'cpu' variable in __schedule()
2016-02-28 16:40 [PATCH 0/2] sched/core: Cleanup leftovers in __schedule() Alexander Gordeev
2016-02-28 16:40 ` [PATCH 1/2] sched/core: Get rid of 'cpu' argument in wq_worker_sleeping() Alexander Gordeev
@ 2016-02-28 16:40 ` Alexander Gordeev
1 sibling, 0 replies; 5+ messages in thread
From: Alexander Gordeev @ 2016-02-28 16:40 UTC (permalink / raw)
To: linux-kernel; +Cc: Alexander Gordeev, Oleg Nesterov, Peter Zijlstra
'cpu' variable is only used to acquire the current runqueue.
By using this_rq() instead, we can get rid of that variable.
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
kernel/sched/core.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 4e56a4d..82206f0 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3205,10 +3205,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;
/*
@@ -3280,7 +3278,6 @@ static void __sched notrace __schedule(bool preempt)
trace_sched_switch(preempt, prev, next);
rq = context_switch(rq, prev, next); /* unlocks the rq */
- cpu = cpu_of(rq);
} else {
lockdep_unpin_lock(&rq->lock);
raw_spin_unlock_irq(&rq->lock);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] sched/core: Get rid of 'cpu' argument in wq_worker_sleeping()
2016-02-28 16:40 ` [PATCH 1/2] sched/core: Get rid of 'cpu' argument in wq_worker_sleeping() Alexander Gordeev
@ 2016-02-28 17:47 ` kbuild test robot
2016-02-29 19:09 ` Oleg Nesterov
1 sibling, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2016-02-28 17:47 UTC (permalink / raw)
To: Alexander Gordeev
Cc: kbuild-all, linux-kernel, Alexander Gordeev, Oleg Nesterov,
Peter Zijlstra
[-- Attachment #1: Type: text/plain, Size: 3368 bytes --]
Hi Alexander,
[auto build test WARNING on wq/for-next]
[also build test WARNING on v4.5-rc6 next-20160226]
[cannot apply to tip/sched/core]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Alexander-Gordeev/sched-core-Cleanup-leftovers-in-__schedule/20160229-004522
base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-next
reproduce: make htmldocs
All warnings (new ones prefixed by >>):
include/linux/init.h:1: warning: no structured comments found
>> kernel/workqueue.c:874: warning: Excess function parameter 'cpu' description in 'wq_worker_sleeping'
kernel/sys.c:1: warning: no structured comments found
drivers/dma-buf/seqno-fence.c:1: warning: no structured comments found
drivers/dma-buf/reservation.c:1: warning: no structured comments found
include/linux/reservation.h:1: warning: no structured comments found
include/linux/spi/spi.h:540: warning: No description found for parameter 'max_transfer_size'
vim +874 kernel/workqueue.c
0fcb78c22f Rolf Eike Beer 2006-07-30 858 /**
e22bee782b Tejun Heo 2010-06-29 859 * wq_worker_sleeping - a worker is going to sleep
e22bee782b Tejun Heo 2010-06-29 860 * @task: task going to sleep
e22bee782b Tejun Heo 2010-06-29 861 * @cpu: CPU in question, must be the current CPU number
^1da177e4c Linus Torvalds 2005-04-16 862 *
e22bee782b Tejun Heo 2010-06-29 863 * This function is called during schedule() when a busy worker is
e22bee782b Tejun Heo 2010-06-29 864 * going to sleep. Worker on the same cpu can be woken up by
e22bee782b Tejun Heo 2010-06-29 865 * returning pointer to its task.
^1da177e4c Linus Torvalds 2005-04-16 866 *
e22bee782b Tejun Heo 2010-06-29 867 * CONTEXT:
e22bee782b Tejun Heo 2010-06-29 868 * spin_lock_irq(rq->lock)
^1da177e4c Linus Torvalds 2005-04-16 869 *
d185af300f Yacine Belkadi 2013-07-31 870 * Return:
e22bee782b Tejun Heo 2010-06-29 871 * Worker task on @cpu to wake up, %NULL if none.
^1da177e4c Linus Torvalds 2005-04-16 872 */
479b9d020d Alexander Gordeev 2016-02-28 873 struct task_struct *wq_worker_sleeping(struct task_struct *task)
^1da177e4c Linus Torvalds 2005-04-16 @874 {
e22bee782b Tejun Heo 2010-06-29 875 struct worker *worker = kthread_data(task), *to_wakeup = NULL;
111c225a5f Tejun Heo 2013-01-17 876 struct worker_pool *pool;
f293ea9200 Oleg Nesterov 2007-05-09 877
111c225a5f Tejun Heo 2013-01-17 878 /*
111c225a5f Tejun Heo 2013-01-17 879 * Rescuers, which may not have all the fields set up like normal
111c225a5f Tejun Heo 2013-01-17 880 * workers, also reach here, let's not access anything before
111c225a5f Tejun Heo 2013-01-17 881 * checking NOT_RUNNING.
111c225a5f Tejun Heo 2013-01-17 882 */
:::::: The code at line 874 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2
:::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 6238 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] sched/core: Get rid of 'cpu' argument in wq_worker_sleeping()
2016-02-28 16:40 ` [PATCH 1/2] sched/core: Get rid of 'cpu' argument in wq_worker_sleeping() Alexander Gordeev
2016-02-28 17:47 ` kbuild test robot
@ 2016-02-29 19:09 ` Oleg Nesterov
1 sibling, 0 replies; 5+ messages in thread
From: Oleg Nesterov @ 2016-02-29 19:09 UTC (permalink / raw)
To: Alexander Gordeev; +Cc: linux-kernel, Peter Zijlstra
On 02/28, Alexander Gordeev wrote:
>
> -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 +886,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 != smp_processor_id()))
> return NULL;
I think both changes are fine, but perhaps it would be better to keep
raw_smp_processor_id(). Unless you did this on purpose, but then it makes
sense to add a note into the changelog.
Oleg.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-02-29 19:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-28 16:40 [PATCH 0/2] sched/core: Cleanup leftovers in __schedule() Alexander Gordeev
2016-02-28 16:40 ` [PATCH 1/2] sched/core: Get rid of 'cpu' argument in wq_worker_sleeping() Alexander Gordeev
2016-02-28 17:47 ` kbuild test robot
2016-02-29 19:09 ` Oleg Nesterov
2016-02-28 16:40 ` [PATCH 2/2] sched/core: Get rid of 'cpu' variable in __schedule() Alexander Gordeev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox