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=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 E017AC433DB for ; Fri, 15 Jan 2021 08:39:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7836E22C7D for ; Fri, 15 Jan 2021 08:39:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7836E22C7D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B2F798D013D; Fri, 15 Jan 2021 03:39:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ADF858D0023; Fri, 15 Jan 2021 03:39:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F4FB8D013D; Fri, 15 Jan 2021 03:39:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0020.hostedemail.com [216.40.44.20]) by kanga.kvack.org (Postfix) with ESMTP id 89C2C8D0023 for ; Fri, 15 Jan 2021 03:39:17 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 5248A3637 for ; Fri, 15 Jan 2021 08:39:17 +0000 (UTC) X-FDA: 77707359954.28.fruit14_5d04fc42752d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 335A86D72 for ; Fri, 15 Jan 2021 08:39:17 +0000 (UTC) X-HE-Tag: fruit14_5d04fc42752d X-Filterd-Recvd-Size: 5288 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 Jan 2021 08:39:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610699956; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lWqMch6QDfmT/tLbAqy5mMLqy5WGH6HlkG8XF9llMoA=; b=LRwLvOO7CE5FywY89eQIQ8RiaTdKHUqk9OzS8srk0N9RgVfXSFCbWiN5wGTdhEVIXuGYWZ ajRqXChBm2ZkDso/+MB7iwDb8n/nBIJ36Nd0xTmv6jbf3fpAEHw942l9Kl0aUkXmdv9XCA FnwE4Tl8HN91Q8sgy6uj+heW6YitEhI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-430-RB4Cml0SMYmz5_Hgzrb9pw-1; Fri, 15 Jan 2021 03:39:12 -0500 X-MC-Unique: RB4Cml0SMYmz5_Hgzrb9pw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0A82010051A4; Fri, 15 Jan 2021 08:39:10 +0000 (UTC) Received: from [10.36.112.11] (ovpn-112-11.ams2.redhat.com [10.36.112.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54ECE5C239; Fri, 15 Jan 2021 08:39:06 +0000 (UTC) Subject: Re: [PATCH 2/2] mm: introduce PAGE_FLAGS() to make output of page flags better To: Yafang Shao , cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, willy@infradead.org, hannes@cmpxchg.org, mhocko@suse.com, osalvador@suse.de, linmiaohe@huawei.com, steven.price@arm.com, guro@fb.com, alexander.h.duyck@linux.intel.com, ying.huang@intel.com Cc: linux-mm@kvack.org References: <20210115061349.67386-1-laoar.shao@gmail.com> <20210115061349.67386-3-laoar.shao@gmail.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: Date: Fri, 15 Jan 2021 09:39:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20210115061349.67386-3-laoar.shao@gmail.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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 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. > > 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. > 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