Commit 16ace91043bf5fa192bb6e42451524b3c6ad7bd7
Committed by
Greg Kroah-Hartman
1 parent
1771fc58a3
Exists in
smarct4x-processor-sdk-04.01.00.06
and in
1 other branch
mm: do not call mem_cgroup_free() from within mem_cgroup_alloc()
commit 40e952f9d687928b32db20226f085ae660a7237c upstream. mem_cgroup_free() indirectly calls wb_domain_exit() which is not prepared to deal with a struct wb_domain object that hasn't executed wb_domain_init(). For instance, the following warning message is printed by lockdep if alloc_percpu() fails in mem_cgroup_alloc(): INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. CPU: 1 PID: 1950 Comm: mkdir Not tainted 4.10.0+ #151 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Call Trace: dump_stack+0x67/0x99 register_lock_class+0x36d/0x540 __lock_acquire+0x7f/0x1a30 lock_acquire+0xcc/0x200 del_timer_sync+0x3c/0xc0 wb_domain_exit+0x14/0x20 mem_cgroup_free+0x14/0x40 mem_cgroup_css_alloc+0x3f9/0x620 cgroup_apply_control_enable+0x190/0x390 cgroup_mkdir+0x290/0x3d0 kernfs_iop_mkdir+0x58/0x80 vfs_mkdir+0x10e/0x1a0 SyS_mkdirat+0xa8/0xd0 SyS_mkdir+0x14/0x20 entry_SYSCALL_64_fastpath+0x18/0xad Add __mem_cgroup_free() which skips wb_domain_exit(). This is used by both mem_cgroup_free() and mem_cgroup_alloc() clean up. Fixes: 0b8f73e104285 ("mm: memcontrol: clean up alloc, online, offline, free functions") Link: http://lkml.kernel.org/r/20170306192122.24262-1-tahsin@google.com Signed-off-by: Tahsin Erdogan <tahsin@google.com> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing 1 changed file with 8 additions and 3 deletions Side-by-side Diff
mm/memcontrol.c
... | ... | @@ -4139,17 +4139,22 @@ |
4139 | 4139 | kfree(memcg->nodeinfo[node]); |
4140 | 4140 | } |
4141 | 4141 | |
4142 | -static void mem_cgroup_free(struct mem_cgroup *memcg) | |
4142 | +static void __mem_cgroup_free(struct mem_cgroup *memcg) | |
4143 | 4143 | { |
4144 | 4144 | int node; |
4145 | 4145 | |
4146 | - memcg_wb_domain_exit(memcg); | |
4147 | 4146 | for_each_node(node) |
4148 | 4147 | free_mem_cgroup_per_node_info(memcg, node); |
4149 | 4148 | free_percpu(memcg->stat); |
4150 | 4149 | kfree(memcg); |
4151 | 4150 | } |
4152 | 4151 | |
4152 | +static void mem_cgroup_free(struct mem_cgroup *memcg) | |
4153 | +{ | |
4154 | + memcg_wb_domain_exit(memcg); | |
4155 | + __mem_cgroup_free(memcg); | |
4156 | +} | |
4157 | + | |
4153 | 4158 | static struct mem_cgroup *mem_cgroup_alloc(void) |
4154 | 4159 | { |
4155 | 4160 | struct mem_cgroup *memcg; |
... | ... | @@ -4200,7 +4205,7 @@ |
4200 | 4205 | fail: |
4201 | 4206 | if (memcg->id.id > 0) |
4202 | 4207 | idr_remove(&mem_cgroup_idr, memcg->id.id); |
4203 | - mem_cgroup_free(memcg); | |
4208 | + __mem_cgroup_free(memcg); | |
4204 | 4209 | return NULL; |
4205 | 4210 | } |
4206 | 4211 |