Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 356579
b: refs/heads/master
c: 692e89a
h: refs/heads/master
i:
  356577: be0cff5
  356575: d7d0fcf
v: v3
  • Loading branch information
Glauber Costa authored and Linus Torvalds committed Feb 24, 2013
1 parent 6ab4b16 commit 0194d63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 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: 0999821b1d08f69e3879eb8fa0d28c4aba82ab5e
refs/heads/master: 692e89abd154b04d212dce0c18a449bda15aac04
31 changes: 7 additions & 24 deletions trunk/mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -4974,8 +4974,6 @@ static int memcg_update_kmem_limit(struct cgroup *cont, u64 val)
{
int ret = -EINVAL;
#ifdef CONFIG_MEMCG_KMEM
bool must_inc_static_branch = false;

struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
/*
* For simplicity, we won't allow this to be disabled. It also can't
Expand Down Expand Up @@ -5004,7 +5002,13 @@ static int memcg_update_kmem_limit(struct cgroup *cont, u64 val)
res_counter_set_limit(&memcg->kmem, RESOURCE_MAX);
goto out;
}
must_inc_static_branch = true;
static_key_slow_inc(&memcg_kmem_enabled_key);
/*
* setting the active bit after the inc will guarantee no one
* starts accounting before all call sites are patched
*/
memcg_kmem_set_active(memcg);

/*
* kmem charges can outlive the cgroup. In the case of slab
* pages, for instance, a page contain objects from various
Expand All @@ -5017,27 +5021,6 @@ static int memcg_update_kmem_limit(struct cgroup *cont, u64 val)
out:
mutex_unlock(&set_limit_mutex);
mutex_unlock(&memcg_create_mutex);

/*
* We are by now familiar with the fact that we can't inc the static
* branch inside cgroup_lock. See disarm functions for details. A
* worker here is overkill, but also wrong: After the limit is set, we
* must start accounting right away. Since this operation can't fail,
* we can safely defer it to here - no rollback will be needed.
*
* The boolean used to control this is also safe, because
* KMEM_ACCOUNTED_ACTIVATED guarantees that only one process will be
* able to set it to true;
*/
if (must_inc_static_branch) {
static_key_slow_inc(&memcg_kmem_enabled_key);
/*
* setting the active bit after the inc will guarantee no one
* starts accounting before all call sites are patched
*/
memcg_kmem_set_active(memcg);
}

#endif
return ret;
}
Expand Down

0 comments on commit 0194d63

Please sign in to comment.