Skip to content

Commit

Permalink
mm: memcontrol: clean up alloc, online, offline, free functions
Browse files Browse the repository at this point in the history
The creation and teardown of struct mem_cgroup is fairly messy and
that has attracted mistakes and subtle bugs before.

The main cause for this is that there is no clear model about what
needs to happen when, and that attracts more chaos. So create one:

1. mem_cgroup_alloc() should allocate struct mem_cgroup and its
   auxiliary members and initialize work items, locks etc. so that the
   object it returns is fully initialized and in a neutral state.

2. mem_cgroup_css_alloc() will use mem_cgroup_alloc() to obtain a new
   memcg object and configure it and the system according to the role
   of the new memory-controlled cgroup in the hierarchy.

3. mem_cgroup_css_online() is no longer needed to synchronize with
   iterators, but it verifies css->id which isn't available earlier.

4. mem_cgroup_css_offline() implements stuff that needs to happen upon
   the user-visible destruction of a cgroup, which includes stopping
   all user interfacing as well as releasing certain structures when
   continued memory consumption would be unexpected at that point.

5. mem_cgroup_css_free() prepares the system and the memcg object for
   the object's disappearance, neutralizes its state, and then gives
   it back to mem_cgroup_free().

6. mem_cgroup_free() releases struct mem_cgroup and auxiliary memory.

[[email protected]: fix SLOB build regression]
Signed-off-by: Johannes Weiner <[email protected]>
Acked-by: Vladimir Davydov <[email protected]>
Cc: Michal Hocko <[email protected]>
Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
hnaz authored and torvalds committed Jan 21, 2016
1 parent 0db1529 commit 0b8f73e
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 176 deletions.
3 changes: 0 additions & 3 deletions include/linux/memcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ struct mem_cgroup {
/* vmpressure notifications */
struct vmpressure vmpressure;

/* css_online() has been completed */
int initialized;

/*
* Should the accounting and control be hierarchical, per subtree?
*/
Expand Down
Loading

0 comments on commit 0b8f73e

Please sign in to comment.