Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2054221pxu; Tue, 24 Nov 2020 16:01:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwB0jbicaJJjmXKNjj6iuTk9woeq/5It/wHUPXgpU+LwNqAk2fW0rlUjR2vpLGJ9w7iBhxM X-Received: by 2002:a17:906:1682:: with SMTP id s2mr834507ejd.62.1606262511777; Tue, 24 Nov 2020 16:01:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606262511; cv=none; d=google.com; s=arc-20160816; b=zRzfB7wkpJGb5zzWbWoK9eJwmyUfRenHdqhFzVtZj6JBtsdFHz/A3CQ3NrgXNMLgKo /iWDPtUcNNrYcd92GTnkyxj523W3yagTIFgmvwoDFt8bUKmlUCPOQoqxbVF4kIrDhWNu 3z35WaqU5RXPKE1TFv8BOkKMWlWR4YPidg58ZZ7b6ZjYjsTkgyaxAU7QG/jHWUW/L+ie wCwaMv6l1I2IgjBVghFc19TiHTC3pPG4fJcnJM3Q4UWzqd8Dc+wCpgsVjKo1le5YIaGq I3NeRGih7cFi4PO0s2lJ/B887BBOwDmmNfd1n8taQz7VA8XDpg7lWU5turHxOSks4Kek ktDA== 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=04YZn/oOi9cwlQjeUz6wAhKNr23VM3kG20feokh0qeg=; b=0y8cDkKHk9WfFcPrxd23ffr9hnDGOwEMAwCHLjDfzBWUrPEbZwr5LiDt9B3ieY6QFF e8TLMze0khSTC1my9Q0paKCEc1dFEzKIHUrX03BbiNoGS1yp6QYXuwOaimUZuoL6baYp G2CqBLAOxs+m+zFpMv9zKfFjCaPbDyFNh7/gByugr86zCyNW0xXi8sj7ccosIIq+OqRs M1KV6Z+mgwRqMJupCqv7ZH3dqSvqVrfWVdo+iZz7QzoBOyq+SGUnDUYgxO5hAdePH3WJ vLQ653KnI1I9kxEwxW+6ApDSqJSiJoUzXg8iRCgL8kWqWfAe3iztqGdocD8gzdkocegp ImVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=VzQAooJ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 o22si271692ejb.569.2020.11.24.16.01.28; Tue, 24 Nov 2020 16:01:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=VzQAooJ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1732603AbgKXVrB (ORCPT + 99 others); Tue, 24 Nov 2020 16:47:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731557AbgKXVrA (ORCPT ); Tue, 24 Nov 2020 16:47:00 -0500 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16498C0613D6 for ; Tue, 24 Nov 2020 13:47:00 -0800 (PST) Received: by mail-oi1-x244.google.com with SMTP id s18so391512oih.1 for ; Tue, 24 Nov 2020 13:47:00 -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=04YZn/oOi9cwlQjeUz6wAhKNr23VM3kG20feokh0qeg=; b=VzQAooJ4hoEvvjBCc+1Qt2u70siZAJm6h9WtKGpP0ywmkQ1vspYXHydmfQoTf4ym3I oqKJzcR5krrs+o2BlUzYp3kcBIpfa6E6ew96qdIC2DTZU5N5pj5QjitRF0O5vAP3DLm/ Rw71YTkXEZBmOi1/VFYN3Po6znE+JQDeN5AQ5GT8PpDyb4DUQYVH9RDLVPxXCtlzpqGL NLPgS8k2q9XJZCcEqp0jixScddihjCkoUiurydf3GmXYEZPzwqkjXKYbEuCjos3F0Dgj X3M8gEHfAlkVbtkko2WkcUF0RRIGEvajB3ukYdimzdhZa9OdqeypZLEs6CnYwqCUGZF7 gNSQ== 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=04YZn/oOi9cwlQjeUz6wAhKNr23VM3kG20feokh0qeg=; b=d84hUq0JcenZYbDP7USN2aWY21j3/zNh+P88/D785iOqa4/eJDSrrbXPKtbJjljJJ7 rrhRavD0CSMILIgtShgux97/4BaWu1dsJ6RkbvtfBFbJ5SrwxM9l47OC1Jqx7yrQiqnU o51/8OGaGWM5kt/dzYEHSL2y3+CioR7ZdVJp37j9jRzVomvQYehrR3iihfWwc+B3IZaZ 6jQMfd5pDJLGmUcSkLTy4BXk7Xf9/2nNbfcwahvteBEOUCqmwoJKYw3qciaHwYbZJQOq GkourcXDQPGuc1Rhcds9zZeduGVA73AKBqOoiq+BdKpiyp/ey0Hw+TgOj79vx/j/X2r+ AcXw== X-Gm-Message-State: AOAM532kxoES3WdY7CYZC9zOWkPTM4Z6K/mfV7zXNN3jXr2mkQ+RiK6q y55Kjv6jDwSCtNl6vq+ABe9Wqw== X-Received: by 2002:aca:f5c8:: with SMTP id t191mr213734oih.40.1606254419120; Tue, 24 Nov 2020 13:46:59 -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 a4sm139138otj.29.2020.11.24.13.46.56 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Tue, 24 Nov 2020 13:46:58 -0800 (PST) Date: Tue, 24 Nov 2020 13:46:44 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Linus Torvalds cc: Matthew Wilcox , 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 Subject: Re: kernel BUG at fs/ext4/inode.c:LINE! In-Reply-To: Message-ID: References: <000000000000d3a33205add2f7b2@google.com> <20200828100755.GG7072@quack2.suse.cz> <20200831100340.GA26519@quack2.suse.cz> <20201124121912.GZ4327@casper.infradead.org> <20201124183351.GD4327@casper.infradead.org> <20201124201552.GE4327@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-kernel@vger.kernel.org On Tue, 24 Nov 2020, Linus Torvalds wrote: > On Tue, Nov 24, 2020 at 12:16 PM Matthew Wilcox wrote: > > > > So my s/if/while/ suggestion is wrong and we need to do something to > > prevent spurious wakeups. Unless we bury the spurious wakeup logic > > inside wait_on_page_writeback() ... > > We can certainly make the "if()" in that loop be a "while()'. > > That's basically what the old code did - simply by virtue of the > wakeup not happening if the writeback bit was set in > wake_page_function(): > > if (test_bit(key->bit_nr, &key->page->flags)) > return -1; > > of course, the race was still there - because the writeback bit might > be clear at that point, but another CPU would reallocate and dirty it, > and then autoremove_wake_function() would happen anyway. > > But back in the bad old days, the wait_on_page_bit_common() code would > then double-check in a loop, so it would catch that case, re-insert > itself on the wait queue, and try again. Except for the DROP case, > which isn't used by writeback. > > Anyway, making that "if()" be a "while()" in wait_on_page_writeback() > would basically re-introduce that old behavior. I don't really care, > because it was the lock bit that really mattered, the writeback bit is > not really all that interesting (except from a "let's fix this bug" > angle) > > I'm not 100% sure I like the fragility of this writeback thing. > > Anyway, I'm certainly happy with either model, whether it be an added > while() in wait_on_page_writeback(), or it be the page reference count > in end_page_writeback(). > > Strong opinions? Responding to "Strong opinions?" before having digested Matthew's DMA sequence (no, not his DNA sequence). I think it comes down to whether my paranoia (about accessing an unreferenced struct page) is realistic or not: since I do hold that paranoia, I do prefer (whatever variant of) my patch. I'm not a memory hotremove guy. I did search mm/memory_hotplug.c for references to rcu or stop_machine(), but found none. I can imagine that the memory containing the struct pages would be located elsewhere than the memory itself, with some strong barrier in between removals; but think there were patches posted just a few days ago, with intent to allocate struct pages from the same memory block. It would be easy to forget this writeback issue when hotremove advances, if we don't fix it properly now. Another problem with the s/if/while/ solution: I think Matthew pointed to another patch needed, to prevent wake_up_page_bit() from doing an inappropriate ClearPageWaiters (I've not studied that patch); and would also need a further patch to deal with my PF_ONLY_HEAD VM_BUG_ON(PageTail). More? I think the unreferenced struct page asks for trouble. Hugh