Re: [PATCH v3] kunit: added lockdep support

From: Uriel Guajardo
Date: Fri Aug 14 2020 - 17:00:20 EST


On Fri, Aug 14, 2020 at 3:58 PM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> On Fri, Aug 14, 2020 at 08:55:27PM +0000, Uriel Guajardo wrote:
> > +
> > +void kunit_check_lockdep(struct kunit *test, struct kunit_lockdep *lockdep) {
> > + int saved_preempt_count = lockdep->preempt_count;
> > + bool saved_debug_locks = lockdep->debug_locks;
> > +
> > + if (DEBUG_LOCKS_WARN_ON(preempt_count() != saved_preempt_count))
> > + preempt_count_set(saved_preempt_count);
> > +
> > +#ifdef CONFIG_TRACE_IRQFLAGS
> > + if (softirq_count())
> > + current->softirqs_enabled = 0;
> > + else
> > + current->softirqs_enabled = 1;
> > +#endif
>
> This block is pointless. The only way to get softirq tracing out of sync
> is an unbalanced local_bh_disable(), but then the above preempt_count()
> test will trigger and kill IRQ tracing.

Ahh I see. Thank you.

>
> > +
> > + if (saved_debug_locks && !debug_locks) {
> > + kunit_set_failure(test);
> > + kunit_warn(test, "Dynamic analysis tool failure from LOCKDEP.");
> > + kunit_warn(test, "Further tests will have LOCKDEP disabled.");
> > + }
> > +}