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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 814B5C3DA7D for ; Tue, 3 Jan 2023 23:29:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A0CE78E0002; Tue, 3 Jan 2023 18:29:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 995CD8E0001; Tue, 3 Jan 2023 18:29:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 838688E0002; Tue, 3 Jan 2023 18:29:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6FC928E0001 for ; Tue, 3 Jan 2023 18:29:57 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 3892240A7F for ; Tue, 3 Jan 2023 23:29:57 +0000 (UTC) X-FDA: 80315082834.03.B7673FA Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id EA041140003 for ; Tue, 3 Jan 2023 23:29:54 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=kgw2QhRf; spf=none (imf23.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672788595; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gJPqyGklqTbYMdKnqat7Qbv+pMXyAuOwKbuCLL2MIGw=; b=XWzw6pMSMGwvyf3Jg1lCu+3cdc2pVYHWSy12+mdzSS/PsYZVvfHWbZtPbFuW9LXcmJBDOL 0LmxA+bUkwELId6KCOIp4B1mEq/K9OSt1aCnYYn1h+Ucx218C/TMOczX1XPh4Rhxt4Spld nW5+1iiFgOw8cDt2uq6PB4pOnudc9HI= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=kgw2QhRf; spf=none (imf23.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672788595; a=rsa-sha256; cv=none; b=gNimhSp1yNn/2BPqPOOwrHlZ1zuDzvyED2/jtCz4tWDKj111QS5IpjmHnNI+9xW4aeGI0I mpxmRQtRjLHA56Y6iQDWHa0uflCj9Ler5XuHMhoCTrPiF21CsSdGc/OTpXpvStKaOK27oe g+fUP5mBBJXZ9SlK22SnbJMjXnBJ6HI= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=gJPqyGklqTbYMdKnqat7Qbv+pMXyAuOwKbuCLL2MIGw=; b=kgw2QhRfZdK8b99xYswM0FAnRa dSWhynhEso+r248R4juIWtqk7DJjJUjp0jhL12KxbqdpiSIrFQ8YSV3VoZFFQ3yO99t2DD70ULyf1 wM3nop/kBaR8yEWyrpbQai8qbp4lcfvIeHsju2Sky76nk/2u4JpuaBwBTW6f5ZmoIh9ACBywZefUB tBytsJdtHZYYlXWf+BK5TNHejVhq9PzgzAkt5OuDjbnMzapHMYdNAqnLoqHqPY0Qps6mu7wHxXe44 fUPitTOeDXgQy1Yk4pts9rgn8+abS24OGJzxGdjmvEzuziye1YpH3/+B++sf8+kPT2PuSlaL5E+EU uSpJ2wlw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCqiy-00EUm4-5a; Tue, 03 Jan 2023 23:29:40 +0000 Date: Tue, 3 Jan 2023 23:29:40 +0000 From: Matthew Wilcox To: David Rientjes Cc: Vlastimil Babka , kernel test robot , Hyeonggon Yoo <42.hyeyoo@gmail.com>, oe-lkp@lists.linux.dev, lkp@intel.com, Mike Rapoport , Christoph Lameter , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: A better dump_page() Message-ID: References: <202212312021.bc1efe86-oliver.sang@intel.com> <41276905-b8a5-76ae-8a17-a8ec6558e988@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: EA041140003 X-Stat-Signature: 3f4wu5b58k8t3xsoziqsr5upii55ff5q X-Rspam-User: X-HE-Tag: 1672788594-743693 X-HE-Meta: U2FsdGVkX1+zgWWCf9BCqMGtACeHgRUrFAvXtep49t9LLsH+jO1nbkHB5sWUoa3CkgVyTM5B1J54Q/cVnHszBZggtrekaEWr+YWffnuaCVAhhFSFIeUXsgBhUgd916TWunMtbp/5MBWYtkuz8BtpXlRUtWZBfpCijdFaY919F9ZR3BglL0Boit6csY5Pwyi4q8ue+jgQgJOznWZe3TZqPxA06xOADf0wOeQX5c0++C6hbrcF45lZJIOElEfMGq4ykVlNgK4fTeASaR/m6+o7JCRq/Q+Ar0BEATGsJhWwyx20RpsZyil2G6HyugRAY7/YT3q2KYrjhaeEH5FTcnxpUnS4w/qgDHX1LE6LkXAtUOzHqui6ThYp7oKSrJtgTEX/CUHAubmgPB6xaLQ0DIHEnmx3kpMoeNOhAXOlhgWwkIACLzqto6oNG2t9kE7unWf8zCSSACNbFLz5UyXYmLeSWOKelqyz+ows3bMWvBk1zwnt9hdpHdV0bHKjXcGFPiojNKIfrXrfm23DzfciXAvZOCwN3l0oSd+9SUusHTXiVWL0jWV98TGEnHQadUdcH0TvuL3HpZsSeq9pwgn7neSUwdduyvNtEYQTFO+LLPY1a4W4eQCsFK10GHHo+97AqccIfnfuKgw36SWOt15+Tui1MfFlaQ04kbAvg7xMGMNOf8X1UkKW4NIzn3/+F28upDVO/ZwXc7B2A8KtsYT08ici0zFrRlBN7PY9ZjOzuogZzoc1xuHR1mhgsSIgq1eD9mkIRkU3qNESKVHREy/MtLAEX7OkEFrNK79XXE19clg2UPY6VL/4OgSvI26MZquzvKaXY8wkxoD+EGY7ll33VC129VcEbRr0RHa2W/Z1RfGOa6uGTqwhNJ5SjHFFMzxf4sQs5LmATHjAQy1mNhulmkBgUZc9N2f/m1gpK13Xo96idz1T8dycZQQwlNvrshVsoIQ69UlG1RvOQFxqvAJP1wy pbaIeePa piZTo 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, Jan 03, 2023 at 03:07:12PM -0800, David Rientjes wrote: > On Tue, 3 Jan 2023, Matthew Wilcox wrote: > > > On Tue, Jan 03, 2023 at 11:42:11AM +0100, Vlastimil Babka wrote: > > > Separately we should also make the __dump_page() more resilient. > > > > Right. It's not ideal when one of our best debugging tools obfuscates > > the problem we're trying to debug. I've seen probems like this before, > > and the problem is that somebody calls dump_page() on a page that they > > don't own a refcount on. That lets the page mutate under us in some > > fairly awkward ways (as you've seen here, it seems to be part of several > > different compound allocations at various points during the dump > > process). > > > > One possibility I thought about was taking our own refcount on the > > page at the start of dump_page(). That would kill off the possibility > > of ever passing in a const struct page, and it would confuse people. > > Also, what if somebody passes in a pointer to something that's not a > > struct page? Then we've (tried to) modify memory that's not a refcount. > > > > I think the best we can do is to snapshot the struct page and the folio > > it appears to belong to at the start of dump_page(). It'll take a > > little care (for example, folio_pfn() must be passed the original > > folio, and not the snapshot), but I think it's doable. > > > > By snapshot do you mean memcpy() of the metadata to the stack? I assume > this still leaves the opportunity for the underlying mutation of the page > but makes the window more narrow. Right. We'd need to memcpy() both the page and the folio, so around 192 bytes. It doesn't make it consistent since it could be mutated during the memcpy(), but it will be consistent throughout the execution of the function, so we won't get calls like folio_entire_mapcount() aborting due to the folio having become a tail page halfway through.