Skip to content

Commit b416514

Browse files
Frederic WeisbeckerKAGA-KOKO
authored andcommitted
entry/rcu: Check TIF_RESCHED _after_ delayed RCU wake-up
RCU sometimes needs to perform a delayed wake up for specific kthreads handling offloaded callbacks (RCU_NOCB). These wakeups are performed by timers and upon entry to idle (also to guest and to user on nohz_full). However the delayed wake-up on kernel exit is actually performed after the thread flags are fetched towards the fast path check for work to do on exit to user. As a result, and if there is no other pending work to do upon that kernel exit, the current task will resume to userspace with TIF_RESCHED set and the pending wake up ignored. Fix this with fetching the thread flags _after_ the delayed RCU-nocb kthread wake-up. Fixes: 47b8ff1 ("entry: Explicitly flush pending rcuog wakeup before last rescheduling point") Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20230315194349.10798-3-joel@joelfernandes.org
1 parent f87d286 commit b416514

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/entry/common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,14 @@ static unsigned long exit_to_user_mode_loop(struct pt_regs *regs,
192192

193193
static void exit_to_user_mode_prepare(struct pt_regs *regs)
194194
{
195-
unsigned long ti_work = read_thread_flags();
195+
unsigned long ti_work;
196196

197197
lockdep_assert_irqs_disabled();
198198

199199
/* Flush pending rcuog wakeup before the last need_resched() check */
200200
tick_nohz_user_enter_prepare();
201201

202+
ti_work = read_thread_flags();
202203
if (unlikely(ti_work & EXIT_TO_USER_MODE_WORK))
203204
ti_work = exit_to_user_mode_loop(regs, ti_work);
204205

0 commit comments

Comments
 (0)