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 X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7D36C56201 for ; Tue, 24 Nov 2020 12:19:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F25F920708 for ; Tue, 24 Nov 2020 12:19:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="AoYEmNwS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F25F920708 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 19AD76B00C3; Tue, 24 Nov 2020 07:19:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 14AC46B00C4; Tue, 24 Nov 2020 07:19:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0646F6B00C5; Tue, 24 Nov 2020 07:19:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0081.hostedemail.com [216.40.44.81]) by kanga.kvack.org (Postfix) with ESMTP id DF47C6B00C3 for ; Tue, 24 Nov 2020 07:19:20 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A4120181AEF23 for ; Tue, 24 Nov 2020 12:19:20 +0000 (UTC) X-FDA: 77519216880.04.nerve51_57085352736e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 863268005050 for ; Tue, 24 Nov 2020 12:19:20 +0000 (UTC) X-HE-Tag: nerve51_57085352736e X-Filterd-Recvd-Size: 4460 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Nov 2020 12:19:19 +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=uvDfFcTJVIdXBGR+joN6zXz154p6r479ClVsKuidpag=; b=AoYEmNwScc3ZhYqB9VycOafUC5 2v8rbvnu68twnK4hQ1ICV3Qzd3tbpCIgVcqUSI2A3/4FgAKbdGgoPE3j691S9i44M+3BMOp+ucZpe WYTpbzzzuC8m5I6rqbpj7uJxVy2iPPq4BbrJt3tnjp156mNc79iiEIPR+k4akIFcqQYYTWMEGNmOn GTS+ei+v5ogGFPnIWlWKqtnu9wWzezGV6iDyvZWWbfaK41ZVxjD7qnMAJMwYOli6+LnTRhtDS8F/J ATpzt8UTjj6e/hWbcAEtZdqToH0AwcokShCJbDWUIV5xBWmnCgjfTQnUGBa3qUsMVttttRPptukAc Xc1lNbWw==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1khXHs-0002FJ-2w; Tue, 24 Nov 2020 12:19:12 +0000 Date: Tue, 24 Nov 2020 12:19:12 +0000 From: Matthew Wilcox To: Hugh Dickins Cc: Linus Torvalds , Jan Kara , syzbot , Andreas Dilger , Ext4 Developers List , Linux Kernel Mailing List , syzkaller-bugs , Theodore Ts'o , Linux-MM , Oleg Nesterov , Andrew Morton , "Kirill A. Shutemov" , Nicholas Piggin , Alex Shi , Qian Cai , Christoph Hellwig , "Darrick J. Wong" , William Kucharski , Jens Axboe , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: Re: kernel BUG at fs/ext4/inode.c:LINE! Message-ID: <20201124121912.GZ4327@casper.infradead.org> References: <000000000000d3a33205add2f7b2@google.com> <20200828100755.GG7072@quack2.suse.cz> <20200831100340.GA26519@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Mon, Nov 23, 2020 at 08:07:24PM -0800, Hugh Dickins wrote: > Twice now, when exercising ext4 looped on shmem huge pages, I have crashed > on the PF_ONLY_HEAD check inside PageWaiters(): ext4_finish_bio() calling > end_page_writeback() calling wake_up_page() on tail of a shmem huge page, > no longer an ext4 page at all. > > The problem is that PageWriteback is not accompanied by a page reference > (as the NOTE at the end of test_clear_page_writeback() acknowledges): as > soon as TestClearPageWriteback has been done, that page could be removed > from page cache, freed, and reused for something else by the time that > wake_up_page() is reached. > > https://lore.kernel.org/linux-mm/20200827122019.GC14765@casper.infradead.org/ > Matthew Wilcox suggested avoiding or weakening the PageWaiters() tail > check; but I'm paranoid about even looking at an unreferenced struct page, > lest its memory might itself have already been reused or hotremoved (and > wake_up_page_bit() may modify that memory with its ClearPageWaiters()). > > Then on crashing a second time, realized there's a stronger reason against > that approach. If my testing just occasionally crashes on that check, > when the page is reused for part of a compound page, wouldn't it be much > more common for the page to get reused as an order-0 page before reaching > wake_up_page()? And on rare occasions, might that reused page already be > marked PageWriteback by its new user, and already be waited upon? What > would that look like? > > It would look like BUG_ON(PageWriteback) after wait_on_page_writeback() > in write_cache_pages() (though I have never seen that crash myself). I don't think this is it. write_cache_pages() holds a reference to the page -- indeed, it holds the page lock! So this particular race cannot cause the page to get recycled. I still have no good ideas what this is :-(