[PATCH -mm][preview] memcg: a patch series for next [7/9]

From: KAMEZAWA Hiroyuki
Date: Tue Aug 19 2008 - 04:37:41 EST


mem_cgroup_charge() common has to take lock but the place of lock can
be calculated in early stage. This patch tries to prefetch lock line.
(Have some good effect on my host.)

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
---
mm/memcontrol.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

Index: linux-2.6.27-rc1-mm1/mm/memcontrol.c
===================================================================
--- linux-2.6.27-rc1-mm1.orig/mm/memcontrol.c
+++ linux-2.6.27-rc1-mm1/mm/memcontrol.c
@@ -707,11 +707,14 @@ static int mem_cgroup_charge_common(stru
struct page_cgroup *pc;
unsigned long nr_retries = MEM_CGROUP_RECLAIM_RETRIES;
unsigned long flags;
+ int nid, zid;

pc = kmem_cache_alloc(page_cgroup_cache, gfp_mask);
if (unlikely(pc == NULL))
goto err;

+ nid = page_to_nid(page);
+ zid = page_zonenum(page);
/*
* We always charge the cgroup the mm_struct belongs to.
* The mm_struct's mem_cgroup changes on task migration if the
@@ -753,6 +756,8 @@ static int mem_cgroup_charge_common(stru
goto out;
}
}
+ mz = mem_cgroup_zoneinfo(mem, nid, zid);
+ prefetchw(mz);

pc->mem_cgroup = mem;
pc->page = page;
@@ -773,7 +778,6 @@ static int mem_cgroup_charge_common(stru

VM_BUG_ON(page->page_cgroup);
page_assign_page_cgroup(page, pc);
- mz = page_cgroup_zoneinfo(pc);
spin_lock_irqsave(&mz->lru_lock, flags);
__mem_cgroup_add_list(mz, pc);
spin_unlock_irqrestore(&mz->lru_lock, flags);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/