Re: [PATCH v2] rhashtable: use private lockdep class for all locks.

From: Herbert Xu

Date: Fri Sep 04 2026 - 06:14:39 EST


On Sat, Aug 15, 2026 at 04:24:07PM +1000, NeilBrown wrote:
>
> This patch builds on
> Commit: 060d4e94b8d4 ("rhashtable: give each instance its own lockdep class")
>
> to allow lockdep to see each rhashtable as unique with respect to all of
> the locks, not just the ht->mutex.
>
> This is needed if rhashtable is to be used tracepoint BPF which could
> run while an rhashtable lock (in a different table) is held - see Link
> below.
>
> Rather then adding extra keys for the other locks, we use distinct
> sub-classes for the different locks.
> rhashtable->lock uses class 0
> rhashtable->mutex uses class 1
> bucket bitlocks, which are the only ones that are ever nested, use
> classes 2 and 3.
>
> Currently rht_lock() and rht_lock_nested() are quite separate code
> despite the near-identical function. This patch moves rht_lock() to
> after rht_lock_nested(), and simply calls that other function with a
> nesting level of zero.
>
> Link: https://lore.kernel.org/all/20260801-fix-rhashtable-bucket-lockdep-v1-1-15a0f8ae094c@xxxxxxxxx/
> Closes: https://syzkaller.appspot.com/bug?extid=ef8d17bae14efb960935
> Tested-by: quanyeyang <quanyeyang@xxxxxxxxx>
> Signed-off-by: NeilBrown <neil@xxxxxxxxxx>
> ---
>
> v2 includes a change to test_rhashtable.c as advised by sashiko.dev
> NeilBrown
>
>
> include/linux/rhashtable-types.h | 3 +++
> include/linux/rhashtable.h | 22 +++++++++-------------
> lib/rhashtable.c | 14 +++++++++++---
> lib/test_rhashtable.c | 2 +-
> 4 files changed, 24 insertions(+), 17 deletions(-)

Patch applied. Thanks.
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt