Tcache use PF_MEMALLOC to distinguish memcg recalim from global reclaim, but sinche upstream commit 89a2848381b5 ("mm: memcontrol: do not recurse in direct reclaim") this is no longer works as PF_MEMALLOC also set during memcg reclaim.
Add new PF_MEMCG_RECLAIM flag set only during memcg reclaim and use it in tcache to distinguish global recalaim from per-memcg recalim. Signed-off-by: Andrey Ryabinin <aryabi...@virtuozzo.com> --- include/linux/sched.h | 1 + mm/tcache.c | 2 +- mm/vmscan.c | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 8ce9573..69f8368 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2044,6 +2044,7 @@ extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, #define PF_KTHREAD 0x00200000 /* I am a kernel thread */ #define PF_RANDOMIZE 0x00400000 /* randomize virtual address space */ #define PF_SWAPWRITE 0x00800000 /* Allowed to write to swap */ +#define PF_MEMCG_RECLAIM 0x01000000 /* We are in memcg reclaim */ #define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_allowed */ #define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */ #define PF_MEMPOLICY 0x10000000 /* Non-default NUMA mempolicy */ diff --git a/mm/tcache.c b/mm/tcache.c index e15d212..94f0383 100644 --- a/mm/tcache.c +++ b/mm/tcache.c @@ -1145,7 +1145,7 @@ static void tcache_cleancache_put_page(int pool_id, struct page *cache_page = NULL; /* It makes no sense to populate tcache when we are short on memory */ - if (!READ_ONCE(tcache_active) || current->flags & PF_MEMALLOC) + if (!READ_ONCE(tcache_active) || !(current->flags & PF_MEMCG_RECLAIM)) return; node = tcache_get_node_and_pool(pool_id, &key, true); diff --git a/mm/vmscan.c b/mm/vmscan.c index a3a380b..6bf978f 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2955,9 +2955,9 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg, sc.may_writepage, sc.gfp_mask); - current->flags |= PF_MEMALLOC; + current->flags |= PF_MEMALLOC | PF_MEMCG_RECLAIM; nr_reclaimed = do_try_to_free_pages(zonelist, &sc); - current->flags &= ~PF_MEMALLOC; + current->flags &= ~(PF_MEMALLOC | PF_MEMCG_RECLAIM); trace_mm_vmscan_memcg_reclaim_end(nr_reclaimed); -- 2.10.2 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel