[04/13] fs: propagate shrinker::id to list_lru

Submitted by Kirill Tkhai on Aug. 28, 2018, 11:31 a.m.

Details

Message ID 153545591622.14565.4470644690529661760.stgit@localhost.localdomain
State New
Series "Port "Improve shrink_slab() scalability" patchset"
Headers show

Commit Message

Kirill Tkhai Aug. 28, 2018, 11:31 a.m.
ms commit c92e8e10cafe (modified)

Add list_lru::shrinker_id field and populate it by registered shrinker id.

This will be used to set correct bit in memcg shrinkers map by lru code
in next patches, after there appeared the first related to memcg element
in list_lru.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 fs/super.c               |    3 +++
 include/linux/list_lru.h |    1 +
 mm/list_lru.c            |    7 +++++++
 3 files changed, 11 insertions(+)

Patch hide | download patch | download mbox

diff --git a/fs/super.c b/fs/super.c
index 7e6352370a45..162ca145940f 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -543,6 +543,9 @@  struct super_block *sget_userns(struct file_system_type *type,
 		deactivate_locked_super(s);
 		s = ERR_PTR(err);
 	}
+
+	s->s_dentry_lru.shrinker_id = s->s_shrink.id;
+	s->s_inode_lru.shrinker_id = s->s_shrink.id;
 	return s;
 }
 
diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h
index 00a339b9415d..aee40a87360c 100644
--- a/include/linux/list_lru.h
+++ b/include/linux/list_lru.h
@@ -51,6 +51,7 @@  struct list_lru {
 	struct list_lru_node	*node;
 #ifdef CONFIG_MEMCG_KMEM
 	struct list_head	list;
+	int			shrinker_id;
 #endif
 };
 
diff --git a/mm/list_lru.c b/mm/list_lru.c
index 91dccc1e30bf..514a862717c5 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -543,6 +543,10 @@  int __list_lru_init(struct list_lru *lru, bool memcg_aware,
 
 	memcg_get_cache_ids();
 
+#ifdef CONFIG_MEMCG_KMEM
+	lru->shrinker_id = -1;
+#endif
+
 	lru->node = kzalloc(size, GFP_KERNEL);
 	if (!lru->node)
 		goto out;
@@ -583,6 +587,9 @@  void list_lru_destroy(struct list_lru *lru)
 	kfree(lru->node);
 	lru->node = NULL;
 
+#ifdef CONFIG_MEMCG_KMEM
+	lru->shrinker_id = -1;
+#endif
 	memcg_put_cache_ids();
 }
 EXPORT_SYMBOL_GPL(list_lru_destroy);