The commit is pushed to "branch-rh8-4.18.0-80.1.2.vz8.3.x-ovz" and will appear 
at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-80.1.2.vz8.3.4
------>
commit 01e2cd461c5e33776b111dc3c1ed6c5ea340357f
Author: Kirill Tkhai <ktk...@virtuozzo.com>
Date:   Thu Apr 2 17:12:35 2020 +0300

    fs: propagate shrinker::id to list_lru
    
    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.
    
    Link: 
http://lkml.kernel.org/r/153063059758.1818.14866596416857717800.stgit@localhost.localdomain
    Signed-off-by: Kirill Tkhai <ktk...@virtuozzo.com>
    
    Acked-by: Vladimir Davydov <vdavydov....@gmail.com>
    Tested-by: Shakeel Butt <shake...@google.com>
    Cc: Al Viro <v...@zeniv.linux.org.uk>
    Cc: Andrey Ryabinin <aryabi...@virtuozzo.com>
    Cc: Chris Wilson <ch...@chris-wilson.co.uk>
    Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
    Cc: Guenter Roeck <li...@roeck-us.net>
    Cc: "Huang, Ying" <ying.hu...@intel.com>
    Cc: Johannes Weiner <han...@cmpxchg.org>
    Cc: Josef Bacik <jba...@fb.com>
    Cc: Li RongQing <lirongq...@baidu.com>
    Cc: Matthew Wilcox <wi...@infradead.org>
    Cc: Matthias Kaehlcke <m...@chromium.org>
    Cc: Mel Gorman <mgor...@techsingularity.net>
    Cc: Michal Hocko <mho...@kernel.org>
    Cc: Minchan Kim <minc...@kernel.org>
    Cc: Philippe Ombredanne <pombreda...@nexb.com>
    Cc: Roman Gushchin <g...@fb.com>
    Cc: Sahitya Tummala <stumm...@codeaurora.org>
    Cc: Stephen Rothwell <s...@canb.auug.org.au>
    Cc: Tetsuo Handa <penguin-ker...@i-love.sakura.ne.jp>
    Cc: Thomas Gleixner <t...@linutronix.de>
    Cc: Waiman Long <long...@redhat.com>
    Signed-off-by: Andrew Morton <a...@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torva...@linux-foundation.org>
    (cherry picked from commit c92e8e10cafeaaedc84f23fed1bfcf9cf07399c2)
    Signed-off-by: Andrey Ryabinin <aryabi...@virtuozzo.com>
---
 fs/super.c               |  4 ++--
 include/linux/list_lru.h | 14 +++++++++-----
 mm/list_lru.c            | 11 ++++++++++-
 mm/workingset.c          |  3 ++-
 4 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/fs/super.c b/fs/super.c
index f509d820121f..3de936dc49e8 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -284,9 +284,9 @@ static struct super_block *alloc_super(struct 
file_system_type *type, int flags,
        s->s_shrink.flags = SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE;
        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;
 
diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h
index 2d23b5b745be..9e75bb33766b 100644
--- a/include/linux/list_lru.h
+++ b/include/linux/list_lru.h
@@ -53,16 +53,20 @@ struct list_lru {
        struct list_lru_node    *node;
 #ifdef CONFIG_MEMCG_KMEM
        struct list_head        list;
+       int                     shrinker_id;
 #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);
-
-#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);
diff --git a/mm/list_lru.c b/mm/list_lru.c
index 7621084d5a7d..077956f8d58f 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -552,12 +552,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;
 
+#ifdef CONFIG_MEMCG_KMEM
+       if (shrinker)
+               lru->shrinker_id = shrinker->id;
+       else
+               lru->shrinker_id = -1;
+#endif
        memcg_get_cache_ids();
 
        lru->node = kzalloc(size, GFP_KERNEL);
@@ -600,6 +606,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);
diff --git a/mm/workingset.c b/mm/workingset.c
index 1eec3e4f2c42..c3a7a9f58428 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -595,7 +595,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,
+                             &workingset_shadow_shrinker);
        if (ret)
                goto err_list_lru;
        register_shrinker_prepared(&workingset_shadow_shrinker);
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to