aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2013-07-08 18:59:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-09 13:33:20 -0400
commit54f72fe022d9b2c4de40043a118881121190a117 (patch)
tree96c6fdf8da875714789cf18c07c008227ad9a213 /mm/memcontrol.c
parent9a2458a633d4b3c9e0eae506da40cf44dc075314 (diff)
memcg: clean up memcg->nodeinfo
Remove struct mem_cgroup_lru_info and fold its single member, the variably sized nodeinfo[0], directly into struct mem_cgroup. This should make it more obvious why it has to be the last member there. Also move the comment that's above that special last member below it, so it is more visible to somebody that considers appending to the struct mem_cgroup. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Cc: David Rientjes <rientjes@google.com> Acked-by: Michal Hocko <mhocko@suse.cz> Cc: Glauber Costa <glommer@openvz.org> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2e851f453814..2b7cd24d4cda 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -187,10 +187,6 @@ struct mem_cgroup_per_node {
187 struct mem_cgroup_per_zone zoneinfo[MAX_NR_ZONES]; 187 struct mem_cgroup_per_zone zoneinfo[MAX_NR_ZONES];
188}; 188};
189 189
190struct mem_cgroup_lru_info {
191 struct mem_cgroup_per_node *nodeinfo[0];
192};
193
194/* 190/*
195 * Cgroups above their limits are maintained in a RB-Tree, independent of 191 * Cgroups above their limits are maintained in a RB-Tree, independent of
196 * their hierarchy representation 192 * their hierarchy representation
@@ -366,14 +362,8 @@ struct mem_cgroup {
366 atomic_t numainfo_updating; 362 atomic_t numainfo_updating;
367#endif 363#endif
368 364
369 /* 365 struct mem_cgroup_per_node *nodeinfo[0];
370 * Per cgroup active and inactive list, similar to the 366 /* WARNING: nodeinfo must be the last member here */
371 * per zone LRU lists.
372 *
373 * WARNING: This has to be the last element of the struct. Don't
374 * add new fields after this point.
375 */
376 struct mem_cgroup_lru_info info;
377}; 367};
378 368
379static size_t memcg_size(void) 369static size_t memcg_size(void)
@@ -683,7 +673,7 @@ static struct mem_cgroup_per_zone *
683mem_cgroup_zoneinfo(struct mem_cgroup *memcg, int nid, int zid) 673mem_cgroup_zoneinfo(struct mem_cgroup *memcg, int nid, int zid)
684{ 674{
685 VM_BUG_ON((unsigned)nid >= nr_node_ids); 675 VM_BUG_ON((unsigned)nid >= nr_node_ids);
686 return &memcg->info.nodeinfo[nid]->zoneinfo[zid]; 676 return &memcg->nodeinfo[nid]->zoneinfo[zid];
687} 677}
688 678
689struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *memcg) 679struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *memcg)
@@ -6087,13 +6077,13 @@ static int alloc_mem_cgroup_per_zone_info(struct mem_cgroup *memcg, int node)
6087 mz->on_tree = false; 6077 mz->on_tree = false;
6088 mz->memcg = memcg; 6078 mz->memcg = memcg;
6089 } 6079 }
6090 memcg->info.nodeinfo[node] = pn; 6080 memcg->nodeinfo[node] = pn;
6091 return 0; 6081 return 0;
6092} 6082}
6093 6083
6094static void free_mem_cgroup_per_zone_info(struct mem_cgroup *memcg, int node) 6084static void free_mem_cgroup_per_zone_info(struct mem_cgroup *memcg, int node)
6095{ 6085{
6096 kfree(memcg->info.nodeinfo[node]); 6086 kfree(memcg->nodeinfo[node]);
6097} 6087}
6098 6088
6099static struct mem_cgroup *mem_cgroup_alloc(void) 6089static struct mem_cgroup *mem_cgroup_alloc(void)