Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

maple_tree: introduce {mtree,mas}_lock_nested()

In some cases, nested locks may be needed, so {mtree,mas}_lock_nested is
introduced. For example, when duplicating maple tree, we need to hold the
locks of two trees, in which case nested locks are needed.

At the same time, add the definition of spin_lock_nested() in tools for
testing.

Link: https://lkml.kernel.org/r/20231027033845.90608-3-zhangpeng.00@bytedance.com
Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Mateusz Guzik <mjguzik@gmail.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Mike Christie <michael.christie@oracle.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Peng Zhang and committed by
Andrew Morton
b2472efe 4f2267b5

+5
+4
include/linux/maple_tree.h
··· 256 256 struct maple_tree name = MTREE_INIT(name, 0) 257 257 258 258 #define mtree_lock(mt) spin_lock((&(mt)->ma_lock)) 259 + #define mtree_lock_nested(mas, subclass) \ 260 + spin_lock_nested((&(mt)->ma_lock), subclass) 259 261 #define mtree_unlock(mt) spin_unlock((&(mt)->ma_lock)) 260 262 261 263 /* ··· 408 406 }; 409 407 410 408 #define mas_lock(mas) spin_lock(&((mas)->tree->ma_lock)) 409 + #define mas_lock_nested(mas, subclass) \ 410 + spin_lock_nested(&((mas)->tree->ma_lock), subclass) 411 411 #define mas_unlock(mas) spin_unlock(&((mas)->tree->ma_lock)) 412 412 413 413
+1
tools/include/linux/spinlock.h
··· 11 11 #define spin_lock_init(x) pthread_mutex_init(x, NULL) 12 12 13 13 #define spin_lock(x) pthread_mutex_lock(x) 14 + #define spin_lock_nested(x, subclass) pthread_mutex_lock(x) 14 15 #define spin_unlock(x) pthread_mutex_unlock(x) 15 16 #define spin_lock_bh(x) pthread_mutex_lock(x) 16 17 #define spin_unlock_bh(x) pthread_mutex_unlock(x)