From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pb0-f43.google.com (mail-pb0-f43.google.com [209.85.160.43]) by kanga.kvack.org (Postfix) with ESMTP id DBD256B0035 for ; Thu, 6 Feb 2014 01:35:46 -0500 (EST) Received: by mail-pb0-f43.google.com with SMTP id md12so1367699pbc.30 for ; Wed, 05 Feb 2014 22:35:46 -0800 (PST) Received: from fgwmail6.fujitsu.co.jp (fgwmail6.fujitsu.co.jp. [192.51.44.36]) by mx.google.com with ESMTPS id x3si31761632pbk.293.2014.02.05.22.35.45 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 05 Feb 2014 22:35:45 -0800 (PST) Received: from m3.gw.fujitsu.co.jp (unknown [10.0.50.73]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 34CE13EE0BD for ; Thu, 6 Feb 2014 15:35:44 +0900 (JST) Received: from smail (m3 [127.0.0.1]) by outgoing.m3.gw.fujitsu.co.jp (Postfix) with ESMTP id 25E4645DEB7 for ; Thu, 6 Feb 2014 15:35:44 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (s3.gw.nic.fujitsu.com [10.0.50.93]) by m3.gw.fujitsu.co.jp (Postfix) with ESMTP id 0DA1145DEB5 for ; Thu, 6 Feb 2014 15:35:44 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id F2D361DB803B for ; Thu, 6 Feb 2014 15:35:43 +0900 (JST) Received: from g01jpfmpwkw02.exch.g01.fujitsu.local (g01jpfmpwkw02.exch.g01.fujitsu.local [10.0.193.56]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 611FF1DB8040 for ; Thu, 6 Feb 2014 15:35:43 +0900 (JST) Message-ID: <52F32D19.7030107@jp.fujitsu.com> Date: Thu, 6 Feb 2014 15:35:05 +0900 From: Yasuaki Ishimatsu MIME-Version: 1.0 Subject: Re: [PATCH] mm: __set_page_dirty_nobuffers uses spin_lock_irqseve instead of spin_lock_irq References: <1391446195-9457-1-git-send-email-kosaki.motohiro@gmail.com> In-Reply-To: <1391446195-9457-1-git-send-email-kosaki.motohiro@gmail.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: kosaki.motohiro@gmail.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, KOSAKI Motohiro , Larry Woodman , Rik van Riel , Johannes Weiner , stable@vger.kernel.org (2014/02/04 1:49), kosaki.motohiro@gmail.com wrote: > From: KOSAKI Motohiro > > During aio stress test, we observed the following lockdep warning. > This mean AIO+numa_balancing is currently deadlockable. > > The problem is, aio_migratepage disable interrupt, but __set_page_dirty_nobuffers > unintentionally enable it again. > > Generally, all helper function should use spin_lock_irqsave() > instead of spin_lock_irq() because they don't know caller at all. > > [ 599.843948] other info that might help us debug this: > [ 599.873748] Possible unsafe locking scenario: > [ 599.873748] > [ 599.900902] CPU0 > [ 599.912701] ---- > [ 599.924929] lock(&(&ctx->completion_lock)->rlock); > [ 599.950299] > [ 599.962576] lock(&(&ctx->completion_lock)->rlock); > [ 599.985771] > [ 599.985771] *** DEADLOCK *** > > [ 600.375623] [] dump_stack+0x19/0x1b > [ 600.398769] [] print_usage_bug+0x1f7/0x208 > [ 600.425092] [] ? print_shortest_lock_dependencies+0x1d0/0x1d0 > [ 600.458981] [] mark_lock+0x21d/0x2a0 > [ 600.482910] [] mark_held_locks+0xb9/0x140 > [ 600.508956] [] ? _raw_spin_unlock_irq+0x2c/0x50 > [ 600.536825] [] trace_hardirqs_on_caller+0x105/0x1d0 > [ 600.566861] [] trace_hardirqs_on+0xd/0x10 > [ 600.593210] [] _raw_spin_unlock_irq+0x2c/0x50 > [ 600.620599] [] __set_page_dirty_nobuffers+0x8c/0xf0 > [ 600.649992] [] migrate_page_copy+0x434/0x540 > [ 600.676635] [] aio_migratepage+0xb1/0x140 > [ 600.703126] [] move_to_new_page+0x7d/0x230 > [ 600.729022] [] migrate_pages+0x5e5/0x700 > [ 600.754705] [] ? buffer_migrate_lock_buffers+0xb0/0xb0 > [ 600.785784] [] migrate_misplaced_page+0xbc/0xf0 > [ 600.814029] [] do_numa_page+0x102/0x190 > [ 600.839182] [] handle_pte_fault+0x241/0x970 > [ 600.865875] [] handle_mm_fault+0x265/0x370 > [ 600.892071] [] __do_page_fault+0x172/0x5a0 > [ 600.918065] [] ? retint_swapgs+0x13/0x1b > [ 600.943493] [] do_page_fault+0x1a/0x70 > [ 600.968081] [] page_fault+0x28/0x30 > > Signed-off-by: KOSAKI Motohiro > Cc: Larry Woodman > Cc: Rik van Riel > Cc: Johannes Weiner > Cc: stable@vger.kernel.org > --- Tested-by: Yasuaki Ishimatsu Thank you for posting the patch. The same issue occurred on my box. And I confirmed that the issue disappeared by the patch. Thanks, Yasuaki Ishimatsu > mm/page-writeback.c | 5 +++-- > 1 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/mm/page-writeback.c b/mm/page-writeback.c > index 2d30e2c..7106cb1 100644 > --- a/mm/page-writeback.c > +++ b/mm/page-writeback.c > @@ -2173,11 +2173,12 @@ int __set_page_dirty_nobuffers(struct page *page) > if (!TestSetPageDirty(page)) { > struct address_space *mapping = page_mapping(page); > struct address_space *mapping2; > + unsigned long flags; > > if (!mapping) > return 1; > > - spin_lock_irq(&mapping->tree_lock); > + spin_lock_irqsave(&mapping->tree_lock, flags); > mapping2 = page_mapping(page); > if (mapping2) { /* Race with truncate? */ > BUG_ON(mapping2 != mapping); > @@ -2186,7 +2187,7 @@ int __set_page_dirty_nobuffers(struct page *page) > radix_tree_tag_set(&mapping->page_tree, > page_index(page), PAGECACHE_TAG_DIRTY); > } > - spin_unlock_irq(&mapping->tree_lock); > + spin_unlock_irqrestore(&mapping->tree_lock, flags); > if (mapping->host) { > /* !PageAnon && !swapper_space */ > __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org