Re: [PATCH v2 05/12] nbd: Enable lock context analysis

Bart Van Assche <[email protected]> Mon, 3 Aug 2026 11:03:13 -0700
Newsgroups org.kernel.vger.linux-block
Message-ID <[email protected]>
On 8/3/26 6:26 AM, Nilay Shroff wrote:
> On 7/31/26 1:28 AM, Bart Van Assche wrote:
>> @@ -2773,7 +2776,11 @@ static void __exit nbd_cleanup(void)
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Also wait for nbd_dev_remove_work() =
completes */
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 destroy_workqueue(nbd_del_wq);
>> -=C2=A0=C2=A0=C2=A0 idr_destroy(&nbd_index_idr);
>> +=C2=A0=C2=A0=C2=A0 {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __assume_ctx_lock(&nbd_ind=
ex_mutex);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 idr_destroy(&nbd_index_idr=
);
>> +=C2=A0=C2=A0=C2=A0 }
>> +
>=20
> Could we instead introduce a scoped __assume_ctx_lock() helper so we
> don't need the explicit scope here? Alternatively, would annotating
> nbd_cleanup() with __context_unsafe be a better fit?
There is code in nbd_cleanup() that must be protected by a mutex so I
think that we shouldn't annotate nbd_cleanup() with __context_unsafe().

Introducing a scoped __assume_ctx_lock() might be overkill.

Thanks,

Bart.