lkml.org 
[lkml]   [2014]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH v2 1/2] sched: schedule_tail() should disable preemption
On 10/08, Oleg Nesterov wrote:
>
> Another problem is that finish_task_switch() itself runs with preempt
> enabled after finish_lock_switch(). If nothing else this means that
> ->sched_in() notifier can't trust its "cpu" arg.

OOPS, this obviously can't happen, ->preempt_notifiers must be empty.
Remove this part from the changelog, please see v2.

I am not sure about finish_arch_post_lock_switch() ... but probably
it should be fine without preempt_disable.

-------------------------------------------------------------------------------
Subject: [PATCH v2 1/2] sched: schedule_tail() should disable preemption

finish_task_switch() enables preemption, so post_schedule(rq) can be
called on the wrong (and even dead) CPU. Afaics, nothing really bad
can happen, but in this case we can wrongly clear rq->post_schedule
on that CPU. And this simply looks wrong in any case.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
kernel/sched/core.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 703c7e6..3f267e8 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2277,15 +2277,14 @@ static inline void post_schedule(struct rq *rq)
asmlinkage __visible void schedule_tail(struct task_struct *prev)
__releases(rq->lock)
{
- struct rq *rq = this_rq();
+ struct rq *rq;

+ /* finish_task_switch() drops rq->lock and enables preemtion */
+ preempt_disable();
+ rq = this_rq();
finish_task_switch(rq, prev);
-
- /*
- * FIXME: do we need to worry about rq being invalidated by the
- * task_switch?
- */
post_schedule(rq);
+ preempt_enable();

if (current->set_child_tid)
put_user(task_pid_vnr(current), current->set_child_tid);
--
1.5.5.1



\
 
 \ /
  Last update: 2014-10-08 22:21    [W:0.073 / U:0.680 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site