Skip to contentSkip to conversation

memcg: remove NULL check from lookup_page_cgroup() result

RFC PATCH In review Johannes Weiner 2 participants 2 messages Feb 3, 2011 – Feb 4, 2011

Subsystems (2)
lore
Share & tools
lore

Johannes Weiner

author maintainer
#0 lore raw

RFC PATCH 1/1 memcg: remove NULL check from lookup_page_cgroup() result

The page_cgroup array is set up before even fork is initialized. I seriously doubt that this code executes before the array is alloc'd.

---
 mm/memcontrol.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
mm/memcontrol.c +1 -4
index a145c9e..6abaa10 100644
@@ -2343,10 +2343,7 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm,
 	}
 
 	pc = lookup_page_cgroup(page);
-	/* can happen at boot */
-	if (unlikely(!pc))
-		return 0;
-	prefetchw(pc);
+	BUG_ON(!pc); /* XXX: remove this and move pc lookup into commit */
 
 	ret = __mem_cgroup_try_charge(mm, gfp_mask, &mem, oom, page_size);
 	if (ret || !mem)
Signature · 8 lines
1.7.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · On Thu, 3 Feb 2011 15:12:30 +0100 Johannes Weiner <[email protected]> wrote:

The page_cgroup array is set up before even fork is initialized. I seriously doubt that this code executes before the array is alloc'd.

I don't have solid answer to this. If some module use radix-tree and enter pages to it, mem_cgroup may see it. But..

For my opinion, tring this is good.

Quoted 23 lines
---
 mm/memcontrol.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
mm/memcontrol.c +1 -4
index a145c9e..6abaa10 100644
@@ -2343,10 +2343,7 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm,
 	}
 
 	pc = lookup_page_cgroup(page);
-	/* can happen at boot */
-	if (unlikely(!pc))
-		return 0;
-	prefetchw(pc);
+	BUG_ON(!pc); /* XXX: remove this and move pc lookup into commit */
 
 	ret = __mem_cgroup_try_charge(mm, gfp_mask, &mem, oom, page_size);
 	if (ret || !mem)
Signature · 1 line
1.7.4