> On May 2, 2018, at 10:30 AM, Peter Zijlstra <[email protected]> wrote:
>
> On Wed, May 02, 2018 at 04:48:32PM +0000, Song Liu wrote:
>>> It's broken though, I've bet you've never actually ran this with lockdep
>>> enabled for example.
>>
>> I am not following here. I just run the new selftest with CONFIG_LOCKDEP on,
>> and got no warning for this.
>
> Weird, I would be expecting complaints about releasing an unheld lock.
>
> nmi_enter(),nmi_exit() have lockdep_off(),lockdep_on() resp. Which means
> that the down_trylock() will not be recorded. The up, which is done from
> IRQ context, will not be so supressed and should hit
> print_unlock_imbalance_bug().
>
I am still not sure whether I am following. I guess your concern apply to
spinlock only? lock_acquire() has the following in the beginning:
if (unlikely(current->lockdep_recursion))
return;
So it will not run in nmi context?
On the other hand, semaphore and rw_semaphore should be ok in such cases?
Thanks,
Song