From patchwork Fri Jan 15 06:13:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12021567 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 4D872C433E0 for ; Fri, 15 Jan 2021 06:14:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D228F239EF for ; Fri, 15 Jan 2021 06:14:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D228F239EF 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 395A68D00F0; Fri, 15 Jan 2021 01:14:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 344AC8D0062; Fri, 15 Jan 2021 01:14:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1BE348D00F0; Fri, 15 Jan 2021 01:14:34 -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 004678D0062 for ; Fri, 15 Jan 2021 01:14:33 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C067B180AD806 for ; Fri, 15 Jan 2021 06:14:33 +0000 (UTC) X-FDA: 77706995226.25.guide61_6211a882752d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 9770E1804E3BE for ; Fri, 15 Jan 2021 06:14:33 +0000 (UTC) X-HE-Tag: guide61_6211a882752d X-Filterd-Recvd-Size: 5107 Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 Jan 2021 06:14:33 +0000 (UTC) Received: by mail-oi1-f171.google.com with SMTP id w124so8536459oia.6 for ; Thu, 14 Jan 2021 22:14:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zvhC1vdHMd6q15+GIn6T1nxuE4aEd8qH0Yq/Vq8htpA=; b=Wq0sgJ9dYA1XKg/xtNzoXyCtGrLEMj2BAh4cGIgV6e8W55O6xZToqMPhfSuXxzqbRJ 3yh+LonuclqfF5pL++fvmigO3cfCPHsGJFLLX+NDRFJXNFM/BVuzo8OKkDHLPfUK1HR1 OyyywTR741Zo9lVMmDcSHeLbHgyENhxViBnk8OjYKTep/dRXr20qrqY9eOr4QVXgbhPe d7iFAC3dy2zK8msTfAmlqQ3CxK73mUrjhkC2Iy/otg1UF6RfVceAEXd3usQRE/3CGMpU brk9DFv/HskEbS7NG8p/JJKRRphIhYwjbyNRc2Hq8jLDb9FsGbODNVVRpGLhMsGzvIWg RiPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zvhC1vdHMd6q15+GIn6T1nxuE4aEd8qH0Yq/Vq8htpA=; b=M/nZJDP+JHs3fQukkyLGpIn/Md37V/7b51aksHGj95vWy+mdSz6jsJs6tGBlNg6XCG S96uMnD8LJrh4VcRouLEob5FwQxNZStVA9ZKtXE366VWuKZeVSMKf8EduOyGgPN8hqyc dglbVWChqTYCGJsmeTC/ByOSy8XM7NE3Lew6NqYZ5cOHmBQYpjDlmcAIoMFpZlMdqcQn NXCxx/N9rr/XsWIkyz6pof6XE97ztTLmjGabm4hgq2cW1V6ma3Wn7RsQPlVGS3rVO5Ok Kkd1brvb+E65d65dELfBFofzT7aCSIhnu98zvxsLY5Cah9m5b7VmLlD1/+Mu4pwMEijC g66A== X-Gm-Message-State: AOAM532SOUhjMjLKWbyA2yHoRZNXE6gfgNd9j2Bzk71NjN43iwMh25F3 HSHTvpM3pr5hDILpRSgLQKE= X-Google-Smtp-Source: ABdhPJx7D79BDb65+AIAEOlu4Q048OCl4D0Betr987y9apr6fqaq2XWXTvigYoNzdxs+EF0ipgq+lQ== X-Received: by 2002:aca:b145:: with SMTP id a66mr4841002oif.92.1610691272702; Thu, 14 Jan 2021 22:14:32 -0800 (PST) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id m7sm1586351oou.11.2021.01.14.22.14.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jan 2021 22:14:31 -0800 (PST) From: Yafang Shao To: 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, david@redhat.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, Yafang Shao Subject: [PATCH 2/2] mm: introduce PAGE_FLAGS() to make output of page flags better Date: Fri, 15 Jan 2021 14:13:49 +0800 Message-Id: <20210115061349.67386-3-laoar.shao@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210115061349.67386-1-laoar.shao@gmail.com> References: <20210115061349.67386-1-laoar.shao@gmail.com> MIME-Version: 1.0 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: 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. There're two choices to achieve that, one of which is clear the 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) 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); }