[Devel] [PATCH RHEL7 COMMIT] mm/tcache: make tcache work again

Konstantin Khorenko khorenko at virtuozzo.com
Tue Apr 18 05:51:13 PDT 2017


The commit is pushed to "branch-rh7-3.10.0-514.16.1.vz7.30.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.16.1.vz7.30.2
------>
commit 9b034990d22f69354f686c9dde81c04023d6530d
Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
Date:   Tue Apr 18 16:51:13 2017 +0400

    mm/tcache: make tcache work again
    
    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.
    
    https://jira.sw.ru/browse/PSBM-64725
    
    Signed-off-by: Andrey Ryabinin <aryabinin at 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);
 


More information about the Devel mailing list