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=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 674ACC2B9F7 for ; Fri, 28 May 2021 18:57:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0422F61108 for ; Fri, 28 May 2021 18:57:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0422F61108 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0C9406B0070; Fri, 28 May 2021 14:57:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 06A986B0071; Fri, 28 May 2021 14:57:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF68B6B0072; Fri, 28 May 2021 14:57:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0088.hostedemail.com [216.40.44.88]) by kanga.kvack.org (Postfix) with ESMTP id 6A1536B0070 for ; Fri, 28 May 2021 14:57:12 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 06C62824999B for ; Fri, 28 May 2021 18:57:12 +0000 (UTC) X-FDA: 78191547504.14.6EDE7DA Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by imf30.hostedemail.com (Postfix) with ESMTP id 1839FE0009AF for ; Fri, 28 May 2021 18:57:04 +0000 (UTC) Received: by mail-ej1-f53.google.com with SMTP id ci15so3462619ejc.10 for ; Fri, 28 May 2021 11:57:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kVbbn9Tllju3ajh8WBDFibkdk2WLCqQZwjz4DxeixVg=; b=o8MAWiiP+EedC79OfXmHH++BL0hoE4dXtHp72RwzksF3nBUatbYbHyZW9+Y6vfu1XF ogG7yxFsG7Lq64QEFHUot8HXaLKln7z13Vp8yI8pvsm1FnxSDkWIvej4VXkbb+2mzMLY lkXs98fhm8PIe10qY7zx/aKHBdn+LUxgEra9/oDEpMYIsIBE2mnt1Wc6NutHJuPDTUv2 XQF1QFGkEJsA+qyzv7aporio0YCQP7sNREElMjnWhHaAKeNfIBciBklxpaMybEe0sHNp Mn191Xm3XXRW2UU3Y+tjjg5VjLl6MVPoXZmB4JKBzy7e/myhVyyQCdfparN7YyZg/oZD S2Cw== 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=kVbbn9Tllju3ajh8WBDFibkdk2WLCqQZwjz4DxeixVg=; b=pRYfJae2RalRvkCFT293xU1riW/N28w8WUkduIwJ/FoIEIKvn4YuWNtimFX8OjdWak g5wVQkS/KnDBQuVVx79i2qNy2bdHAA1Q5KU8A7etTZZwhOwJeObYQZN7VlcGHXNe4zFx GSoHFGTjh1cV/NDn/zr/0fr+3rej9N//aWU5WnMh2Wo5rEDfle3AKgdiJr56BcbtPII3 iNBY/f65w5DKiYzTUwyOpP7JbHKTe4ESiCVXpvVIXx2FBnlQmHNE9s3Uj6Cr/flEH/so U49dPVziTMYWPN6Yeby50eKWONnb8jo23Tcx7aCJ1escy5Eyg/947VKMZW5T/HKExg0q SCPA== X-Gm-Message-State: AOAM530okuz/6aI5vBv46zl2zdxbnc/z7iGGF1Jdwt8xsVuaCTbJJxN3 GHzMkb8/lq0bVhKk83KfqYFelbeqIQ3xMmDBh7A= X-Google-Smtp-Source: ABdhPJzcUtLuBBKkDmUt7ki04LQtzvWlnRvb0cqO/bJ0/ldbrdUJfKjgTVdlz3Nmu5W1bQjljxkBLOODwJyqBiV1q3s= X-Received: by 2002:a17:906:da1b:: with SMTP id fi27mr10497141ejb.161.1622228230486; Fri, 28 May 2021 11:57:10 -0700 (PDT) MIME-Version: 1.0 References: <20210528175403.4506-1-shy828301@gmail.com> In-Reply-To: From: Yang Shi Date: Fri, 28 May 2021 11:56:59 -0700 Message-ID: Subject: Re: [RFC PATCH] mm: dump_page: print total mapcount for compound page To: Matthew Wilcox Cc: Hugh Dickins , John Hubbard , "Kirill A. Shutemov" , Vlastimil Babka , Andrew Morton , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=o8MAWiiP; spf=pass (imf30.hostedemail.com: domain of shy828301@gmail.com designates 209.85.218.53 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 1839FE0009AF X-Stat-Signature: xebiedqyshuhqpqox847j7hu51u1simb X-HE-Tag: 1622228224-41531 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 11:22 AM Matthew Wilcox wrote: > > 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. Yes, slab page dump is missed for a long time. > > > + 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. Yes, it is inaccurate in some cases. There is not a simple way to rule out those random transient references. The page cache has been taken into account by this patch, but I overlooked private page and LRU cache cases, they seem simple to filter out by page flags. > > I had to think hard about it though. I like what you're trying to do, > I just don't think it works ;-( The random transient references are annoying and could make the number be far away from accuracy. That would be too confusing to be worth printing the number. But I'm not sure how often or bad it could be.