memcg: add BUILD_BUG_ON() for string tables
authorGreg Thelen <gthelen@google.com>
Wed, 11 Feb 2015 23:25:58 +0000 (15:25 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 12 Feb 2015 01:06:02 +0000 (17:06 -0800)
Use BUILD_BUG_ON() to compile assert that memcg string tables are in sync
with corresponding enums.  There aren't currently any issues with these
tables.  This is just defensive.

Signed-off-by: Greg Thelen <gthelen@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memcontrol.c

index 6187ca4d5dc21418d44906ae08245f2533327f20..dc5c4cd0afdf60adcb4d05c5229fc6d2dbd1d99f 100644 (file)
@@ -3568,6 +3568,10 @@ static int memcg_stat_show(struct seq_file *m, void *v)
        struct mem_cgroup *mi;
        unsigned int i;
 
+       BUILD_BUG_ON(ARRAY_SIZE(mem_cgroup_stat_names) !=
+                    MEM_CGROUP_STAT_NSTATS);
+       BUILD_BUG_ON(ARRAY_SIZE(mem_cgroup_events_names) !=
+                    MEM_CGROUP_EVENTS_NSTATS);
        BUILD_BUG_ON(ARRAY_SIZE(mem_cgroup_lru_names) != NR_LRU_LISTS);
 
        for (i = 0; i < MEM_CGROUP_STAT_NSTATS; i++) {