Patch "memcg: mem_cgroup_migrate() may be called with irq disabled" has been added to the 4.6-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
memcg: mem_cgroup_migrate() may be called with irq disabled
to the 4.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
memcg-mem_cgroup_migrate-may-be-called-with-irq-disabled.patch
and it can be found in the queue-4.6 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
d93c4130a7d049b234b5d5a15808eaf5406f2789Mon Sep 17 00:00:00 2001
From: Tejun Heo <[email protected]>
Date: Fri, 24 Jun 2016 14:49:54 -0700
Subject: memcg: mem_cgroup_migrate() may be called with irq disabled
From: Tejun Heo <[email protected]>
commit d93c4130a7d049b234b5d5a15808eaf5406f2789 upstream.
mem_cgroup_migrate() uses local_irq_disable/enable() but can be called with irq disabled from migrate_page_copy(). This ends up enabling irq while holding a irq context lock triggering the following lockdep warning. Fix it by using irq_save/restore instead.
=================================
[ INFO: inconsistent lock state ]
4.7.0-rc1+ #52 Tainted: G W
---------------------------------
inconsistent {IN-SOFTIRQ-W} -> {SOFTIRQ-ON-W} usage.
kcompactd0/151 [HC0[0]:SC0[0]:HE1:SE1] takes:
(&(&ctx->completion_lock)->rlock){+.?.-.}, at: [<000000000038fd96>] aio_migratepage+0x156/0x1e8
{IN-SOFTIRQ-W} state was registered at:
__lock_acquire+0x5b6/0x1930
lock_acquire+0xee/0x270
_raw_spin_lock_irqsave+0x66/0xb0
aio_complete+0x98/0x328
dio_complete+0xe4/0x1e0
blk_update_request+0xd4/0x450
scsi_end_request+0x48/0x1c8
scsi_io_completion+0x272/0x698
blk_done_softirq+0xca/0xe8
__do_softirq+0xc8/0x518
irq_exit+0xee/0x110
do_IRQ+0x6a/0x88
io_int_handler+0x11a/0x25c
__mutex_unlock_slowpath+0x144/0x1d8
__mutex_unlock_slowpath+0x140/0x1d8
kernfs_iop_permission+0x64/0x80
__inode_permission+0x9e/0xf0
link_path_walk+0x6e/0x510
path_lookupat+0xc4/0x1a8
filename_lookup+0x9c/0x160
user_path_at_empty+0x5c/0x70
SyS_readlinkat+0x68/0x140
system_call+0xd6/0x270
irq event stamp: 971410
hardirqs last enabled at (971409): migrate_page_move_mapping+0x3ea/0x588
hardirqs last disabled at (971410): _raw_spin_lock_irqsave+0x3c/0xb0
softirqs last enabled at (970526): __do_softirq+0x460/0x518
softirqs last disabled at (970519): irq_exit+0xee/0x110other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(&(&ctx->completion_lock)->rlock);
<Interrupt>
lock(&(&ctx->completion_lock)->rlock);
*** DEADLOCK ***3 locks held by kcompactd0/151:
#0: (&(&mapping->private_lock)->rlock){+.+.-.}, at: aio_migratepage+0x42/0x1e8
#1: (&ctx->ring_lock){+.+.+.}, at: aio_migratepage+0x5a/0x1e8
#2: (&(&ctx->completion_lock)->rlock){+.?.-.}, at: aio_migratepage+0x156/0x1e8 stack backtrace:
CPU: 20 PID: 151 Comm: kcompactd0 Tainted: G W 4.7.0-rc1+ #52
Call Trace:
show_trace+0xea/0xf0
show_stack+0x72/0xf0
dump_stack+0x9a/0xd8
print_usage_bug.part.27+0x2d4/0x2e8
mark_lock+0x17e/0x758
mark_held_locks+0xa2/0xd0
trace_hardirqs_on_caller+0x140/0x1c0
mem_cgroup_migrate+0x266/0x370
aio_migratepage+0x16a/0x1e8
move_to_new_page+0xb0/0x260
migrate_pages+0x8f4/0x9f0
compact_zone+0x4dc/0xdc8
kcompactd_do_work+0x1aa/0x358
kcompactd+0xba/0x2c8
kthread+0x10a/0x110
kernel_thread_starter+0x6/0xc
kernel_thread_starter+0x0/0xc
INFO: lockdep is turned off.--- mm/memcontrol.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
mm/memcontrol.c +3 -2
@@ -5524,6 +5524,7 @@ void mem_cgroup_migrate(struct page *oldstruct mem_cgroup *memcg;unsigned int nr_pages;bool compound; +unsigned long flags;VM_BUG_ON_PAGE (!PageLocked (oldpage), oldpage);VM_BUG_ON_PAGE (!PageLocked (newpage), newpage);
@@ -5554,10 +5555,10 @@ void mem_cgroup_migrate(struct page *oldcommit_charge (newpage, memcg, false); -local_irq_disable (); +local_irq_save (flags);mem_cgroup_charge_statistics (memcg, newpage, compound, nr_pages);memcg_check_events (memcg, newpage); -local_irq_enable (); +local_irq_restore (flags); }DEFINE_STATIC_KEY_FALSE (memcg_sockets_enabled_key);
Patches currently in stable-queue which might be from [email protected] are
queue-4.6/memcg-css_alloc-should-return-an-err_ptr-value-on-error.patch queue-4.6/memcg-mem_cgroup_migrate-may-be-called-with-irq-disabled.patch queue-4.6/mm-memcontrol-fix-cgroup-creation-failure-after-many-small-jobs.patch