Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp678119pxb; Wed, 27 Jan 2021 18:56:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfsYUMGx6zbVgMMRXfxUyWpljERJr/AImcmIPvOxejP7NbR+Qsqpz2DtRBJZCv0GU1x/D7 X-Received: by 2002:a05:6402:110b:: with SMTP id u11mr12215325edv.57.1611802612379; Wed, 27 Jan 2021 18:56:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611802612; cv=none; d=google.com; s=arc-20160816; b=iIF9lcqlAmijrTSO4bJjxAVJVAK3fsJw66yn0QuvShQZae9CdjUdHgD5KYkl0dpp9l cBWFilFtmLiEWtmcOGMDxS2ewiADKBHoWIBHBJMxRGE2WWngxHGoO1I0nJDqB7rtaVqo 2Gtq0pvYzPDdXC3bJaCoA6ljhUP+kZ/S42sRhwlwemj2zhC8zoEa0e1d5El/qtV0G5Ie eLsltC80uAo3knKXXiqBe9BXEkHFWT6xiF2AFc2dso31r4NfTWcbeopr8eHTYIo0M9S/ GznVYjlnLHF49vd48lza52AbWYiRkDVhpKQxFujBR72IuYwXSJWL40YT9J9/peQnVSa4 rUGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=ilvhGA2HwQvBRlCB4ZW/bs7ZfIyf9IvdsCWYegOKjLI=; b=YL0tf87AkORzeFItQCvCAz1VH5TPmU8fvQV6Joo6NJLI6E7BigmoUhb0XnTf/vJDwy bioUeyPbuNEy8DRA2YSX3eOvensZ6Ay8OcLuoddKJ52tHY1dr9WR2tpuWKAOOdF5rCjU hVhg1s4tQUhc4KTRwPSVqNx283lul+Boin2CL3by1l5YY1WXzOu6D2KO4ulnW2yL7yj+ oLMF/51XKVz95c01pJbOHPJfdJgx+4VLeWWMxuga07BvLcq3gcP5Q95Ixz71has2Ri+S irna2ZcfOWei7dQ3RrEKPx9Aa5OSrrIwUa7WqGNVyCqHdCqeO6tLyz2k4lzl7ldqTHng I09w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z22si1782627ejr.655.2021.01.27.18.56.27; Wed, 27 Jan 2021 18:56:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231158AbhA1Cw5 (ORCPT + 99 others); Wed, 27 Jan 2021 21:52:57 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:11209 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231147AbhA1Cwz (ORCPT ); Wed, 27 Jan 2021 21:52:55 -0500 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.