[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240821230539.168107-5-woodyzhang666@gmail.com>
Date: Thu, 22 Aug 2024 07:05:38 +0800
From: Woody Zhang <woodyzhang666@...il.com>
To: Thomas Gleixner <tglx@...utronix.de>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org,
Woody Zhang <woodyzhang666@...il.com>
Subject: [PATCH 4/5] list_bl: add hlist_bl_move_list and two macros
hlist_bl_move_list is similar to hlist_move_list. Caller should decide
whether bit locking is required for old and new hash list.
Signed-off-by: Woody Zhang <woodyzhang666@...il.com>
---
include/linux/list_bl.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/linux/list_bl.h b/include/linux/list_bl.h
index d25c659f6635..928048354e04 100644
--- a/include/linux/list_bl.h
+++ b/include/linux/list_bl.h
@@ -38,6 +38,8 @@ struct hlist_bl_head {
struct hlist_bl_node {
struct hlist_bl_node *next, **pprev;
};
+#define HLIST_BL_HEAD_INIT { .first = NULL }
+#define HLIST_BL_HEAD(name) struct hlist_bl_head name = { .first = NULL }
#define INIT_HLIST_BL_HEAD(ptr) \
((ptr)->first = NULL)
@@ -142,6 +144,17 @@ static inline void hlist_bl_del_init(struct hlist_bl_node *n)
}
}
+static inline void hlist_bl_move_list(struct hlist_bl_head *old,
+ struct hlist_bl_head *new)
+{
+ struct hlist_bl_node *n = hlist_bl_first(old);
+
+ hlist_bl_set_first(new, n);
+ if (n)
+ n->pprev = &new->first;
+ hlist_bl_set_first(old, NULL);
+}
+
static inline void hlist_bl_lock(struct hlist_bl_head *b)
{
bit_spin_lock(0, (unsigned long *)b);
--
2.45.2
Powered by blists - more mailing lists