linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] mm: memcontrol: micro-optimize mem_cgroup_update_page_stat()
@ 2014-10-20 15:17 Johannes Weiner
  2014-10-20 18:59 ` Michal Hocko
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Weiner @ 2014-10-20 15:17 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Michal Hocko, Vladimir Davydov, linux-mm, cgroups, linux-kernel

Do not look up the page_cgroup when the memory controller is
runtime-disabled, but do assert that the locking protocol is followed
under DEBUG_VM regardless.  Also remove the unused flags variable.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/memcontrol.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 76892eb89d26..bea3fddb3372 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2177,13 +2177,14 @@ void mem_cgroup_update_page_stat(struct page *page,
 				 enum mem_cgroup_stat_index idx, int val)
 {
 	struct mem_cgroup *memcg;
-	struct page_cgroup *pc = lookup_page_cgroup(page);
-	unsigned long uninitialized_var(flags);
+	struct page_cgroup *pc;
+
+	VM_BUG_ON(!rcu_read_lock_held());
 
 	if (mem_cgroup_disabled())
 		return;
 
-	VM_BUG_ON(!rcu_read_lock_held());
+	pc = lookup_page_cgroup(page);
 	memcg = pc->mem_cgroup;
 	if (unlikely(!memcg || !PageCgroupUsed(pc)))
 		return;
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] mm: memcontrol: micro-optimize mem_cgroup_update_page_stat()
  2014-10-20 15:17 [patch] mm: memcontrol: micro-optimize mem_cgroup_update_page_stat() Johannes Weiner
@ 2014-10-20 18:59 ` Michal Hocko
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Hocko @ 2014-10-20 18:59 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Vladimir Davydov, linux-mm, cgroups, linux-kernel

On Mon 20-10-14 11:17:39, Johannes Weiner wrote:
> Do not look up the page_cgroup when the memory controller is
> runtime-disabled, but do assert that the locking protocol is followed
> under DEBUG_VM regardless.  Also remove the unused flags variable.
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Michal Hocko <mhocko@suse.cz>

mem_cgroup_split_huge_fixup is following the same pattern and might be
folded into this one. I can send a separate patch if you prefer, though.
---
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 3a203c7ec6c7..544e32292c7f 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3167,7 +3167,7 @@ static inline void memcg_unregister_all_caches(struct mem_cgroup *memcg)
  */
 void mem_cgroup_split_huge_fixup(struct page *head)
 {
-	struct page_cgroup *head_pc = lookup_page_cgroup(head);
+	struct page_cgroup *head_pc;
 	struct page_cgroup *pc;
 	struct mem_cgroup *memcg;
 	int i;
@@ -3175,6 +3175,8 @@ void mem_cgroup_split_huge_fixup(struct page *head)
 	if (mem_cgroup_disabled())
 		return;
 
+	head_pc = lookup_page_cgroup(head);
+
 	memcg = head_pc->mem_cgroup;
 	for (i = 1; i < HPAGE_PMD_NR; i++) {
 		pc = head_pc + i;
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-10-20 18:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-20 15:17 [patch] mm: memcontrol: micro-optimize mem_cgroup_update_page_stat() Johannes Weiner
2014-10-20 18:59 ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).