By providing declarations in a lean header, we can reduce header
dependencies.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
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
@@ -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)
new file mode 100644
@@ -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
@@ -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>