Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 190787
b: refs/heads/master
c: 7f0f154
h: refs/heads/master
i:
  190785: 21a6afe
  190783: 6abd9c2
v: v3
  • Loading branch information
KAMEZAWA Hiroyuki authored and Linus Torvalds committed May 12, 2010
1 parent 8484d2b commit cfafa04
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 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: 11cad320a4f4bc53d3585c85600c782faa12b99e
refs/heads/master: 7f0f15464185a92f9d8791ad231bcd7bf6df54e4
15 changes: 13 additions & 2 deletions trunk/kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -4435,7 +4435,15 @@ __setup("cgroup_disable=", cgroup_disable);
*/
unsigned short css_id(struct cgroup_subsys_state *css)
{
struct css_id *cssid = rcu_dereference(css->id);
struct css_id *cssid;

/*
* This css_id() can return correct value when somone has refcnt
* on this or this is under rcu_read_lock(). Once css->id is allocated,
* it's unchanged until freed.
*/
cssid = rcu_dereference_check(css->id,
rcu_read_lock_held() || atomic_read(&css->refcnt));

if (cssid)
return cssid->id;
Expand All @@ -4445,7 +4453,10 @@ EXPORT_SYMBOL_GPL(css_id);

unsigned short css_depth(struct cgroup_subsys_state *css)
{
struct css_id *cssid = rcu_dereference(css->id);
struct css_id *cssid;

cssid = rcu_dereference_check(css->id,
rcu_read_lock_held() || atomic_read(&css->refcnt));

if (cssid)
return cssid->depth;
Expand Down
19 changes: 5 additions & 14 deletions trunk/mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -2314,9 +2314,7 @@ mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)

/* record memcg information */
if (do_swap_account && swapout && memcg) {
rcu_read_lock();
swap_cgroup_record(ent, css_id(&memcg->css));
rcu_read_unlock();
mem_cgroup_get(memcg);
}
if (swapout && memcg)
Expand Down Expand Up @@ -2373,10 +2371,8 @@ static int mem_cgroup_move_swap_account(swp_entry_t entry,
{
unsigned short old_id, new_id;

rcu_read_lock();
old_id = css_id(&from->css);
new_id = css_id(&to->css);
rcu_read_unlock();

if (swap_cgroup_cmpxchg(entry, old_id, new_id) == old_id) {
mem_cgroup_swap_statistics(from, false);
Expand Down Expand Up @@ -4044,16 +4040,11 @@ static int is_target_pte_for_mc(struct vm_area_struct *vma,
put_page(page);
}
/* throught */
if (ent.val && do_swap_account && !ret) {
unsigned short id;
rcu_read_lock();
id = css_id(&mc.from->css);
rcu_read_unlock();
if (id == lookup_swap_cgroup(ent)) {
ret = MC_TARGET_SWAP;
if (target)
target->ent = ent;
}
if (ent.val && do_swap_account && !ret &&
css_id(&mc.from->css) == lookup_swap_cgroup(ent)) {
ret = MC_TARGET_SWAP;
if (target)
target->ent = ent;
}
return ret;
}
Expand Down

0 comments on commit cfafa04

Please sign in to comment.