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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 3B40FC2B9F7 for ; Fri, 28 May 2021 18:22:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ABE47611AE for ; Fri, 28 May 2021 18:22:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABE47611AE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2877C6B0036; Fri, 28 May 2021 14:22:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 25F686B006E; Fri, 28 May 2021 14:22:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 127916B0070; Fri, 28 May 2021 14:22:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D724B6B0036 for ; Fri, 28 May 2021 14:22:27 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 6B20E1815524C for ; Fri, 28 May 2021 18:22:27 +0000 (UTC) X-FDA: 78191459934.20.5A60377 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id E3044A000146 for ; Fri, 28 May 2021 18:22:18 +0000 (UTC) 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=gNnTtNhYhsjLZyYSFhpISMIVt3cv2qaTo4HNXcWiEEk=; b=tSJVz2PFgt3iU+MzA4FHLI2H2K V8mLCpYUNOH9K3/3Kipce59E3aKijW984GYpCkjg96TS4wOm942DGDlcPIYfGMDK1tMNjYtvCN21j MSle5FrCI15iMnVMNVLcH88cOmSBWQXXh8qrCJ99e3Enyt6usVtPLjwbXCnouJAG/qXBJkf4HPZrt ZawOO+LctRF4IOkGX33pev+9o2bjMn9SfLUheplgs0b8LcH5jhLyXOTY0PkR/dNgpAxbJzWxqAWGJ dWxfjsc5wIlEWJ3XDD9Epj8ESdVpG747XVHe+6KAczst2+Yh+y7X1JJdL+tvlIiClrCQG8r8TzavZ oVtDGjRw==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lmh7a-006tAY-7K; Fri, 28 May 2021 18:22:12 +0000 Date: Fri, 28 May 2021 19:22:10 +0100 From: Matthew Wilcox To: Yang Shi Cc: hughd@google.com, jhubbard@nvidia.com, kirill.shutemov@linux.intel.com, vbabka@suse.cz, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] mm: dump_page: print total mapcount for compound page Message-ID: References: <20210528175403.4506-1-shy828301@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210528175403.4506-1-shy828301@gmail.com> X-Rspamd-Queue-Id: E3044A000146 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tSJVz2PF; dmarc=none; 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 X-Rspamd-Server: rspam03 X-Stat-Signature: k88de6qmx6qctqxenwg1xs4roh5kiidy X-HE-Tag: 1622226138-239298 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 Fri, May 28, 2021 at 10:54:03AM -0700, Yang Shi wrote: > So I prepared this patch to show a possible approach to get some > feedback. The same thing could be decoded by the reader of page dump > as well by using the same formula used by this patch. However it sounds > more convenient to have kernel do the math. You haven't taken enough things into consideration ... > + bool is_slab = PageSlab(head); We should probably have a separate dump_slab_page(). Almost nothing in __dump_page() is really useful for slab pages (eg, mapping, index, mapcount, compound_mapcount, compound_pincount, aops), and the flags (such as are used) have different meanings. > + nr = compound_nr(head); > + if (is_slab) > + total_mapcount = 0; > + else if (PageHuge(head)) > + total_mapcount = comp_mapcnt; > + else { > + if (mapping) { > + if (!PageAnon(head)) > + nr = nr * (comp_mapcnt + 1) - comp_mapcnt; > + } else > + nr = 0; > + total_mapcount = refcount - pincount - nr; I see what you're trying to do here, but there are so many other things which take a refcount on a page. The LRU, the page cache, private fs data, random temporary "gets" (eg, buffered reads, buffered writes, get_user_pages(), readahead, truncate, migration). I think this is likely to be so inaccurate as to be confusing. I had to think hard about it though. I like what you're trying to do, I just don't think it works ;-(