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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 C5792C433DB for ; Fri, 15 Jan 2021 10:11:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 528C2238A1 for ; Fri, 15 Jan 2021 10:11:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 528C2238A1 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 D509E8D014F; Fri, 15 Jan 2021 05:11:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D00FD8D0023; Fri, 15 Jan 2021 05:11:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C177A8D014F; Fri, 15 Jan 2021 05:11:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0235.hostedemail.com [216.40.44.235]) by kanga.kvack.org (Postfix) with ESMTP id AB61C8D0023 for ; Fri, 15 Jan 2021 05:11:14 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7A439180AD817 for ; Fri, 15 Jan 2021 10:11:14 +0000 (UTC) X-FDA: 77707591668.16.flame10_3311c882752e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 59D67100E690C for ; Fri, 15 Jan 2021 10:11:14 +0000 (UTC) X-HE-Tag: flame10_3311c882752e X-Filterd-Recvd-Size: 6276 Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 Jan 2021 10:11:13 +0000 (UTC) Received: by mail-io1-f51.google.com with SMTP id e22so17068857iom.5 for ; Fri, 15 Jan 2021 02:11:13 -0800 (PST) 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=7DHtK3vpojuiKURcRv6BuSayvLLOoF8Kc/PNJH4nNDs=; b=aSX3+QaMpkvZpF7N6ZoQLnDgo86Wb0bUZYl1zLABVn0v7UtUPQKC8zCaWp28jFXvND B40+d7dv49JVx4yaIumLsYa4sJ8S12QmYuzrt9Tdd8aJxkHvF8gy9eGAI4ifOU16WrBE ka6c+g4RIB9w2RnweDU103/Ffwk4zrdRJR8Zk1xgYklft7j1LfkrdZUXRbGZB/RT1Dgg o2L5OEETp1hDeWj9LQkLFDy20OWYuAuG/I/Xjgv9ixdirx4Cz+S/jX3k+EKLmBO8odMA KZgOcH2STY4B4FH+jZrThl6cFpKPW3FtkUyZgHlGyLKhCueqEAtQOt5Z8xxeiPOommi8 Cutg== 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=7DHtK3vpojuiKURcRv6BuSayvLLOoF8Kc/PNJH4nNDs=; b=pMqDf5g+LOGaJxBBXsozQQ3I/whP5FPovMVg+hHLRWeYe+xZaPsnCHDKSpGSyyHuan +t7FGKis8vforifhcPyvK+/xryVNJXnNpGIL6SFobwdl5/AhamcqkZPpXymvmvHUuoNr pbEm0hBeRieA3nNS0dvgt3IEZ40iFnkJUpIv0bhnATH7YhrH8sLsA5nnwPCWbB32jZHw al1CaJFe2LqzvtLLFkx6p20dSjc/7ROj/mZIqTVkNk+/cdqKSGdstBaZLdQtmSMtcl/s hIjC80bSPZfQ3YdIcqEi0lsBgC4Vxb3ejpvaeEYs/m0o2sAzGrdjXVxPM9yXE+LN2skA +Rug== X-Gm-Message-State: AOAM533oyhvyg1MADQVJtHUSM9rueHECeTwm1a2rnQG375i++AUyQAcm wjnC3xSTY1rZwfkzx7CNvR5NxKJVvOsDD5CAJ0w= X-Google-Smtp-Source: ABdhPJwP0LdbcLL8vVv547y4Hh6ye5kJGqMuBD6dgbgDt4K94zNkLWWv0vQ8aLi16QTJ57yUPYYhMLimEtYBq3iPZKY= X-Received: by 2002:a02:a152:: with SMTP id m18mr9787401jah.64.1610705473205; Fri, 15 Jan 2021 02:11:13 -0800 (PST) MIME-Version: 1.0 References: <20210115061349.67386-1-laoar.shao@gmail.com> <20210115061349.67386-3-laoar.shao@gmail.com> In-Reply-To: From: Yafang Shao Date: Fri, 15 Jan 2021 18:10:37 +0800 Message-ID: Subject: Re: [PATCH 2/2] mm: introduce PAGE_FLAGS() to make output of page flags better To: David Hildenbrand Cc: Christoph Lameter , penberg@kernel.org, David Rientjes , iamjoonsoo.kim@lge.com, Andrew Morton , Matthew Wilcox , Johannes Weiner , Michal Hocko , osalvador@suse.de, linmiaohe@huawei.com, steven.price@arm.com, Roman Gushchin , "Huang, Ying" , Linux MM Content-Type: text/plain; charset="UTF-8" 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, Jan 15, 2021 at 4:39 PM David Hildenbrand wrote: > > On 15.01.21 07:13, Yafang Shao wrote: > > There're totally __NR_PAGEFLAGS page flags, but the type of page->flags is > > unsigned long, that makes the value of page->flags a little misleading when > > it is printed to the user. We'd better print the real pages flags, instead > > of the whole 64bits including the random values in the useless high bits. > > No, these are *not* random values. They include the nid, zid, and > section_nr - which are helpful to have at hand when debugging, or > detecting that something might be messed up there. > Thanks for the explanation. I just noticed the page-flags layout in page-flags-layout.h. > > > > There're two choices to achieve that, one of which is clear the useless > > Again, not useless. > > > high bits when we initlize the page->flags, the other is don't print the > > high bits when it is showed to the user. The latter one is better because > > it is in the slow path and the performance won't be impacted. > > > > Before that change, the output is, > > [ 8846.517809] INFO: Slab 0x00000000f42a2c60 objects=33 used=3 fp=0x0000000060d32ca8 flags=0x17ffffc0010200(slab|head) > > > > After that change, the output is, > > [ 8843.757770] INFO: Slab 0x00000000f0e98335 objects=33 used=3 fp=0x00000000b643c7d8 flags=0x10200(slab|head) > > > > Nack to the current approach. If you're going to strip this information, > you should expose it differently. E.g., printing page_zonenum() or > page_to_nid(). But still, then we might lose valuable information of > bits stored in there that shouldn't have been set. > How about changing the implementation of pGp in printk() ? In the new implementation of pGp we can dump the full information of page->flags, rather than the flag's name only. For example, 0xXXXXXXXX(node n, nid n, ..., slab|head) That will make it easier to understand, as it is not easy to look into the detail of page-flags layout. > > Signed-off-by: Yafang Shao > > --- > > include/linux/page-flags.h | 2 ++ > > mm/slub.c | 2 +- > > 2 files changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h > > index ec5d029..db5c017 100644 > > --- a/include/linux/page-flags.h > > +++ b/include/linux/page-flags.h > > @@ -175,6 +175,8 @@ enum pageflags { > > PG_reported = PG_uptodate, > > }; > > > > +#define PAGE_FLAGS(flags) (flags & ((1 << __NR_PAGEFLAGS) - 1)) > > + > > #ifndef __GENERATING_BOUNDS_H > > > > struct page; /* forward declaration */ > > diff --git a/mm/slub.c b/mm/slub.c > > index 901a45a..a93a03c 100644 > > --- a/mm/slub.c > > +++ b/mm/slub.c > > @@ -643,7 +643,7 @@ static void print_page_info(struct page *page) > > { > > pr_err("INFO: Slab 0x%p objects=%u used=%u fp=0x%p flags=%#lx(%pGp)\n", > > page, page->objects, page->inuse, page->freelist, > > - page->flags, &page->flags); > > + PAGE_FLAGS(page->flags), &page->flags); > > > > } > > > > > > > -- > Thanks, > > David / dhildenb > -- Thanks Yafang