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 06785C63798 for ; Tue, 24 Nov 2020 16:28:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4B8020757 for ; Tue, 24 Nov 2020 16:28:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="h2tPcALc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390479AbgKXQ2d (ORCPT ); Tue, 24 Nov 2020 11:28:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390470AbgKXQ2c (ORCPT ); Tue, 24 Nov 2020 11:28:32 -0500 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE142C061A4D for ; Tue, 24 Nov 2020 08:28:32 -0800 (PST) Received: by mail-ot1-x329.google.com with SMTP id 11so7349030oty.9 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=Dw6l0ocgyfY1+bztCrjpBJZtujJqH61VEUI6U7+NbYsp0eCcwIDqo5f4UWLP6wBTq5 fC2a25S61Xc9vur6yYCInQu9fNckv2QPjW63smiIZJ2g5Xu1N7B/KU3EeheIwiorAbI+ 6uKqDZYyMozUjs8ncsFOj0k7zL/rjPqU5ri//kxXkIhMkS8gUxfQcIssOkTGjzu+HQBu JuinMp0WsjL0FIkpq3ka7fW6JApzoPIEdYBYm2q1rnXCV83uNZ3oKdbN+ygMtz05tieP N9E1bMMw3q1rofuy255V2FelQ6Mn24JGugJ0t/YF3dhFg6zAY6v1K2pftyiaWv10D7aj SNvw== X-Gm-Message-State: AOAM53100g9PHW6+KNVOMfEQ4cPxp1aPhBhzIOFzWvG48ApP2rgllRbK tjZy+Sa37EWUERv2mcjOxXXcYw== 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 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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