Skip to content

Commit

Permalink
context_tracking: Restore previous state in schedule_user
Browse files Browse the repository at this point in the history
It appears that some SCHEDULE_USER (asm for schedule_user) callers
in arch/x86/kernel/entry_64.S are called from RCU kernel context,
and schedule_user will return in RCU user context.  This causes RCU
warnings and possible failures.

This is intended to be a minimal fix suitable for 3.18.

Reported-and-tested-by: Dave Jones <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Frédéric Weisbecker <[email protected]>
Acked-by: Paul E. McKenney <[email protected]>
Signed-off-by: Andy Lutomirski <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
amluto authored and torvalds committed Dec 4, 2014
1 parent ebcd241 commit 7cc78f8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2874,10 +2874,14 @@ asmlinkage __visible void __sched schedule_user(void)
* or we have been woken up remotely but the IPI has not yet arrived,
* we haven't yet exited the RCU idle mode. Do it here manually until
* we find a better solution.
*
* NB: There are buggy callers of this function. Ideally we
* should warn if prev_state != IN_USER, but that will trigger
* too frequently to make sense yet.
*/
user_exit();
enum ctx_state prev_state = exception_enter();
schedule();
user_enter();
exception_exit(prev_state);
}
#endif

Expand Down

0 comments on commit 7cc78f8

Please sign in to comment.