From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5A01C433EF for ; Wed, 15 Dec 2021 04:19:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA7726B0071; Tue, 14 Dec 2021 23:19:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E57996B0073; Tue, 14 Dec 2021 23:19:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D46BF6B0074; Tue, 14 Dec 2021 23:19:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id C7A9E6B0071 for ; Tue, 14 Dec 2021 23:19:22 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8869788CF4 for ; Wed, 15 Dec 2021 04:19:12 +0000 (UTC) X-FDA: 78918723744.14.E656BE5 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf21.hostedemail.com (Postfix) with ESMTP id 785231C000D for ; Wed, 15 Dec 2021 04:19:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=0b1q8LH8HNfIeoCv8LnUjTKY84gOKuNMMSC+sT9rUTg=; b=cQk2DYMJXuu0MBuDrPtlgE1CRX xY+UUh6YCq8HVHXh+hxpzd73ce9aIW/O0olGP28ELG13T1psHPUDwZHA+2IUe5C7AGKE7BFpQgWVn fXRMYCslEiYjDEI+DOJNtlwG4mQ03kJ9U/tS/PvYvlGfPnST5MPZ9sQiApZFQPcEVT6Uut5PW/rmk pXDS/x0wFbuEtFm8PXj3gg7rDlHnUCg4Yrdx0/N1BEQSSz7y55cNfFSOUV8mmPUaOnvrP9fRI2jvh zImaYdysxdVWvxQDEWkcOxovm+1AIsHCll4vvFjEPV837ptJtA+62u0Nho2jJDQ8xT4ZJZWqRY7RU 9RSM9YFw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxLkt-00EKiH-EC; Wed, 15 Dec 2021 04:19:03 +0000 Date: Wed, 15 Dec 2021 04:19:03 +0000 From: Matthew Wilcox To: syzbot Cc: akpm@linux-foundation.org, dhowells@redhat.com, hughd@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] possible deadlock in split_huge_page_to_list Message-ID: References: <00000000000091a18b05d324df40@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00000000000091a18b05d324df40@google.com> X-Rspamd-Queue-Id: 785231C000D X-Stat-Signature: 97znu6k99ert838aa935pa1cmwoah7pk Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cQk2DYMJ; dmarc=none; spf=none (imf21.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam11 X-HE-Tag: 1639541949-255124 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Dec 14, 2021 at 05:03:26PM -0800, syzbot wrote: > commit 3ebffc96befbaf9de9297b00d67091bb702fad8e > Author: Matthew Wilcox (Oracle) > Date: Sun Jun 28 02:19:08 2020 +0000 > > mm: Use multi-index entries in the page cache > > bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1276e4bab00000 > final oops: https://syzkaller.appspot.com/x/report.txt?x=1176e4bab00000 > console output: https://syzkaller.appspot.com/x/log.txt?x=1676e4bab00000 Well, this is all entirely plausible: + xas_split_alloc(&xas, head, compound_order(head), + mapping_gfp_mask(mapping) & GFP_RECLAIM_MASK); It looks like I can fix this by moving the memory allocation before the acquisition of the i_mmap_lock. Any objections to this: +++ b/mm/huge_memory.c @@ -2653,6 +2653,13 @@ int split_huge_page_to_list(struct page *page, struct lis t_head *list) goto out; } + xas_split_alloc(&xas, head, compound_order(head), + mapping_gfp_mask(mapping) & GFP_RECLAIM_MASK); + if (xas_error(&xas)) { + ret = xas_error(&xas); + goto out; + } + anon_vma = NULL; i_mmap_lock_read(mapping); @@ -2679,15 +2686,6 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) unmap_page(head); - if (mapping) { - xas_split_alloc(&xas, head, compound_order(head), - mapping_gfp_mask(mapping) & GFP_RECLAIM_MASK); - if (xas_error(&xas)) { - ret = xas_error(&xas); - goto out_unlock; - } - } - /* block interrupt reentry in xa_lock and spinlock */ local_irq_disable(); if (mapping) { (relative to the above patch)