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=-14.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL 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 C69F6C2D0E4 for ; Tue, 24 Nov 2020 16:28:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 29D2920757 for ; Tue, 24 Nov 2020 16:28:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="h2tPcALc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29D2920757 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 04DA66B005D; Tue, 24 Nov 2020 11:28:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F19886B0070; Tue, 24 Nov 2020 11:28:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE01C6B0071; Tue, 24 Nov 2020 11:28:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0177.hostedemail.com [216.40.44.177]) by kanga.kvack.org (Postfix) with ESMTP id C2D946B005D for ; Tue, 24 Nov 2020 11:28:36 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8059C180AD815 for ; Tue, 24 Nov 2020 16:28:36 +0000 (UTC) X-FDA: 77519845032.03.time44_4d0d6ce2736f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 2798328A4ED for ; Tue, 24 Nov 2020 16:28:33 +0000 (UTC) X-HE-Tag: time44_4d0d6ce2736f X-Filterd-Recvd-Size: 6081 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Nov 2020 16:28:32 +0000 (UTC) Received: by mail-ot1-f45.google.com with SMTP id 92so16822135otd.5 for ; Tue, 24 Nov 2020 08:28:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=ah+J2wD/1faDZjYB3Zrgws96wmPFn4mzRk/eDM0VpfE=; b=h2tPcALcjB1t4yCELbdTsVIXBflLhIBZpuIe7YEIWaqMrErciI4oYibsR4PuSR3eBm a1HQUDkbKIXT7dw2dF1osk+Ewd3ry8H3qWPqrsnSSvpwphmnYiduGvPC/acc89Z4HoBF dQR/Qust/cntC0l8MxoB01tlPMhZdg1GZvFe3YCRbX0EKSlHwbCzgWJ+8KF8ujYqRMcW p809jw2U5Nyr4t7ccXvc7ZQ/lpTlBodFDk0ppPG9Td5VTTRT1dKl5zZ+op8i964Uwmcn oQyidKfqYMNIuIxyBYIQwwGDr7gMOmgSS8FTpPSS8SBScIpqSj6pDarOKlRo1GGyy13e DtPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=ah+J2wD/1faDZjYB3Zrgws96wmPFn4mzRk/eDM0VpfE=; b=f4El3SmzNGYtkwv2DRfl7iFHsR8xnFoDxf8NeJBPfPahiOwSm7sKBSbXZaGs3edVOz fbV2ESjtOUmLdWgp5QcBd5XkCnoml33cYEFAs6787lPgX9u/gaC2PEHdV/UTyVjdt88a M9QiHKzvEhGXF/6uJyn0mMhGQd3qP4hLLgXbLZqKDvv5GaRtNzOVR7TqqcguJZ1+L86V SlRh83rNqPqoI1of8zp1iHNVY5lhMl5JA+8dR9UPyV3QsQOszp8U3gT6PvFdyoEatzMm AwRI/SbgeJX+TDdym2cmHzGlOFuYcdYGeOcQu9PMejqQnkphsJs/WzCFwzEDaxa37Kpw JWkA== X-Gm-Message-State: AOAM530V53RGXiy6fs/aJzmSh0jQNq7Ai8WCa/iO40lj4y2U+J/qpt5k vjU7pAkn+eaMM23a45AI62B6Vw== X-Google-Smtp-Source: ABdhPJwD6ulzDfoJYVk98EDsBubLOjkB0ZnaCfJOcW8zo99O0ipagto7b7cafmz/JIb+EReFJU1LvA== X-Received: by 2002:a05:6830:1f11:: with SMTP id u17mr4030280otg.287.1606235311779; Tue, 24 Nov 2020 08:28:31 -0800 (PST) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id u4sm7428592ote.71.2020.11.24.08.28.29 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Tue, 24 Nov 2020 08:28:30 -0800 (PST) Date: Tue, 24 Nov 2020 08:28:16 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Matthew Wilcox cc: Hugh Dickins , 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! In-Reply-To: <20201124121912.GZ4327@casper.infradead.org> Message-ID: References: <000000000000d3a33205add2f7b2@google.com> <20200828100755.GG7072@quack2.suse.cz> <20200831100340.GA26519@quack2.suse.cz> <20201124121912.GZ4327@casper.infradead.org> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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, 24 Nov 2020, Matthew Wilcox wrote: > On Mon, Nov 23, 2020 at 08:07:24PM -0800, Hugh Dickins wrote: > > > > 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 :-( It is confusing. I tried to explain that in the final paragraph: > > Was there a chance of missed wakeups before, since a page freed before > > reaching wake_up_page() would have PageWaiters cleared? I think not, > > because each waiter does hold a reference on the page: this bug comes > > not from real waiters, but from when PageWaiters is a false positive. but got lost in between the original end_page_writeback() and the patched version when writing that last part - false positive PageWaiters are not relevant. I'll try rewording that in the simpler version, following. The BUG_ON(PageWriteback) would occur when the old use of the page, the one we do TestClearPageWriteback on, had *no* waiters, so no additional page reference beyond the page cache (and whoever racily frees it). The reuse of the page definitely has a waiter holding a reference, as you point out, and PageWriteback still set; but our belated wake_up_page() has woken it to hit the BUG_ON. Hugh