mm, memcg: mark cgroup_memory_nosocket, nokmem and noswap as __ro_after_init
authorRoman Gushchin <guro@fb.com>
Thu, 3 Jun 2021 01:09:29 +0000 (18:09 -0700)
committerDennis Zhou <dennis@kernel.org>
Sat, 5 Jun 2021 20:40:59 +0000 (20:40 +0000)
cgroup_memory_nosocket, cgroup_memory_nokmem and cgroup_memory_noswap
are initialized during the kernel initialization and never change
their value afterwards.

cgroup_memory_nosocket, cgroup_memory_nokmem are written only from
cgroup_memory(), which is marked as __init.

cgroup_memory_noswap is written from setup_swap_account() and
mem_cgroup_swap_init(), both are marked as __init.

Mark all three variables as __ro_after_init.

Signed-off-by: Roman Gushchin <guro@fb.com>
Signed-off-by: Dennis Zhou <dennis@kernel.org>
mm/memcontrol.c

index e064ac0d850ac1cc968c8a11306e2b233c2ae706..e6203ee24a11a3a331c2d50212887de4f36dd1f4 100644 (file)
@@ -80,14 +80,14 @@ struct mem_cgroup *root_mem_cgroup __read_mostly;
 DEFINE_PER_CPU(struct mem_cgroup *, int_active_memcg);
 
 /* Socket memory accounting disabled? */
-static bool cgroup_memory_nosocket;
+static bool cgroup_memory_nosocket __ro_after_init;
 
 /* Kernel memory accounting disabled? */
-static bool cgroup_memory_nokmem;
+static bool cgroup_memory_nokmem __ro_after_init;
 
 /* Whether the swap controller is active */
 #ifdef CONFIG_MEMCG_SWAP
-bool cgroup_memory_noswap __read_mostly;
+bool cgroup_memory_noswap __ro_after_init;
 #else
 #define cgroup_memory_noswap           1
 #endif