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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 D297EC2D0E4 for ; Tue, 24 Nov 2020 19:01:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E91FA204FD for ; Tue, 24 Nov 2020 19:01:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="dmXydy1i" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E91FA204FD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EE0056B006E; Tue, 24 Nov 2020 14:01:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E83626B0070; Tue, 24 Nov 2020 14:01:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D72946B0071; Tue, 24 Nov 2020 14:01:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0213.hostedemail.com [216.40.44.213]) by kanga.kvack.org (Postfix) with ESMTP id C085F6B006E for ; Tue, 24 Nov 2020 14:01:08 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 84EF08249980 for ; Tue, 24 Nov 2020 19:01:08 +0000 (UTC) X-FDA: 77520229416.06.cough88_121277327370 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 7C90310043E78 for ; Tue, 24 Nov 2020 19:01:04 +0000 (UTC) X-HE-Tag: cough88_121277327370 X-Filterd-Recvd-Size: 6789 Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Nov 2020 19:01:03 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id l11so30457181lfg.0 for ; Tue, 24 Nov 2020 11:01:03 -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=fJs6+I4J6f/45FP+hAp1WGXWpVCWxDYPm8hebsmxqNNndyuytmZ7jJaGEPHeoXveR8 Rb/3CLyW2PjDFQlJcMqIkd6PryU9glRh8kmcwkcLeRtzNMF5yvbdfkSRwKnPlXy7qDVV h9OiMppq+AjOZ/lHzGrjCoWmw+1O0kamvZRRzmgotayCl5fv5s/pVSxsHvXbCGFEI+nG OpP2+Vznit+PmSLtcCZkOm6YZbRFZeHwWvV/FMrXgLXHWfCbX86bpIyHPDZ/zFQ943/O j6fINt6mB9VPLeSH97rSTmfj+1om2uKleS0B4pSVHu6topXA0DhxhU7C25UfFBFl6shJ dX9Q== X-Gm-Message-State: AOAM532euI6QrNCSRt0pAcYdClT85bJF3496yTB6DBzog7zPCIQTKU3U kX5sJqVgeMxBsyX5z770aD1yBQoXRB+kTQ== X-Google-Smtp-Source: ABdhPJxm9AucylNTyiKbcKlgekFDdhaj1LAAmnwXLUO0Yl/eS2axuHVBPvdev1k3R/ZnHIMXtAZ8gQ== X-Received: by 2002:a19:f207:: with SMTP id q7mr2120213lfh.588.1606244461514; Tue, 24 Nov 2020 11:01:01 -0800 (PST) Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com. [209.85.208.177]) by smtp.gmail.com with ESMTPSA id c12sm1821105lfj.44.2020.11.24.11.00.58 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Nov 2020 11:00:59 -0800 (PST) Received: by mail-lj1-f177.google.com with SMTP id i17so23308051ljd.3 for ; Tue, 24 Nov 2020 11:00:58 -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" 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, 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