The patch titled Subject: mm/list_lru.c: set bit in memcg shrinker bitmap on first list_lru item appearance has been added to the -mm tree. Its filename is mm-set-bit-in-memcg-shrinker-bitmap-on-first-list_lru-item-apearance.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-set-bit-in-memcg-shrinker-bitmap-on-first-list_lru-item-apearance.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-set-bit-in-memcg-shrinker-bitmap-on-first-list_lru-item-apearance.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Kirill Tkhai <ktkhai@xxxxxxxxxxxxx> Subject: mm/list_lru.c: set bit in memcg shrinker bitmap on first list_lru item appearance Introduce set_shrinker_bit() to set shrinker-related bit in memcg shrinker bitmap, and set the bit after the first item is added and in case of reparenting destroyed memcg's items. This will allow next patch to make shrinkers be called only, in case of they have charged objects at the moment, and to improve shrink_slab() performance. Link: http://lkml.kernel.org/r/153063065671.1818.15914674956134687268.stgit@localhost.localdomain Signed-off-by: Kirill Tkhai <ktkhai@xxxxxxxxxxxxx> Acked-by: Vladimir Davydov <vdavydov.dev@xxxxxxxxx> Tested-by: Shakeel Butt <shakeelb@xxxxxxxxxx> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx> Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Cc: Guenter Roeck <linux@xxxxxxxxxxxx> Cc: "Huang, Ying" <ying.huang@xxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Josef Bacik <jbacik@xxxxxx> Cc: Li RongQing <lirongqing@xxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Matthias Kaehlcke <mka@xxxxxxxxxxxx> Cc: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Minchan Kim <minchan@xxxxxxxxxx> Cc: Philippe Ombredanne <pombredanne@xxxxxxxx> Cc: Roman Gushchin <guro@xxxxxx> Cc: Sahitya Tummala <stummala@xxxxxxxxxxxxxx> Cc: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx> Cc: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Cc: Waiman Long <longman@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/memcontrol.h | 14 ++++++++++++++ mm/list_lru.c | 22 ++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff -puN include/linux/memcontrol.h~mm-set-bit-in-memcg-shrinker-bitmap-on-first-list_lru-item-apearance include/linux/memcontrol.h --- a/include/linux/memcontrol.h~mm-set-bit-in-memcg-shrinker-bitmap-on-first-list_lru-item-apearance +++ a/include/linux/memcontrol.h @@ -1273,6 +1273,18 @@ static inline int memcg_cache_id(struct extern int memcg_expand_shrinker_maps(int new_id); +static inline void memcg_set_shrinker_bit(struct mem_cgroup *memcg, + int nid, int shrinker_id) +{ + if (shrinker_id >= 0 && memcg && !mem_cgroup_is_root(memcg)) { + struct memcg_shrinker_map *map; + + rcu_read_lock(); + map = rcu_dereference(memcg->nodeinfo[nid]->shrinker_map); + set_bit(shrinker_id, map->map); + rcu_read_unlock(); + } +} #else #define for_each_memcg_cache_index(_idx) \ for (; NULL; ) @@ -1295,6 +1307,8 @@ static inline void memcg_put_cache_ids(v { } +static inline void memcg_set_shrinker_bit(struct mem_cgroup *memcg, + int nid, int shrinker_id) { } #endif /* CONFIG_MEMCG_KMEM */ #endif /* _LINUX_MEMCONTROL_H */ diff -puN mm/list_lru.c~mm-set-bit-in-memcg-shrinker-bitmap-on-first-list_lru-item-apearance mm/list_lru.c --- a/mm/list_lru.c~mm-set-bit-in-memcg-shrinker-bitmap-on-first-list_lru-item-apearance +++ a/mm/list_lru.c @@ -30,6 +30,11 @@ static void list_lru_unregister(struct l mutex_unlock(&list_lrus_mutex); } +static int lru_shrinker_id(struct list_lru *lru) +{ + return lru->shrinker_id; +} + static inline bool list_lru_memcg_aware(struct list_lru *lru) { /* @@ -93,6 +98,11 @@ static void list_lru_unregister(struct l { } +static int lru_shrinker_id(struct list_lru *lru) +{ + return -1; +} + static inline bool list_lru_memcg_aware(struct list_lru *lru) { return false; @@ -118,13 +128,17 @@ bool list_lru_add(struct list_lru *lru, { int nid = page_to_nid(virt_to_page(item)); struct list_lru_node *nlru = &lru->node[nid]; + struct mem_cgroup *memcg; struct list_lru_one *l; spin_lock(&nlru->lock); if (list_empty(item)) { - l = list_lru_from_kmem(nlru, item, NULL); + l = list_lru_from_kmem(nlru, item, &memcg); list_add_tail(item, &l->list); - l->nr_items++; + /* Set shrinker bit if the first element was added */ + if (!l->nr_items++) + memcg_set_shrinker_bit(memcg, nid, + lru_shrinker_id(lru)); nlru->nr_items++; spin_unlock(&nlru->lock); return true; @@ -513,6 +527,7 @@ static void memcg_drain_list_lru_node(st struct list_lru_node *nlru = &lru->node[nid]; int dst_idx = dst_memcg->kmemcg_id; struct list_lru_one *src, *dst; + bool set; /* * Since list_lru_{add,del} may be called under an IRQ-safe lock, @@ -524,7 +539,10 @@ static void memcg_drain_list_lru_node(st dst = list_lru_from_memcg_idx(nlru, dst_idx); list_splice_init(&src->list, &dst->list); + set = (!dst->nr_items && src->nr_items); dst->nr_items += src->nr_items; + if (set) + memcg_set_shrinker_bit(dst_memcg, nid, lru_shrinker_id(lru)); src->nr_items = 0; spin_unlock_irq(&nlru->lock); _ Patches currently in -mm which might be from ktkhai@xxxxxxxxxxxxx are memcg-remove-memcg_cgroup-id-from-idr-on-mem_cgroup_css_alloc-failure.patch list_lru-combine-code-under-the-same-define.patch mm-introduce-config_memcg_kmem-as-combination-of-config_memcg-config_slob.patch mm-assign-id-to-every-memcg-aware-shrinker.patch memcg-move-up-for_each_mem_cgroup-_tree-defines.patch mm-assign-memcg-aware-shrinkers-bitmap-to-memcg.patch mm-refactoring-in-workingset_init.patch fs-refactoring-in-alloc_super.patch fs-propagate-shrinker-id-to-list_lru.patch list_lru-add-memcg-argument-to-list_lru_from_kmem.patch list_lru-pass-dst_memcg-argument-to-memcg_drain_list_lru_node.patch list_lru-pass-lru-argument-to-memcg_drain_list_lru_node.patch mm-export-mem_cgroup_is_root.patch mm-set-bit-in-memcg-shrinker-bitmap-on-first-list_lru-item-apearance.patch mm-iterate-only-over-charged-shrinkers-during-memcg-shrink_slab.patch mm-add-shrink_empty-shrinker-methods-return-value.patch mm-clear-shrinker-bit-if-there-are-no-objects-related-to-memcg.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html