Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp624317pxj; Fri, 28 May 2021 11:25:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpxm5/d2rSsL3oqkKpFpQFjTQI+xyll/XvGRWf8WIRGrPQx/tttQnP+HBStLbBHeAyYDp2 X-Received: by 2002:a17:907:781a:: with SMTP id la26mr10388507ejc.435.1622226351535; Fri, 28 May 2021 11:25:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622226351; cv=none; d=google.com; s=arc-20160816; b=TL/eJTmHpKFKa68YgnnUnixu99icCVhjqas2a1fq3k7qd2Sb8TK+Dy2aV/9C5nhOMX Er+P+3Fd4Wmtzxlqyj7v8PAKwGMghy2eZEdugcy1mjhQFdZ6b5sKVPn6K2bZy0q6u2nc aFZ3NjxSsscu9G+GDHuP/2Aj43It+a0BxuNRfK77ZlsvKYLzlx0mfXFjND7SeQdhM2in C5RmKOZ/upLNYetbi6DMjKtSi0g8nzZSu55LxK+zoRJo5RngmSzGP8Gn+AWSTKQzgBmM LMU8ZUA++7x9wLH+D7mN9r5I290A0+R/BK9VRr9plOan+ZVVKgpohvBBGnPnMxDgzF91 NVAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gNnTtNhYhsjLZyYSFhpISMIVt3cv2qaTo4HNXcWiEEk=; b=jZ8Aah8yIi/tmaNA/dwUFikVgoS6LO1gYqamDOT0hV781tFDPYBibEYtSPhAPXhZlg 5tl6SRstIiSdnRZafOT5YZEqNr/rgJO3oJmTCb7PdVnn8ob6npYP3voO0J/5VJ86MfTP MqjU08FkyXvvbolpKnvx5g+/oEfZdlZxdW8TRRgMG38kxMwvekCsQFut3nwS5gIegUWq br2fH8BFJjtIBCXTLhJaxC8zfEyU3+CnTXneFwIDtj3KfaA7A7xDZ+0PAcWTfZTuC1ji W9upu1NDJdxe1XV5xJ3wXeMgeOFlGLxJCOz6ncEruqmLiXZ0LQxY/38uyMqD3YYHy1y/ iJbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=tSJVz2PF; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l17si5291228eja.456.2021.05.28.11.25.27; Fri, 28 May 2021 11:25:51 -0700 (PDT) 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=@infradead.org header.s=casper.20170209 header.b=tSJVz2PF; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229492AbhE1SYF (ORCPT + 99 others); Fri, 28 May 2021 14:24:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbhE1SYC (ORCPT ); Fri, 28 May 2021 14:24:02 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6710C061574 for ; Fri, 28 May 2021 11:22:27 -0700 (PDT) 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ;-(