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=-7.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 5DAD4C433E0 for ; Thu, 28 Jan 2021 07:43:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D700264DD8 for ; Thu, 28 Jan 2021 07:43:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D700264DD8 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 2D7A56B0005; Thu, 28 Jan 2021 02:43:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 291AB6B0006; Thu, 28 Jan 2021 02:43:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1756D6B006C; Thu, 28 Jan 2021 02:43:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0176.hostedemail.com [216.40.44.176]) by kanga.kvack.org (Postfix) with ESMTP id F1A806B0005 for ; Thu, 28 Jan 2021 02:43:15 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C05C21EF2 for ; Thu, 28 Jan 2021 07:43:15 +0000 (UTC) X-FDA: 77754393150.03.sock01_570b00a2759d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id A465428A4E8 for ; Thu, 28 Jan 2021 07:43:15 +0000 (UTC) X-HE-Tag: sock01_570b00a2759d X-Filterd-Recvd-Size: 5424 Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Thu, 28 Jan 2021 07:43:15 +0000 (UTC) Received: by mail-il1-f182.google.com with SMTP id g7so3297597iln.2 for ; Wed, 27 Jan 2021 23:43:15 -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=R34wmap4SlZQiVdkg4GoUNHYognsPIau3/lAsDGw4ww=; b=JuwSz00A+EuJFHf+7JP6WRl7/DURYn5ADwiJCNhLZzTHtNOFDXGVP0o8+5yGgHIhB0 xoDpPwv7XvdNxjkpyYQloIf8k15L19G6Tf4XCXIwoZKzoM/6lAy0CF2AL/b2ICrVZbzY ZLczipoHHHL9Z7EC/5ZY26L2JNlBO0ctsouL7sITUMzq4PwcDQT52UuRItUqobhGn5Fs UbHNMDjBkBbkAxh2jV3oDoIib7kH+8Iv1+02uRUBnwBRmEemKLsxwo0AlBHC3RsIkNtL 4zgeDBlQ3qOvwzsYRSTxX5zKLbOJ91nCEllpeLsxXXu8LdejczL+K3m/FpyEDbxPwAMZ FTMQ== 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=R34wmap4SlZQiVdkg4GoUNHYognsPIau3/lAsDGw4ww=; b=LdWU+2YrxkJkGKdKuRB0FZmKArS/Qp9msgORe1dU2C53H6ymnQnZIzSIyt0vb0yC/c wB3YSLl2LC/n1Hobj9ya3g2t/aAYn3OhI2LaMe8n6g8iyGm2ionEuYDGQbgCkRTOfdiz cz2wAHHCvNOLCMLfkA76kWRbYYOiI/iRAH+Yy0PuLe+q8MX5cRV19jH4SxPqJGHKL5j2 PQPplq3KdAHdBuTi6hnqW/tUW+DDCD/9R3yc0RpiuMFsZQMuTy51nJGD76B26NcZi+KV MpjqQNycPZOHE8jpbFu1NgP+OKnbvvPOJW+mjdsOOU5TRsTA3ZIj4HClyAxgsYvr94dk T47g== X-Gm-Message-State: AOAM532edUQb1O/YaxWpJw1huszoD6Y1Zrc1WQE+ydUBuMXfCpejZm0X YnB5BStd0vjCSrNNreTxVyW3hoOVIM2qyfCjNYE= X-Google-Smtp-Source: ABdhPJxfPmtA//UDL6jbaBgYGr0yMcusgQaCXh5P1cB6yZXF4048HMIeXPZjLU+v01hQMHmgzwsfGqjp0Jq37WEBIfM= X-Received: by 2002:a92:5bc2:: with SMTP id c63mr11989709ilg.142.1611819794700; Wed, 27 Jan 2021 23:43:14 -0800 (PST) MIME-Version: 1.0 References: <20210128021947.22877-1-laoar.shao@gmail.com> <20210128021947.22877-4-laoar.shao@gmail.com> In-Reply-To: From: Yafang Shao Date: Thu, 28 Jan 2021 15:42:38 +0800 Message-ID: Subject: Re: [PATCH 3/3] printk: dump full information of page flags in pGp To: Joe Perches Cc: 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 , Linux MM , LKML Content-Type: text/plain; charset="UTF-8" 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 Thu, Jan 28, 2021 at 10:35 AM Joe Perches wrote: > > On Thu, 2021-01-28 at 10:19 +0800, 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. > [] > > diff --git 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; > > +}; > > + > > +struct page_flags_layout pfl[] = { > > static const struct page_flags_layout pfl[] = { 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) > > poor name. perhaps format_page_flags > Thanks for the suggestion. > > +{ > > + int i; > > + > > + for (i = 0; i < sizeof(pfl) / sizeof(struct page_flags_layout) && buf < end; i++) { > > for (i = 0; i < ARRAY_SIZE(pfl) && buf < end; i++) { > Sure. > > > @@ -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; > > Perhaps store the bitshift into a temp and use the temp twice > > foo = BIT(NR_PAGEFLAGS) - 1; > > buf = format_layout(buf, end, flags & ~foo); > flags &= foo; > > Thanks for the suggestion. I will change them all. -- Thanks Yafang