Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1769582pxu; Tue, 24 Nov 2020 08:30:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEq6HWRQCbGxXlZ5w8SbRveQXUekCQF7z9Kq0uyXoTYFPANe1lv0VqiYPaPGTJPhlk+pGd X-Received: by 2002:a17:906:3ac2:: with SMTP id z2mr4731841ejd.26.1606235455749; Tue, 24 Nov 2020 08:30:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606235455; cv=none; d=google.com; s=arc-20160816; b=iLpTOLUD/nYwQRv4GAFunQyc9SuTIEolHfIXQ6CdSBJ+ZNhAjFO/KCZb3qnyW3vQL1 KZOSyFDIDx4iy8gnAaVqIuVsYN1P2ugtlI3oXC/ZDFtMP50JiAos+lrfJgpPXvj0b9T1 xcnPnQ77TSl49eqev7DVq4f7pjPHl4CPGZukuMPoQqi40p0onDAV/fc82EzIp2NWed5h MRcPH2aAO3pG1msDlkhjBWGv3rpGQmLg18/IfeIOfaxGRUg9ePvbmTlJdTxKTj5pdMV/ hTFcA8pUbG9RNx/Hk0vyM66qW0lwQUPhYQOIEekDI0bXxoqy8jeOfqaLv4rVA7ig26Ik QgeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=ah+J2wD/1faDZjYB3Zrgws96wmPFn4mzRk/eDM0VpfE=; b=LUH5lMVyZn1bjjsKleHr1tlpd+Jg5lQMXPs1kKMXCmwXno4IqgWsudzpkX0GxGOjRW t7OvxSGcqelkdo4SmVhxVQ5JGSjslRsSTwk8Ogv1JQx+oQOd/QepsW9WgBkh2VTA3GtS G7OR0AzqcgYmzwybtYAo4DE6WzBVqTN6YIrG5OUTxzvA82AtYJymXfZt26UF46RmyR28 w9ep2K6S5z0gyhG3+bApM3DNwG/QICNLTXhRna6Tmpb0kJJaDOZXD2sm06htyfgzwqbM n4IpyLqMQ4bOtNmG+mCLJSb59zdaHRCABlZ3+6O1MeTnDrbgxPz4h9ZgWmIcfovcO9AT cBZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=h2tPcALc; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w10si8839425edj.71.2020.11.24.08.30.19; Tue, 24 Nov 2020 08:30:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=h2tPcALc; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390475AbgKXQ2d (ORCPT + 99 others); Tue, 24 Nov 2020 11:28:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390472AbgKXQ2c (ORCPT ); Tue, 24 Nov 2020 11:28:32 -0500 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B61C0C061A4E for ; Tue, 24 Nov 2020 08:28:32 -0800 (PST) Received: by mail-ot1-x335.google.com with SMTP id 79so19861197otc.7 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=JmGnnm61F7IQ5vbf66VTbvYJ+pU1ernkjCfAdJJ5qKaRxdtTTVKiwlVaxeKYLpi+w+ zl8B79pYuGQ5ln6ZSh1zF5n4tBqWbVpIGTgSebUKiTDHs65gZdOUFFiV8ZT0/5UFW1Um bgZA9+1iMXzT28Om19l+BaO5ZZWBTBZuvb2mxWQKXHK9VFRra1Mgos+T6l/vOOqO+T+5 lpNHtvHvt4gKIKTRVDLL6yp4s54RJcWuRzxg3IF+/bhw+wCPnpvBpSDfWAbIa1qVYmJN Az7l3G11Rxwt0+Op1rmUe58wohJOTd82HlLs6iAXUtr+WIt4iNsvuWEC60vifKdJtvsV 6QGA== X-Gm-Message-State: AOAM531zGvsv5lBDFayKbJFX20zOYvbAa+/FL6+jTRqpKM3scYI+EUgm z44V9llBegDlIpP/H2lUXm5pBA== 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-ext4@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