Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105906
b: refs/heads/master
c: c9b0ed5
h: refs/heads/master
v: v3
  • Loading branch information
KAMEZAWA Hiroyuki authored and Linus Torvalds committed Jul 25, 2008
1 parent f0100c5 commit 3eee7ee
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 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: 69029cd550284e32de13d6dd2f77b723c8a0e444
refs/heads/master: c9b0ed51483cc2fc42bb801b6675c4231b0e4634
7 changes: 7 additions & 0 deletions trunk/include/linux/memcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
extern void mem_cgroup_uncharge_page(struct page *page);
extern void mem_cgroup_uncharge_cache_page(struct page *page);
extern void mem_cgroup_move_lists(struct page *page, bool active);
extern int mem_cgroup_shrink_usage(struct mm_struct *mm, gfp_t gfp_mask);

extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
struct list_head *dst,
unsigned long *scanned, int order,
Expand Down Expand Up @@ -102,6 +104,11 @@ static inline void mem_cgroup_uncharge_cache_page(struct page *page)
{
}

static inline int mem_cgroup_shrink_usage(struct mm_struct *mm, gfp_t gfp_mask)
{
return 0;
}

static inline void mem_cgroup_move_lists(struct page *page, bool active)
{
}
Expand Down
26 changes: 26 additions & 0 deletions trunk/mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,32 @@ void mem_cgroup_end_migration(struct page *newpage)
mem_cgroup_uncharge_page(newpage);
}

/*
* A call to try to shrink memory usage under specified resource controller.
* This is typically used for page reclaiming for shmem for reducing side
* effect of page allocation from shmem, which is used by some mem_cgroup.
*/
int mem_cgroup_shrink_usage(struct mm_struct *mm, gfp_t gfp_mask)
{
struct mem_cgroup *mem;
int progress = 0;
int retry = MEM_CGROUP_RECLAIM_RETRIES;

rcu_read_lock();
mem = mem_cgroup_from_task(rcu_dereference(mm->owner));
css_get(&mem->css);
rcu_read_unlock();

do {
progress = try_to_free_mem_cgroup_pages(mem, gfp_mask);
} while (!progress && --retry);

css_put(&mem->css);
if (!retry)
return -ENOMEM;
return 0;
}

/*
* This routine traverse page_cgroup in given list and drop them all.
* *And* this routine doesn't reclaim page itself, just removes page_cgroup.
Expand Down
11 changes: 4 additions & 7 deletions trunk/mm/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1315,17 +1315,14 @@ static int shmem_getpage(struct inode *inode, unsigned long idx,
shmem_swp_unmap(entry);
spin_unlock(&info->lock);
unlock_page(swappage);
page_cache_release(swappage);
if (error == -ENOMEM) {
/* allow reclaim from this memory cgroup */
error = mem_cgroup_cache_charge(swappage,
current->mm, gfp & ~__GFP_HIGHMEM);
if (error) {
page_cache_release(swappage);
error = mem_cgroup_shrink_usage(current->mm,
gfp);
if (error)
goto failed;
}
mem_cgroup_uncharge_cache_page(swappage);
}
page_cache_release(swappage);
goto repeat;
}
} else if (sgp == SGP_READ && !filepage) {
Expand Down

0 comments on commit 3eee7ee

Please sign in to comment.