Commit c92e8e10 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Linus Torvalds

fs: propagate shrinker::id to list_lru

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

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.

Link: default avatarKirill Tkhai <>
Acked-by: Vladimir Davydov's avatarVladimir Davydov <>
Tested-by: default avatarShakeel Butt <>
Cc: Al Viro <>
Cc: Andrey Ryabinin <>
Cc: Chris Wilson <>
Cc: Greg Kroah-Hartman <>
Cc: Guenter Roeck <>
Cc: "Huang, Ying" <>
Cc: Johannes Weiner <>
Cc: Josef Bacik <>
Cc: Li RongQing <>
Cc: Matthew Wilcox <>
Cc: Matthias Kaehlcke <>
Cc: Mel Gorman <>
Cc: Michal Hocko <>
Cc: Minchan Kim <>
Cc: Philippe Ombredanne <>
Cc: Roman Gushchin <>
Cc: Sahitya Tummala <>
Cc: Stephen Rothwell <>
Cc: Tetsuo Handa <>
Cc: Thomas Gleixner <>
Cc: Waiman Long <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 2b3648a6
......@@ -261,9 +261,9 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags,
if (prealloc_shrinker(&s->s_shrink))
goto fail;
if (list_lru_init_memcg(&s->s_dentry_lru))
if (list_lru_init_memcg(&s->s_dentry_lru, &s->s_shrink))
goto fail;
if (list_lru_init_memcg(&s->s_inode_lru))
if (list_lru_init_memcg(&s->s_inode_lru, &s->s_shrink))
goto fail;
return s;
......@@ -53,16 +53,20 @@ struct list_lru {
struct list_lru_node *node;
struct list_head list;
int shrinker_id;
void list_lru_destroy(struct list_lru *lru);
int __list_lru_init(struct list_lru *lru, bool memcg_aware,
struct lock_class_key *key);
#define list_lru_init(lru) __list_lru_init((lru), false, NULL)
#define list_lru_init_key(lru, key) __list_lru_init((lru), false, (key))
#define list_lru_init_memcg(lru) __list_lru_init((lru), true, NULL)
struct lock_class_key *key, struct shrinker *shrinker);
#define list_lru_init(lru) \
__list_lru_init((lru), false, NULL, NULL)
#define list_lru_init_key(lru, key) \
__list_lru_init((lru), false, (key), NULL)
#define list_lru_init_memcg(lru, shrinker) \
__list_lru_init((lru), true, NULL, shrinker)
int memcg_update_all_list_lrus(int num_memcgs);
void memcg_drain_all_list_lrus(int src_idx, int dst_idx);
......@@ -546,12 +546,18 @@ static void memcg_destroy_list_lru(struct list_lru *lru)
#endif /* CONFIG_MEMCG_KMEM */
int __list_lru_init(struct list_lru *lru, bool memcg_aware,
struct lock_class_key *key)
struct lock_class_key *key, struct shrinker *shrinker)
int i;
size_t size = sizeof(*lru->node) * nr_node_ids;
int err = -ENOMEM;
if (shrinker)
lru->shrinker_id = shrinker->id;
lru->shrinker_id = -1;
lru->node = kzalloc(size, GFP_KERNEL);
......@@ -594,6 +600,9 @@ void list_lru_destroy(struct list_lru *lru)
lru->node = NULL;
lru->shrinker_id = -1;
......@@ -526,7 +526,8 @@ static int __init workingset_init(void)
ret = prealloc_shrinker(&workingset_shadow_shrinker);
if (ret)
goto err;
ret = __list_lru_init(&shadow_nodes, true, &shadow_nodes_key);
ret = __list_lru_init(&shadow_nodes, true, &shadow_nodes_key,
if (ret)
goto err_list_lru;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment