Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 232416
b: refs/heads/master
c: 52dbb90
h: refs/heads/master
v: v3
  • Loading branch information
KAMEZAWA Hiroyuki authored and Linus Torvalds committed Jan 26, 2011
1 parent c64e262 commit bdb4af6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3d37c4a9199920964ffdfaec6335d93b9dcf9ca5
refs/heads/master: 52dbb9050936fd33ceb45f10529dbc992507c058
25 changes: 16 additions & 9 deletions trunk/mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -2236,7 +2236,12 @@ static int mem_cgroup_move_account(struct page_cgroup *pc,
{
int ret = -EINVAL;
unsigned long flags;

/*
* The page is isolated from LRU. So, collapse function
* will not handle this page. But page splitting can happen.
* Do this check under compound_page_lock(). The caller should
* hold it.
*/
if ((charge_size > PAGE_SIZE) && !PageTransHuge(pc->page))
return -EBUSY;

Expand Down Expand Up @@ -2268,7 +2273,7 @@ static int mem_cgroup_move_parent(struct page_cgroup *pc,
struct cgroup *cg = child->css.cgroup;
struct cgroup *pcg = cg->parent;
struct mem_cgroup *parent;
int charge = PAGE_SIZE;
int page_size = PAGE_SIZE;
unsigned long flags;
int ret;

Expand All @@ -2281,22 +2286,24 @@ static int mem_cgroup_move_parent(struct page_cgroup *pc,
goto out;
if (isolate_lru_page(page))
goto put;
/* The page is isolated from LRU and we have no race with splitting */
charge = PAGE_SIZE << compound_order(page);

if (PageTransHuge(page))
page_size = HPAGE_SIZE;

parent = mem_cgroup_from_cont(pcg);
ret = __mem_cgroup_try_charge(NULL, gfp_mask, &parent, false, charge);
ret = __mem_cgroup_try_charge(NULL, gfp_mask,
&parent, false, page_size);
if (ret || !parent)
goto put_back;

if (charge > PAGE_SIZE)
if (page_size > PAGE_SIZE)
flags = compound_lock_irqsave(page);

ret = mem_cgroup_move_account(pc, child, parent, true, charge);
ret = mem_cgroup_move_account(pc, child, parent, true, page_size);
if (ret)
mem_cgroup_cancel_charge(parent, charge);
mem_cgroup_cancel_charge(parent, page_size);

if (charge > PAGE_SIZE)
if (page_size > PAGE_SIZE)
compound_unlock_irqrestore(page, flags);
put_back:
putback_lru_page(page);
Expand Down

0 comments on commit bdb4af6

Please sign in to comment.