Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 308891
b: refs/heads/master
c: 4b91355
h: refs/heads/master
i:
  308889: 91256b4
  308887: 9730c5e
v: v3
  • Loading branch information
KAMEZAWA Hiroyuki authored and Linus Torvalds committed May 29, 2012
1 parent a2aed1c commit e11c72a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 54 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: 181eb39425f2b9275afcb015eaa547d11f71a02f
refs/heads/master: 4b91355e9dc9ac1eb3d69e56de093899ff2677ef
9 changes: 4 additions & 5 deletions trunk/Documentation/cgroups/memory.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,14 @@ behind this approach is that a cgroup that aggressively uses a shared
page will eventually get charged for it (once it is uncharged from
the cgroup that brought it in -- this will happen on memory pressure).

But see section 8.2: when moving a task to another cgroup, its pages may
be recharged to the new cgroup, if move_charge_at_immigrate has been chosen.

Exception: If CONFIG_CGROUP_CGROUP_MEM_RES_CTLR_SWAP is not used.
When you do swapoff and make swapped-out pages of shmem(tmpfs) to
be backed into memory in force, charges for pages are accounted against the
caller of swapoff rather than the users of shmem.


2.4 Swap Extension (CONFIG_CGROUP_MEM_RES_CTLR_SWAP)

Swap Extension allows you to record charge for swap. A swapped-in page is
Expand Down Expand Up @@ -615,8 +617,7 @@ memory cgroup.
bit | what type of charges would be moved ?
-----+------------------------------------------------------------------------
0 | A charge of an anonymous page(or swap of it) used by the target task.
| Those pages and swaps must be used only by the target task. You must
| enable Swap Extension(see 2.4) to enable move of swap charges.
| You must enable Swap Extension(see 2.4) to enable move of swap charges.
-----+------------------------------------------------------------------------
1 | A charge of file pages(normal file, tmpfs file(e.g. ipc shared memory)
| and swaps of tmpfs file) mmapped by the target task. Unlike the case of
Expand All @@ -629,8 +630,6 @@ memory cgroup.

8.3 TODO

- Implement madvise(2) to let users decide the vma to be moved or not to be
moved.
- All of moving charge operations are done under cgroup_mutex. It's not good
behavior to hold the mutex too long, so we may need some trick.

Expand Down
9 changes: 0 additions & 9 deletions trunk/include/linux/swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ struct backing_dev_info;
#ifdef CONFIG_CGROUP_MEM_RES_CTLR
extern void
mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout);
extern int mem_cgroup_count_swap_user(swp_entry_t ent, struct page **pagep);
#else
static inline void
mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)
Expand Down Expand Up @@ -470,14 +469,6 @@ mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent)
{
}

#ifdef CONFIG_CGROUP_MEM_RES_CTLR
static inline int
mem_cgroup_count_swap_user(swp_entry_t ent, struct page **pagep)
{
return 0;
}
#endif

#endif /* CONFIG_SWAP */
#endif /* __KERNEL__*/
#endif /* _LINUX_SWAP_H */
22 changes: 14 additions & 8 deletions trunk/mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -5154,7 +5154,7 @@ static struct page *mc_handle_present_pte(struct vm_area_struct *vma,
return NULL;
if (PageAnon(page)) {
/* we don't move shared anon */
if (!move_anon() || page_mapcount(page) > 2)
if (!move_anon())
return NULL;
} else if (!move_file())
/* we ignore mapcount for file pages */
Expand All @@ -5165,26 +5165,32 @@ static struct page *mc_handle_present_pte(struct vm_area_struct *vma,
return page;
}

#ifdef CONFIG_SWAP
static struct page *mc_handle_swap_pte(struct vm_area_struct *vma,
unsigned long addr, pte_t ptent, swp_entry_t *entry)
{
int usage_count;
struct page *page = NULL;
swp_entry_t ent = pte_to_swp_entry(ptent);

if (!move_anon() || non_swap_entry(ent))
return NULL;
usage_count = mem_cgroup_count_swap_user(ent, &page);
if (usage_count > 1) { /* we don't move shared anon */
if (page)
put_page(page);
return NULL;
}
/*
* Because lookup_swap_cache() updates some statistics counter,
* we call find_get_page() with swapper_space directly.
*/
page = find_get_page(&swapper_space, ent.val);
if (do_swap_account)
entry->val = ent.val;

return page;
}
#else
static struct page *mc_handle_swap_pte(struct vm_area_struct *vma,
unsigned long addr, pte_t ptent, swp_entry_t *entry)
{
return NULL;
}
#endif

static struct page *mc_handle_file_pte(struct vm_area_struct *vma,
unsigned long addr, pte_t ptent, swp_entry_t *entry)
Expand Down
31 changes: 0 additions & 31 deletions trunk/mm/swapfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,37 +717,6 @@ int free_swap_and_cache(swp_entry_t entry)
return p != NULL;
}

#ifdef CONFIG_CGROUP_MEM_RES_CTLR
/**
* mem_cgroup_count_swap_user - count the user of a swap entry
* @ent: the swap entry to be checked
* @pagep: the pointer for the swap cache page of the entry to be stored
*
* Returns the number of the user of the swap entry. The number is valid only
* for swaps of anonymous pages.
* If the entry is found on swap cache, the page is stored to pagep with
* refcount of it being incremented.
*/
int mem_cgroup_count_swap_user(swp_entry_t ent, struct page **pagep)
{
struct page *page;
struct swap_info_struct *p;
int count = 0;

page = find_get_page(&swapper_space, ent.val);
if (page)
count += page_mapcount(page);
p = swap_info_get(ent);
if (p) {
count += swap_count(p->swap_map[swp_offset(ent)]);
spin_unlock(&swap_lock);
}

*pagep = page;
return count;
}
#endif

#ifdef CONFIG_HIBERNATION
/*
* Find the swap type that corresponds to given device (if any).
Expand Down

0 comments on commit e11c72a

Please sign in to comment.