[PATCH 25/28] list_bl.h: move declarations to list_bl_types.h
From: Max Kellermann
Date: Wed Jan 31 2024 - 09:55:58 EST
By providing declarations in a lean header, we can reduce header
dependencies.
Signed-off-by: Max Kellermann <max.kellermann@xxxxxxxxx>
---
include/linux/list_bl.h | 19 +-----------------
include/linux/list_bl_types.h | 36 +++++++++++++++++++++++++++++++++++
include/linux/mbcache.h | 2 +-
3 files changed, 38 insertions(+), 19 deletions(-)
create mode 100644 include/linux/list_bl_types.h
diff --git a/include/linux/list_bl.h b/include/linux/list_bl.h
index ae1b541446c9..39c14b6bad71 100644
--- a/include/linux/list_bl.h
+++ b/include/linux/list_bl.h
@@ -2,7 +2,7 @@
#ifndef _LINUX_LIST_BL_H
#define _LINUX_LIST_BL_H
-#include <linux/list.h>
+#include <linux/list_bl_types.h>
#include <linux/bit_spinlock.h>
/*
@@ -30,23 +30,6 @@
#define LIST_BL_BUG_ON(x)
#endif
-
-struct hlist_bl_head {
- struct hlist_bl_node *first;
-};
-
-struct hlist_bl_node {
- struct hlist_bl_node *next, **pprev;
-};
-#define INIT_HLIST_BL_HEAD(ptr) \
- ((ptr)->first = NULL)
-
-static inline void INIT_HLIST_BL_NODE(struct hlist_bl_node *h)
-{
- h->next = NULL;
- h->pprev = NULL;
-}
-
#define hlist_bl_entry(ptr, type, member) container_of(ptr,type,member)
static inline bool hlist_bl_unhashed(const struct hlist_bl_node *h)
diff --git a/include/linux/list_bl_types.h b/include/linux/list_bl_types.h
new file mode 100644
index 000000000000..84229bb7bd02
--- /dev/null
+++ b/include/linux/list_bl_types.h
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_LIST_BL_TYPES_H
+#define _LINUX_LIST_BL_TYPES_H
+
+#include <linux/list.h>
+
+/*
+ * Special version of lists, where head of the list has a lock in the lowest
+ * bit. This is useful for scalable hash tables without increasing memory
+ * footprint overhead.
+ *
+ * For modification operations, the 0 bit of hlist_bl_head->first
+ * pointer must be set.
+ *
+ * With some small modifications, this can easily be adapted to store several
+ * arbitrary bits (not just a single lock bit), if the need arises to store
+ * some fast and compact auxiliary data.
+ */
+
+struct hlist_bl_head {
+ struct hlist_bl_node *first;
+};
+
+struct hlist_bl_node {
+ struct hlist_bl_node *next, **pprev;
+};
+#define INIT_HLIST_BL_HEAD(ptr) \
+ ((ptr)->first = NULL)
+
+static inline void INIT_HLIST_BL_NODE(struct hlist_bl_node *h)
+{
+ h->next = NULL;
+ h->pprev = NULL;
+}
+
+#endif
diff --git a/include/linux/mbcache.h b/include/linux/mbcache.h
index 97e64184767d..32ebbb428053 100644
--- a/include/linux/mbcache.h
+++ b/include/linux/mbcache.h
@@ -3,7 +3,7 @@
#define _LINUX_MBCACHE_H
#include <linux/hash.h>
-#include <linux/list_bl.h>
+#include <linux/list_bl_types.h>
#include <linux/list.h>
#include <linux/atomic.h>
#include <linux/fs.h>
--
2.39.2