[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241024132009.2267260-3-yukuai1@huaweicloud.com>
Date: Thu, 24 Oct 2024 21:19:43 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: stable@...r.kernel.org,
gregkh@...uxfoundation.org,
harry.wentland@....com,
sunpeng.li@....com,
Rodrigo.Siqueira@....com,
alexander.deucher@....com,
christian.koenig@....com,
Xinhui.Pan@....com,
airlied@...il.com,
daniel@...ll.ch,
viro@...iv.linux.org.uk,
brauner@...nel.org,
Liam.Howlett@...cle.com,
akpm@...ux-foundation.org,
hughd@...gle.com,
willy@...radead.org,
sashal@...nel.org,
srinivasan.shanmugam@....com,
chiahsuan.chung@....com,
mingo@...nel.org,
mgorman@...hsingularity.net,
yukuai3@...wei.com,
chengming.zhou@...ux.dev,
zhangpeng.00@...edance.com,
chuck.lever@...cle.com
Cc: amd-gfx@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org,
maple-tree@...ts.infradead.org,
linux-mm@...ck.org,
yukuai1@...weicloud.com,
yi.zhang@...wei.com,
yangerkun@...wei.com
Subject: [PATCH 6.6 02/28] maple_tree: introduce {mtree,mas}_lock_nested()
From: Peng Zhang <zhangpeng.00@...edance.com>
commit b2472efe4316b2687c153919c1513a098bd82c17 upstream.
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@...edance.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@...cle.com>
Cc: Christian Brauner <brauner@...nel.org>
Cc: Jonathan Corbet <corbet@....net>
Cc: Mateusz Guzik <mjguzik@...il.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Cc: Matthew Wilcox <willy@...radead.org>
Cc: Michael S. Tsirkin <mst@...hat.com>
Cc: Mike Christie <michael.christie@...cle.com>
Cc: Nicholas Piggin <npiggin@...il.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Suren Baghdasaryan <surenb@...gle.com>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Yu Kuai <yukuai3@...wei.com>
---
include/linux/maple_tree.h | 4 ++++
tools/include/linux/spinlock.h | 1 +
2 files changed, 5 insertions(+)
diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h
index d01e850b570f..f91dbc7fe091 100644
--- a/include/linux/maple_tree.h
+++ b/include/linux/maple_tree.h
@@ -256,6 +256,8 @@ struct maple_tree {
struct maple_tree name = MTREE_INIT(name, 0)
#define mtree_lock(mt) spin_lock((&(mt)->ma_lock))
+#define mtree_lock_nested(mas, subclass) \
+ spin_lock_nested((&(mt)->ma_lock), subclass)
#define mtree_unlock(mt) spin_unlock((&(mt)->ma_lock))
/*
@@ -406,6 +408,8 @@ struct ma_wr_state {
};
#define mas_lock(mas) spin_lock(&((mas)->tree->ma_lock))
+#define mas_lock_nested(mas, subclass) \
+ spin_lock_nested(&((mas)->tree->ma_lock), subclass)
#define mas_unlock(mas) spin_unlock(&((mas)->tree->ma_lock))
diff --git a/tools/include/linux/spinlock.h b/tools/include/linux/spinlock.h
index 622266b197d0..a6cdf25b6b9d 100644
--- a/tools/include/linux/spinlock.h
+++ b/tools/include/linux/spinlock.h
@@ -11,6 +11,7 @@
#define spin_lock_init(x) pthread_mutex_init(x, NULL)
#define spin_lock(x) pthread_mutex_lock(x)
+#define spin_lock_nested(x, subclass) pthread_mutex_lock(x)
#define spin_unlock(x) pthread_mutex_unlock(x)
#define spin_lock_bh(x) pthread_mutex_lock(x)
#define spin_unlock_bh(x) pthread_mutex_unlock(x)
--
2.39.2
Powered by blists - more mailing lists