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=-15.3 required=3.0 tests=BAYES_00, 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 61C79C433DB for ; Thu, 28 Jan 2021 02:52:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CB67764DD0 for ; Thu, 28 Jan 2021 02:52:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB67764DD0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1F8E16B0070; Wed, 27 Jan 2021 21:52:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A83B6B0072; Wed, 27 Jan 2021 21:52:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 06F9E6B0073; Wed, 27 Jan 2021 21:52:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0140.hostedemail.com [216.40.44.140]) by kanga.kvack.org (Postfix) with ESMTP id E0D236B0070 for ; Wed, 27 Jan 2021 21:52:17 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id AD69B8249980 for ; Thu, 28 Jan 2021 02:52:17 +0000 (UTC) X-FDA: 77753659914.04.cat96_190a2f02759c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 8B659800CE63 for ; Thu, 28 Jan 2021 02:52:17 +0000 (UTC) X-HE-Tag: cat96_190a2f02759c X-Filterd-Recvd-Size: 4538 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Thu, 28 Jan 2021 02:52:16 +0000 (UTC) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DR4hw2sMNzlBqG; Thu, 28 Jan 2021 10:50:40 +0800 (CST) Received: from [10.174.179.117] (10.174.179.117) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Thu, 28 Jan 2021 10:52:11 +0800 Subject: Re: [PATCH 3/3] printk: dump full information of page flags in pGp To: Yafang Shao CC: , , , , , , , , , , , , , References: <20210128021947.22877-1-laoar.shao@gmail.com> <20210128021947.22877-4-laoar.shao@gmail.com> From: Miaohe Lin Message-ID: <27e53062-7b0e-42e8-6f44-4eba44832805@huawei.com> Date: Thu, 28 Jan 2021 10:52:11 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210128021947.22877-4-laoar.shao@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.117] X-CFilter-Loop: Reflected 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: Hi: On 2021/1/28 10:19, Yafang Shao wrote: > Currently the pGp only shows the names of page flags, rather than > the full information including section, node, zone, last cpupid and > kasan tag. While it is not easy to parse these information manually > because there're so many flavors. Let's interpret them in pGp as well. > > - Before the patch, > [ 6312.639698] ERR: Slab 0x000000006d1133b9 objects=33 used=3 fp=0x000000006d0779d1 flags=0x17ffffc0010200(slab|head) > > - After the patch, > [ 6315.235783] ERR: Slab 0x000000006d1133b9 objects=33 used=3 fp=0x000000006d0779d1 flags=0x17ffffc0010200(Node 0x0,Zone 0x2,Lastcpupid 0x1fffff,slab|head) > Thanks. This really helps! > Cc: David Hildenbrand > Signed-off-by: Yafang Shao > --- > lib/vsprintf.c | 42 +++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 41 insertions(+), 1 deletion(-) > > diff --git a/lib/vsprintf.c b/lib/vsprintf.c > index 3b53c73580c5..bd809f4f1b82 100644 > --- a/lib/vsprintf.c > +++ b/lib/vsprintf.c > @@ -1916,6 +1916,46 @@ char *format_flags(char *buf, char *end, unsigned long flags, > return buf; > } > > +struct page_flags_layout { > + int width; > + int shift; > + int mask; > + char *name; Should we add const for name ? > +}; > + > +struct page_flags_layout pfl[] = { Should we add static const for pfl[] as we won't change its value and use it outside this file ? > + {SECTIONS_WIDTH, SECTIONS_PGSHIFT, SECTIONS_MASK, "Section "}, > + {NODES_WIDTH, NODES_PGSHIFT, NODES_MASK, "Node "}, > + {ZONES_WIDTH, ZONES_PGSHIFT, ZONES_MASK, "Zone "}, > + {LAST_CPUPID_WIDTH, LAST_CPUPID_PGSHIFT, LAST_CPUPID_MASK, "Lastcpupid "}, > + {KASAN_TAG_WIDTH, KASAN_TAG_PGSHIFT, KASAN_TAG_MASK, "Kasantag "}, > +}; > + > +static > +char *format_layout(char *buf, char *end, unsigned long flags) > +{ > + int i; > + > + for (i = 0; i < sizeof(pfl) / sizeof(struct page_flags_layout) && buf < end; i++) { I think we can use ARRAY_SIZE here. > + if (pfl[i].width == 0) > + continue; > + > + buf = string(buf, end, pfl[i].name, default_str_spec); > + > + if (buf >= end) > + break; > + buf = number(buf, end, (flags >> pfl[i].shift) & pfl[i].mask, > + default_flag_spec); > + > + if (buf >= end) > + break; > + *buf = ','; > + buf++; > + } > + > + return buf; > +} > + > static noinline_for_stack > char *flags_string(char *buf, char *end, void *flags_ptr, > struct printf_spec spec, const char *fmt) > @@ -1929,7 +1969,7 @@ char *flags_string(char *buf, char *end, void *flags_ptr, > switch (fmt[1]) { > case 'p': > flags = *(unsigned long *)flags_ptr; > - /* Remove zone id */ > + buf = format_layout(buf, end, flags & ~((1UL << NR_PAGEFLAGS) - 1)); > flags &= (1UL << NR_PAGEFLAGS) - 1; > names = pageflag_names; > break; > Many thanks.