Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 83795
b: refs/heads/master
c: 58ae83d
h: refs/heads/master
i:
  83793: 531f8e2
  83791: 13092bd
v: v3
  • Loading branch information
KAMEZAWA Hiroyuki authored and Linus Torvalds committed Feb 7, 2008
1 parent ab7b3b0 commit 4907796
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 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: 6d12e2d8ddbe653d80ea4f71578481c1bc933025
refs/heads/master: 58ae83db2a40dea15d4277d499a11dadc823c388
11 changes: 10 additions & 1 deletion trunk/include/linux/memcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ extern int mem_cgroup_prepare_migration(struct page *page);
extern void mem_cgroup_end_migration(struct page *page);
extern void mem_cgroup_page_migration(struct page *page, struct page *newpage);

/*
* For memory reclaim.
*/
extern int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem);


#else /* CONFIG_CGROUP_MEM_CONT */
static inline void mm_init_cgroup(struct mm_struct *mm,
struct task_struct *p)
Expand Down Expand Up @@ -135,7 +141,10 @@ mem_cgroup_page_migration(struct page *page, struct page *newpage)
{
}


static inline int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem)
{
return 0;
}
#endif /* CONFIG_CGROUP_MEM_CONT */

#endif /* _LINUX_MEMCONTROL_H */
Expand Down
17 changes: 17 additions & 0 deletions trunk/mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,23 @@ void mem_cgroup_move_lists(struct page_cgroup *pc, bool active)
spin_unlock(&mem->lru_lock);
}

/*
* Calculate mapped_ratio under memory controller. This will be used in
* vmscan.c for deteremining we have to reclaim mapped pages.
*/
int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem)
{
long total, rss;

/*
* usage is recorded in bytes. But, here, we assume the number of
* physical pages can be represented by "long" on any arch.
*/
total = (long) (mem->res.usage >> PAGE_SHIFT) + 1L;
rss = (long)mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS);
return (int)((rss * 100L) / total);
}

unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
struct list_head *dst,
unsigned long *scanned, int order,
Expand Down

0 comments on commit 4907796

Please sign in to comment.