Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp801330pxb; Wed, 27 Jan 2021 23:51:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxC0wNoDx6+srsqZyUtetk195V4lRfLfKtesyy/zGuvEWBRyD5w8wdit4btr6M+EQt7cm1l X-Received: by 2002:a50:fa86:: with SMTP id w6mr12602955edr.98.1611820278216; Wed, 27 Jan 2021 23:51:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611820278; cv=none; d=google.com; s=arc-20160816; b=kNMyR940Kb2XJ7CNtF1lvhaYOB2P/Fl1mgJ0pYw1ZnvMt6inPTORcloU+2hlt+hC6+ tky5jWWkeqp4WMqR15235HETiJhNFEjQFjXQLiREWy/P2dycGthhlPWPi8BpQAWXzMag kCIfSTZuuLXcx7MkwWrVAzRkEAQD0ABEZOER50SBvuuG/tZAI4E1mGjjJGCN1Gv/FkdE i9gIx34fw1zE8vEuMUNpQvFoFKj0QoXNGGA1SR5l/3hvmItl2YrM21Q54npo9JYKcUvn mt0KCrhPgzizKgPxQsdIkcBXB7zm6hpv3enNpzDOAA+rE1OSIq7MLaN6LvANN7MxEb3j xo6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ztUYIztZJjhj5tFTgkC2lU/YF4nMMpQ1Z9nSKOugLuE=; b=nLlz9JUzKDHjhUjSNHGsECSpPXZNzHceNBmhutok4N8igJZEIhZMKWNXI17uTnZQOe mTB7CYHxHrsm2daYEAI69giHClnXoFyequ4RqpPy12mhbSB/mAOEjGxJJ/9tgRyFecFu ABjfgRmEaD5stc9t5O3p+/RoTMADZbtJwweMsgk8rSGvLsLVzWWhSNzFYQDnTIsS9YEL +1R4WWHKUQ/M44/51ti65ktnu2Tm3EKZP5qF1mN4feqpyunzEP8mqmX+/V6YUPu9PyPA a73D/gGgYlgKt+roqe2kSvBbBrSh5K6cY0uOqyVMBCYSQ7zALfyAIB/szdhvQQ3xqw6L PMhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BnIWltQ+; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f16si2091693ejx.196.2021.01.27.23.50.54; Wed, 27 Jan 2021 23:51:18 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BnIWltQ+; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232217AbhA1Htw (ORCPT + 99 others); Thu, 28 Jan 2021 02:49:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231826AbhA1HpV (ORCPT ); Thu, 28 Jan 2021 02:45:21 -0500 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67960C0613D6 for ; Wed, 27 Jan 2021 23:44:41 -0800 (PST) Received: by mail-il1-x12d.google.com with SMTP id c20so4390229ilj.13 for ; Wed, 27 Jan 2021 23:44:41 -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=ztUYIztZJjhj5tFTgkC2lU/YF4nMMpQ1Z9nSKOugLuE=; b=BnIWltQ+ltM4LRkMogP4dKfVIO7xiPORVwxQ0nsXxhWa1OMmPQ4GucpEe2IKlqyiyO qPu2N5q9y/dQLjkdqAXqjloZXd7nOGxnHMSx9ZTjaTjrN+kon2+/7TPOHF+honm8KB1S psmdStrdSQGYK5ABjeFcm9+bscp6aYtbQ7YjNAIVnm1DaXlN4RSpTsckF14PXrnFPorU J0znJ2RG4GQMSOagUDSu1ksZ3bx8wpiO8fwY+H7K9aP/N/oek7kKdsvppEsCiZHF9f/Y 3DkjaGdBemoKcJ+wl6dZrzvQNz3EjiQkG/KiJB6vXLuc3BnUv8b9gCmkaADf6llDpv0N wBeg== 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=ztUYIztZJjhj5tFTgkC2lU/YF4nMMpQ1Z9nSKOugLuE=; b=kooNL+DWM71o1SQqYWuQNkZjCO5UtcZpiTausOAJKigcvvex/di+Z0E1SxVsXuyUce Vhk8xPjJMQIzMP9SMuELTOM9CLq1qrnacLRNA22+5dVQPEJE4VAx2telmnZb5oUbrPtC LVpcwjb2F8EMxBRBmVY0n47EeT7Pupcl8BFt2z01y5KYUv7gahkNyN+sX+XN1B4L8Apm UagP8HKDD5MS+xRu2Fvw/CXq70bTG1qkBoKB/UIhJaMSz8O4FQzSQEu7hvpLJ6QLMfsz gE5TonO6GQxqr9+/os8UEnX+RLLUhOnJ3lAvXs4oS/35E8kyEsxCR7467AjLHvLrIyrU QONg== X-Gm-Message-State: AOAM530BemeXf32vhG+9YynzKPeHG2vZsUfVQXHvE3PUK66RE2MVVCIR xiBxhIbcQ3IsUBbi485yizPmlS5AJEFTOlIZALo= X-Received: by 2002:a92:5bc2:: with SMTP id c63mr11992705ilg.142.1611819880901; Wed, 27 Jan 2021 23:44:40 -0800 (PST) MIME-Version: 1.0 References: <20210128021947.22877-1-laoar.shao@gmail.com> <20210128021947.22877-4-laoar.shao@gmail.com> <27e53062-7b0e-42e8-6f44-4eba44832805@huawei.com> In-Reply-To: <27e53062-7b0e-42e8-6f44-4eba44832805@huawei.com> From: Yafang Shao Date: Thu, 28 Jan 2021 15:44:04 +0800 Message-ID: Subject: Re: [PATCH 3/3] printk: dump full information of page flags in pGp To: Miaohe Lin Cc: Linux MM , LKML , David Hildenbrand , Vlastimil Babka , Christoph Lameter , penberg@kernel.org, David Rientjes , iamjoonsoo.kim@lge.com, Andrew Morton , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , andriy.shevchenko@linux.intel.com, Rasmus Villemoes Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 28, 2021 at 10:52 AM Miaohe Lin wrote: > > 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 ? > Good suggestion. > > +}; > > + > > +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 ? > Sure. > > + {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. > Sure. > > + 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. -- Thanks Yafang