Skip to content

Commit 589f22c

Browse files
author
Sebastian Andrzej Siewior
committed
RCU: skip the "schedule() in RCU section" warning on UP, too
In "RCU: we need to skip that warning but only on sleeping locks" we skipped a warning on SMP systems in case we schedule out in a RCU section while attempt to obtain a sleeping lock. This is also required on UP systems. In order to do so, I introduce a tiny version of migrate_disable() + _enable() which only update the counters which we then can check against on RT && !SMP. Cc: [email protected] Reported-by: Grygorii Strashko <[email protected]> Tested-by: Grygorii Strashko <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
1 parent 531cf6e commit 589f22c

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed

include/linux/preempt.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,15 @@ extern void migrate_enable(void);
211211

212212
int __migrate_disabled(struct task_struct *p);
213213

214+
#elif !defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
215+
216+
extern void migrate_disable(void);
217+
extern void migrate_enable(void);
218+
static inline int __migrate_disabled(struct task_struct *p)
219+
{
220+
return 0;
221+
}
222+
214223
#else
215224
#define migrate_disable() barrier()
216225
#define migrate_enable() barrier()

include/linux/sched.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,12 @@ struct task_struct {
591591
# ifdef CONFIG_SCHED_DEBUG
592592
int migrate_disable_atomic;
593593
# endif
594+
595+
#elif !defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
596+
int migrate_disable;
597+
# ifdef CONFIG_SCHED_DEBUG
598+
int migrate_disable_atomic;
599+
# endif
594600
#endif
595601

596602
#ifdef CONFIG_PREEMPT_RCU

kernel/rcu/tree_plugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ static void rcu_preempt_note_context_switch(bool preempt)
326326
int mg_counter = 0;
327327

328328
RCU_LOCKDEP_WARN(!irqs_disabled(), "rcu_preempt_note_context_switch() invoked with interrupts enabled!!!\n");
329-
#if defined(CONFIG_PREEMPT_COUNT) && defined(CONFIG_SMP)
329+
#if defined(CONFIG_PREEMPT_RT_BASE)
330330
mg_counter = t->migrate_disable;
331331
#endif
332332
WARN_ON_ONCE(!preempt && t->rcu_read_lock_nesting > 0 && !mg_counter);

kernel/sched/core.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7020,4 +7020,49 @@ void migrate_enable(void)
70207020
preempt_enable();
70217021
}
70227022
EXPORT_SYMBOL(migrate_enable);
7023+
7024+
#elif !defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
7025+
void migrate_disable(void)
7026+
{
7027+
struct task_struct *p = current;
7028+
7029+
if (in_atomic() || irqs_disabled()) {
7030+
#ifdef CONFIG_SCHED_DEBUG
7031+
p->migrate_disable_atomic++;
7032+
#endif
7033+
return;
7034+
}
7035+
#ifdef CONFIG_SCHED_DEBUG
7036+
if (unlikely(p->migrate_disable_atomic)) {
7037+
tracing_off();
7038+
WARN_ON_ONCE(1);
7039+
}
7040+
#endif
7041+
7042+
p->migrate_disable++;
7043+
}
7044+
EXPORT_SYMBOL(migrate_disable);
7045+
7046+
void migrate_enable(void)
7047+
{
7048+
struct task_struct *p = current;
7049+
7050+
if (in_atomic() || irqs_disabled()) {
7051+
#ifdef CONFIG_SCHED_DEBUG
7052+
p->migrate_disable_atomic--;
7053+
#endif
7054+
return;
7055+
}
7056+
7057+
#ifdef CONFIG_SCHED_DEBUG
7058+
if (unlikely(p->migrate_disable_atomic)) {
7059+
tracing_off();
7060+
WARN_ON_ONCE(1);
7061+
}
7062+
#endif
7063+
7064+
WARN_ON_ONCE(p->migrate_disable <= 0);
7065+
p->migrate_disable--;
7066+
}
7067+
EXPORT_SYMBOL(migrate_enable);
70237068
#endif

0 commit comments

Comments
 (0)