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