Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1883967pxu; Tue, 24 Nov 2020 11:09:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQMvl960hZ4jBPjf5vMQSdq0MvuRUxikJ7aOQmFX+AQWN+Pg13Nos+j9Z4eXYaJ2iqusdj X-Received: by 2002:aa7:c249:: with SMTP id y9mr3873190edo.67.1606244951496; Tue, 24 Nov 2020 11:09:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606244951; cv=none; d=google.com; s=arc-20160816; b=PRXbjZD1kzsQSG8PaibRfc4p5yHvloCi7vacfQ8k2DtCfnSmPc0QTDzUzWxConyz5U FYLWtCEUBQB6GlMwcTKdwMfpX5rFGz1Sl/dus9/O6UE9CXL41gjyF+YNIIwEJu1IR1pc W///klrKKEP6Yo9LbLEbBMWJoVbl82n6WjYZ/A1cPR7ByVTe0I6BXIAuTdgiwFHiKstD 8Y21VCSFZ/R1Mlcaqq42IPAAyQK0jkDnDmLeXeN3hLLVK7WYv6dy/VeAugw+V2wHnMyp xB+/2RoWQkO353q9vMSre1IAizv5GwTv1FzMknv+Inc1IkW/o+N3zYe5vfEimzKDo9/O 5drQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=UJx0vHStpjdpABeEWpHqZ5R1kGbrDvDIbtQyZ0Zhqxc=; b=AsKHtzYZJNBPh+aKLnkKo0c57v6zR15vjN1BrhLR1kJ7HwEp6rCnAyvbMbVmJeFian +Dh2hMugMo/xxXAkjVR1FVWUclklRdGFdmpUFvHhgPHiqVbl2IhPcWgFMLNcMjAOMYIC SGi9cBuT01/9aLjFAMxaBNkaVw3TmuDMjMWIRsvranO5J1Q6nwBy+P60zpZhYee2XRL3 h1pRRKFB6Vjc5gbVIxt689JbWSnZzYuAahO0IjhJxWaI206k3gF4ladJLChauMfP8NAF 1on15PF4z8PPZBDtzmHV1XvgixvNNtWjYCtMOFmRlAXsVuhRry5sXg5amsHJZq1aGdvI xbhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=dmXydy1i; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u7si8659312ejt.194.2020.11.24.11.08.40; Tue, 24 Nov 2020 11:09:11 -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=@linux-foundation.org header.s=google header.b=dmXydy1i; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404379AbgKXTGX (ORCPT + 99 others); Tue, 24 Nov 2020 14:06:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404416AbgKXTGW (ORCPT ); Tue, 24 Nov 2020 14:06:22 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4919DC0617A6 for ; Tue, 24 Nov 2020 11:06:22 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id q3so22011768edr.12 for ; Tue, 24 Nov 2020 11:06:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UJx0vHStpjdpABeEWpHqZ5R1kGbrDvDIbtQyZ0Zhqxc=; b=dmXydy1iMYMcd0XA86NtUQBuK77rLN5v+kCemhoSI8sSKW0ZRUU4BOa40Nc/j8TZ1H sUEPaPfvxYlaUXBxTnerkp0eTXuq+POTIYnXmeE1NOsrDnQWhHfi6trKluzdjlU1lbtI 5f/uYvPlgWdyj4CpKpPEHo4H4FSJGyyvBfUWQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UJx0vHStpjdpABeEWpHqZ5R1kGbrDvDIbtQyZ0Zhqxc=; b=J+j+N/NNGy2ylWzo1ABdHAeSBSyafElLb1VahJS8yo+4uVJcHfTCq0g+g1Z56Bz5N5 0y27Z+FyIeTkc3T8HMhttVlOyElJjOs38T7Y+NoNqBJLh+D/+UPA2etuzNJjb+R28zba rT31nRzesqBmISNrFHW/AKdgnhAwSWAlXefepTrrFofRa9B54NjzuYIyLZnYXtE68UoW gTC2dsAiWLFuEhdi6WkKa1gyY7nvgC4oZHpfWMIJgWCSjt5zHbIcT/kXjbSkLoGCmUy+ 9bQYVnytTjTK/vlH+UBs93v32POCjWje+EaXiYZez2SC734jSmkEbzgq0bwKi+Ufpate Vvkw== X-Gm-Message-State: AOAM530W/2FDx6ZdMibtP709I6ApwMBSG0qRI84OzEjkpNZIxGtEn7pT DMZdfCfNpVfaB0uIpaS+3t/lrdb1t/nzQw== X-Received: by 2002:aa7:c2d6:: with SMTP id m22mr5632914edp.368.1606244780725; Tue, 24 Nov 2020 11:06:20 -0800 (PST) Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com. [209.85.208.45]) by smtp.gmail.com with ESMTPSA id j6sm7546209edy.87.2020.11.24.11.06.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Nov 2020 11:06:20 -0800 (PST) Received: by mail-ed1-f45.google.com with SMTP id q16so22031683edv.10 for ; Tue, 24 Nov 2020 11:06:20 -0800 (PST) X-Received: by 2002:a05:651c:339:: with SMTP id b25mr2577530ljp.285.1606244458511; Tue, 24 Nov 2020 11:00:58 -0800 (PST) MIME-Version: 1.0 References: <000000000000d3a33205add2f7b2@google.com> <20200828100755.GG7072@quack2.suse.cz> <20200831100340.GA26519@quack2.suse.cz> <20201124121912.GZ4327@casper.infradead.org> <20201124183351.GD4327@casper.infradead.org> In-Reply-To: <20201124183351.GD4327@casper.infradead.org> From: Linus Torvalds Date: Tue, 24 Nov 2020 11:00:42 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: kernel BUG at fs/ext4/inode.c:LINE! To: Matthew Wilcox Cc: Hugh Dickins , 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 , linux-xfs Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, Nov 24, 2020 at 10:33 AM Matthew Wilcox wrote: > > We could fix this by turning that 'if' into a 'while' in > write_cache_pages(). That might be the simplest patch indeed. At the same time, I do worry about other cases like this: while spurious wakeup events are normal and happen in other places, this is a bit different. This is literally a wakeup that leaks from a previous use of a page, and makes us think that something could have happened to the new use. The unlock_page() case presumably never hits that, because even if we have some unlock without a page ref (which I don't think can happen, but whatever..), the exclusive nature of "lock_page()" means that no locker can care - once you get the lock, you own the page./ The writeback code is special in that the writeback bit isn't some kind of exclusive bit, but this code kind of expected it to be that. So I'd _like_ to have something like WARN_ON_ONCE(!page_count(page)); in the wake_up_page_bit() function, to catch things that wake up a page that has already been released and might be reused.. And that would require the "get_page()" to be done when we set the writeback bit and queue the page up for IO (so that then end_page_writeback() would clear the bit, do the wakeup, and then drop the ref). Hugh's second patch isn't pretty - I think the "get_page()" is conceptually in the wrong place - but it "works" in that it keeps that "implicit page reference" being kept by the PG_writeback bit, and then it takes an explicit page reference before it clears the bit. So while I don't love the whole "PG_writeback is an implicit reference to the page" model, Hugh's patch at least makes that model much more straightforward: we really either have that PG_writeback, _or_ we have a real ref to the page, and we never have that odd "we could actually lose the page" situation. So I think I prefer Hugh's two-liner over your one-liner suggestion. But your one-liner is technically not just smaller, it obviously also avoids the whole mucking with the atomic page ref. I don't _think_ that the extra get/put overhead could possibly really matter: doing the writeback is going to be a lot more expensive anyway. And an atomic access to a 'struct page' sounds expensive, but that cacheline is already likely dirty in the L1 cache because we've touch page->flags and done other things to it). So I'd personally be inclined to go with Hugh's patch. Comments? Linus