All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 103/108] mm: memcontrol: use generic mod_memcg_page_state for kmem pages
@ 2017-07-06 22:40 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2017-07-06 22:40 UTC (permalink / raw)
  To: akpm, hannes, josef, mhocko, mm-commits, riel, torvalds, vdavydov.dev

From: Johannes Weiner <hannes@cmpxchg.org>
Subject: mm: memcontrol: use generic mod_memcg_page_state for kmem pages

The kmem-specific functions do the same thing. Switch and drop.

Link: http://lkml.kernel.org/r/20170530181724.27197-5-hannes@cmpxchg.org
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 include/linux/memcontrol.h |   17 -----------------
 kernel/fork.c              |    8 ++++----
 mm/slab.h                  |   16 ++++++++--------
 3 files changed, 12 insertions(+), 29 deletions(-)

diff -puN include/linux/memcontrol.h~mm-memcontrol-use-generic-mod_memcg_page_state-for-kmem-pages include/linux/memcontrol.h
--- a/include/linux/memcontrol.h~mm-memcontrol-use-generic-mod_memcg_page_state-for-kmem-pages
+++ a/include/linux/memcontrol.h
@@ -929,19 +929,6 @@ static inline int memcg_cache_id(struct
 	return memcg ? memcg->kmemcg_id : -1;
 }
 
-/**
- * memcg_kmem_update_page_stat - update kmem page state statistics
- * @page: the page
- * @idx: page state item to account
- * @val: number of pages (positive or negative)
- */
-static inline void memcg_kmem_update_page_stat(struct page *page,
-				enum memcg_stat_item idx, int val)
-{
-	if (memcg_kmem_enabled() && page->mem_cgroup)
-		this_cpu_add(page->mem_cgroup->stat->count[idx], val);
-}
-
 #else
 #define for_each_memcg_cache_index(_idx)	\
 	for (; NULL; )
@@ -964,10 +951,6 @@ static inline void memcg_put_cache_ids(v
 {
 }
 
-static inline void memcg_kmem_update_page_stat(struct page *page,
-				enum memcg_stat_item idx, int val)
-{
-}
 #endif /* CONFIG_MEMCG && !CONFIG_SLOB */
 
 #endif /* _LINUX_MEMCONTROL_H */
diff -puN kernel/fork.c~mm-memcontrol-use-generic-mod_memcg_page_state-for-kmem-pages kernel/fork.c
--- a/kernel/fork.c~mm-memcontrol-use-generic-mod_memcg_page_state-for-kmem-pages
+++ a/kernel/fork.c
@@ -326,8 +326,8 @@ static void account_kernel_stack(struct
 		}
 
 		/* All stack pages belong to the same memcg. */
-		memcg_kmem_update_page_stat(vm->pages[0], MEMCG_KERNEL_STACK_KB,
-					    account * (THREAD_SIZE / 1024));
+		mod_memcg_page_state(vm->pages[0], MEMCG_KERNEL_STACK_KB,
+				     account * (THREAD_SIZE / 1024));
 	} else {
 		/*
 		 * All stack pages are in the same zone and belong to the
@@ -338,8 +338,8 @@ static void account_kernel_stack(struct
 		mod_zone_page_state(page_zone(first_page), NR_KERNEL_STACK_KB,
 				    THREAD_SIZE / 1024 * account);
 
-		memcg_kmem_update_page_stat(first_page, MEMCG_KERNEL_STACK_KB,
-					    account * (THREAD_SIZE / 1024));
+		mod_memcg_page_state(first_page, MEMCG_KERNEL_STACK_KB,
+				     account * (THREAD_SIZE / 1024));
 	}
 }
 
diff -puN mm/slab.h~mm-memcontrol-use-generic-mod_memcg_page_state-for-kmem-pages mm/slab.h
--- a/mm/slab.h~mm-memcontrol-use-generic-mod_memcg_page_state-for-kmem-pages
+++ a/mm/slab.h
@@ -285,10 +285,10 @@ static __always_inline int memcg_charge_
 	if (ret)
 		return ret;
 
-	memcg_kmem_update_page_stat(page,
-			(s->flags & SLAB_RECLAIM_ACCOUNT) ?
-			NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE,
-			1 << order);
+	mod_memcg_page_state(page,
+			     (s->flags & SLAB_RECLAIM_ACCOUNT) ?
+			     NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE,
+			     1 << order);
 	return 0;
 }
 
@@ -298,10 +298,10 @@ static __always_inline void memcg_unchar
 	if (!memcg_kmem_enabled())
 		return;
 
-	memcg_kmem_update_page_stat(page,
-			(s->flags & SLAB_RECLAIM_ACCOUNT) ?
-			NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE,
-			-(1 << order));
+	mod_memcg_page_state(page,
+			     (s->flags & SLAB_RECLAIM_ACCOUNT) ?
+			     NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE,
+			     -(1 << order));
 	memcg_kmem_uncharge(page, order);
 }
 
_

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-07-06 22:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-06 22:40 [patch 103/108] mm: memcontrol: use generic mod_memcg_page_state for kmem pages akpm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.