Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 83783
b: refs/heads/master
c: 217bc31
h: refs/heads/master
i:
  83781: 6bc9041
  83779: 73a15d6
  83775: 6e5029a
v: v3
  • Loading branch information
KAMEZAWA Hiroyuki authored and Linus Torvalds committed Feb 7, 2008
1 parent bca5c14 commit e951088
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 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: cc8475822f8a4b17e9b76e7fadb6b9a341860422
refs/heads/master: 217bc3194d57150549e9234e6ddfee30de28cc78
24 changes: 21 additions & 3 deletions trunk/mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ struct page_cgroup {
struct mem_cgroup *mem_cgroup;
atomic_t ref_cnt; /* Helpful when pages move b/w */
/* mapped and cached states */
int flags;
};
#define PAGE_CGROUP_FLAG_CACHE (0x1) /* charged as cache */

enum {
MEM_CGROUP_TYPE_UNSPEC = 0,
Expand All @@ -93,6 +95,11 @@ enum {
MEM_CGROUP_TYPE_MAX,
};

enum charge_type {
MEM_CGROUP_CHARGE_TYPE_CACHE = 0,
MEM_CGROUP_CHARGE_TYPE_MAPPED,
};

static struct mem_cgroup init_mem_cgroup;

static inline
Expand Down Expand Up @@ -306,8 +313,8 @@ unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
* 0 if the charge was successful
* < 0 if the cgroup is over its limit
*/
int mem_cgroup_charge(struct page *page, struct mm_struct *mm,
gfp_t gfp_mask)
static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm,
gfp_t gfp_mask, enum charge_type ctype)
{
struct mem_cgroup *mem;
struct page_cgroup *pc;
Expand Down Expand Up @@ -409,6 +416,9 @@ int mem_cgroup_charge(struct page *page, struct mm_struct *mm,
atomic_set(&pc->ref_cnt, 1);
pc->mem_cgroup = mem;
pc->page = page;
pc->flags = 0;
if (ctype == MEM_CGROUP_CHARGE_TYPE_CACHE)
pc->flags |= PAGE_CGROUP_FLAG_CACHE;
if (page_cgroup_assign_new_page_cgroup(page, pc)) {
/*
* an another charge is added to this page already.
Expand All @@ -433,6 +443,13 @@ int mem_cgroup_charge(struct page *page, struct mm_struct *mm,
return -ENOMEM;
}

int mem_cgroup_charge(struct page *page, struct mm_struct *mm,
gfp_t gfp_mask)
{
return mem_cgroup_charge_common(page, mm, gfp_mask,
MEM_CGROUP_CHARGE_TYPE_MAPPED);
}

/*
* See if the cached pages should be charged at all?
*/
Expand All @@ -445,7 +462,8 @@ int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,

mem = rcu_dereference(mm->mem_cgroup);
if (mem->control_type == MEM_CGROUP_TYPE_ALL)
return mem_cgroup_charge(page, mm, gfp_mask);
return mem_cgroup_charge_common(page, mm, gfp_mask,
MEM_CGROUP_CHARGE_TYPE_CACHE);
else
return 0;
}
Expand Down

0 comments on commit e951088

Please sign in to comment.