Skip to content

Commit 8bf6c67

Browse files
Sebastian SiewiorPeter Zijlstra
authored andcommitted
completion: Use lockdep_assert_RT_in_threaded_ctx() in complete_all()
The warning was intended to spot complete_all() users from hardirq context on PREEMPT_RT. The warning as-is will also trigger in interrupt handlers, which are threaded on PREEMPT_RT, which was not intended. Use lockdep_assert_RT_in_threaded_ctx() which triggers in non-preemptive context on PREEMPT_RT. Fixes: a5c6234 ("completion: Use simple wait queues") Reported-by: kernel test robot <[email protected]> Suggested-by: Peter Zijlstra <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent d53f2b6 commit 8bf6c67

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

include/linux/lockdep.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,21 @@ do { \
711711
# define lockdep_assert_in_irq() do { } while (0)
712712
#endif
713713

714+
#ifdef CONFIG_PROVE_RAW_LOCK_NESTING
715+
716+
# define lockdep_assert_RT_in_threaded_ctx() do { \
717+
WARN_ONCE(debug_locks && !current->lockdep_recursion && \
718+
current->hardirq_context && \
719+
!(current->hardirq_threaded || current->irq_config), \
720+
"Not in threaded context on PREEMPT_RT as expected\n"); \
721+
} while (0)
722+
723+
#else
724+
725+
# define lockdep_assert_RT_in_threaded_ctx() do { } while (0)
726+
727+
#endif
728+
714729
#ifdef CONFIG_LOCKDEP
715730
void lockdep_rcu_suspicious(const char *file, const int line, const char *s);
716731
#else

kernel/sched/completion.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void complete_all(struct completion *x)
5858
{
5959
unsigned long flags;
6060

61-
WARN_ON(irqs_disabled());
61+
lockdep_assert_RT_in_threaded_ctx();
6262

6363
raw_spin_lock_irqsave(&x->wait.lock, flags);
6464
x->done = UINT_MAX;

0 commit comments

Comments
 (0)