Skip to content

Commit

Permalink
memory cgroup enhancements: remember "a page is on active list of cgr…
Browse files Browse the repository at this point in the history
…oup or not"

Remember page_cgroup is on active_list or not in page_cgroup->flags.

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>
Signed-off-by: YAMAMOTO Takashi <[email protected]>
Cc: Balbir Singh <[email protected]>
Cc: Pavel Emelianov <[email protected]>
Cc: Paul Menage <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Nick Piggin <[email protected]>
Cc: Kirill Korotaev <[email protected]>
Cc: Herbert Poetzl <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Vaidyanathan Srinivasan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
hkamezawa authored and Linus Torvalds committed Feb 7, 2008
1 parent 8236955 commit 3564c7c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct page_cgroup {
int flags;
};
#define PAGE_CGROUP_FLAG_CACHE (0x1) /* charged as cache */
#define PAGE_CGROUP_FLAG_ACTIVE (0x2) /* page is active in this cgroup */

enum {
MEM_CGROUP_TYPE_UNSPEC = 0,
Expand Down Expand Up @@ -213,10 +214,13 @@ clear_page_cgroup(struct page *page, struct page_cgroup *pc)

static void __mem_cgroup_move_lists(struct page_cgroup *pc, bool active)
{
if (active)
if (active) {
pc->flags |= PAGE_CGROUP_FLAG_ACTIVE;
list_move(&pc->lru, &pc->mem_cgroup->active_list);
else
} else {
pc->flags &= ~PAGE_CGROUP_FLAG_ACTIVE;
list_move(&pc->lru, &pc->mem_cgroup->inactive_list);
}
}

int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem)
Expand Down Expand Up @@ -403,7 +407,7 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm,
atomic_set(&pc->ref_cnt, 1);
pc->mem_cgroup = mem;
pc->page = page;
pc->flags = 0;
pc->flags = PAGE_CGROUP_FLAG_ACTIVE;
if (ctype == MEM_CGROUP_CHARGE_TYPE_CACHE)
pc->flags |= PAGE_CGROUP_FLAG_CACHE;

Expand Down

0 comments on commit 3564c7c

Please sign in to comment.