[PATCH 24/28] list_lru.h: move declarations to list_lru_types.h

From: Max Kellermann
Date: Wed Jan 31 2024 - 09:55:24 EST


By providing declarations in a lean header, we can reduce header
dependencies.

Signed-off-by: Max Kellermann <max.kellermann@xxxxxxxxx>
---
fs/super.c | 1 +
include/linux/fs.h | 2 +-
include/linux/list_lru.h | 36 +----------------------------
include/linux/list_lru_types.h | 42 ++++++++++++++++++++++++++++++++++
4 files changed, 45 insertions(+), 36 deletions(-)
create mode 100644 include/linux/list_lru_types.h

diff --git a/fs/super.c b/fs/super.c
index d35e85295489..a1d4d9dfa79a 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -33,6 +33,7 @@
#include <linux/rculist_bl.h>
#include <linux/fscrypt.h>
#include <linux/fsnotify.h>
+#include <linux/list_lru.h>
#include <linux/lockdep.h>
#include <linux/user_namespace.h>
#include <linux/fs_context.h>
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7b37a22c9513..06eda3a4fb52 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -10,7 +10,7 @@
#include <linux/stat.h>
#include <linux/cache.h>
#include <linux/list.h>
-#include <linux/list_lru.h>
+#include <linux/list_lru_types.h>
#include <linux/llist.h>
#include <linux/xarray.h>
#include <linux/rbtree.h>
diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h
index bf0b71faa059..3a72e8cde939 100644
--- a/include/linux/list_lru.h
+++ b/include/linux/list_lru.h
@@ -8,14 +8,10 @@
#ifndef _LRU_LIST_H
#define _LRU_LIST_H

-#include <linux/list.h>
+#include <linux/list_lru_types.h>
#include <linux/nodemask.h>
#include <linux/shrinker.h>

-#ifdef CONFIG_MEMCG_KMEM
-#include <linux/xarray_types.h>
-#endif
-
struct mem_cgroup;

/* list_lru_walk_cb has to always return one of those */
@@ -29,36 +25,6 @@ enum lru_status {
internally, but has to return locked. */
};

-struct list_lru_one {
- struct list_head list;
- /* may become negative during memcg reparenting */
- long nr_items;
-};
-
-struct list_lru_memcg {
- struct rcu_head rcu;
- /* array of per cgroup per node lists, indexed by node id */
- struct list_lru_one node[];
-};
-
-struct list_lru_node {
- /* protects all lists on the node, including per cgroup */
- spinlock_t lock;
- /* global list, used for the root cgroup in cgroup aware lrus */
- struct list_lru_one lru;
- long nr_items;
-} ____cacheline_aligned_in_smp;
-
-struct list_lru {
- struct list_lru_node *node;
-#ifdef CONFIG_MEMCG_KMEM
- struct list_head list;
- int shrinker_id;
- bool memcg_aware;
- struct xarray xa;
-#endif
-};
-
void list_lru_destroy(struct list_lru *lru);
int __list_lru_init(struct list_lru *lru, bool memcg_aware,
struct lock_class_key *key, struct shrinker *shrinker);
diff --git a/include/linux/list_lru_types.h b/include/linux/list_lru_types.h
new file mode 100644
index 000000000000..51ccef0d6994
--- /dev/null
+++ b/include/linux/list_lru_types.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LRU_LIST_TYPES_H
+#define _LRU_LIST_TYPES_H
+
+#include <linux/list.h>
+
+#ifdef CONFIG_MEMCG_KMEM
+#include <linux/types.h> // for bool
+#include <linux/xarray_types.h>
+#endif
+
+struct list_lru_one {
+ struct list_head list;
+ /* may become negative during memcg reparenting */
+ long nr_items;
+};
+
+struct list_lru_memcg {
+ struct rcu_head rcu;
+ /* array of per cgroup per node lists, indexed by node id */
+ struct list_lru_one node[];
+};
+
+struct list_lru_node {
+ /* protects all lists on the node, including per cgroup */
+ spinlock_t lock;
+ /* global list, used for the root cgroup in cgroup aware lrus */
+ struct list_lru_one lru;
+ long nr_items;
+} ____cacheline_aligned_in_smp;
+
+struct list_lru {
+ struct list_lru_node *node;
+#ifdef CONFIG_MEMCG_KMEM
+ struct list_head list;
+ int shrinker_id;
+ bool memcg_aware;
+ struct xarray xa;
+#endif
+};
+
+#endif /* _LRU_LIST_TYPES_H */
--
2.39.2