Messages in this thread | | | Date | Tue, 26 May 2020 02:52:31 +0200 | From | "Ahmed S. Darwish" <> | Subject | Re: [PATCH v1 07/25] lockdep: Add preemption disabled assertion API |
| |
Peter Zijlstra <peterz@infradead.org> wrote: > On Sun, May 24, 2020 at 12:41:32AM +0200, Peter Zijlstra wrote: > > On Sat, May 23, 2020 at 04:59:42PM +0200, Sebastian A. Siewior wrote: > > > > > > Any "static inline" in the header file using > > > lockdep_assert_preemption_disabled() will tro to complain about missing > > > current-> define. But yes, it will work otherwise. > > > > Because...? /me rummages around.. Ah you're proposing sticking this in > > seqcount itself and then header hell. > > > > Moo.. ok I'll go have another look on Monday. > > How's this? >
This will work for my case as current-> is no longer referenced by the lockdep macros. Please continue below though.
...
> -#define lockdep_assert_irqs_enabled() do { \ > - WARN_ONCE(debug_locks && !current->lockdep_recursion && \ > - !current->hardirqs_enabled, \ > - "IRQs not enabled as expected\n"); \ > - } while (0) > +DECLARE_PER_CPU(int, hardirqs_enabled); > +DECLARE_PER_CPU(int, hardirq_context); > > -#define lockdep_assert_irqs_disabled() do { \ > - WARN_ONCE(debug_locks && !current->lockdep_recursion && \ > - current->hardirqs_enabled, \ > - "IRQs not disabled as expected\n"); \ > - } while (0) > +#define lockdep_assert_irqs_enabled() \ > +do { \ > + WARN_ON_ONCE(debug_locks && !this_cpu_read(hardirqs_enabled)); \ > +} while (0) >
Given that lockdep_off() is defined at lockdep.c as:
void lockdep_off(void) { current->lockdep_recursion += LOCKDEP_OFF; }
This would imply that all of the macros:
- lockdep_assert_irqs_enabled() - lockdep_assert_irqs_disabled() - lockdep_assert_in_irq() - lockdep_assert_preemption_disabled() - lockdep_assert_preemption_enabled()
will do the lockdep checks *even if* lockdep_off() was called.
This doesn't sound right. Even if all of the above macros call sites didn't care about lockdep_off()/on(), it is semantically incoherent.
Thanks,
-- Ahmed S. Darwish Linutronix GmbH
| |