Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp799080pxb; Wed, 27 Jan 2021 23:46:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhWNTE5/14+jhMvvWLQ5ow+rrCKN80gs04mxtcf/VsE9l2O528saRFUQUpLeGApxxA0URy X-Received: by 2002:aa7:cdcb:: with SMTP id h11mr12775959edw.237.1611819964900; Wed, 27 Jan 2021 23:46:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611819964; cv=none; d=google.com; s=arc-20160816; b=QtolTNzOGk9gtdFCjpa6xvZV8PROZ9NYzqn/T97oMCtAfK+o22OPZ7zQy7PydrbccS FSttB+rVkCioYL7QkgXSVetLsbFdyjNUXVQ0qTwq5uqyjYAasUiRKpYr2f7G4ugsjeZt dL+z6qpvML3EktJXbPBD4kUIpisSZPEl+dHR5IiS440cShr4jtqH7Riipx02wwTjRyN0 nES+ijwPR/j7KsEXwvEs6vOhAgQqRmV1QEuUuRZlqQPuR65tzdJoYtb2rYlMI1udXAPZ XgW6ATQ9SXZ18uD79/cFSwAL44cFBB+2RIbba5UbquU/otOZ7oQe1byCY1jru1KVKHq/ 62RQ== 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=R34wmap4SlZQiVdkg4GoUNHYognsPIau3/lAsDGw4ww=; b=cro2ohCNhdeFm4H5wL0vGRBcFcCeQ/QX9oa2FYDs0PWOpfmpYmKed2dID6ObdRnUk2 WASD9/PuhC6Ualz6qMrllsMMsaTeLq+YnA8duIGIYwEagnA6cIiECkPHnwat9jxgBrVD M7LMZn6VePCEFhzf7FWB/0r7KP71uOLYaDQNb/rCQKXrohuyCOkhF9VIzTCJqBBQ/3ag 1ZIROexSV4KBkiMkwMUqBJi6yIqM/6fThojFScPqMtebAYd4rrhjuXLYkhQYm/hZ9Na5 sKmh0XhIcMFhcwPAK1d7KzXgMWikFkqsc4VnNDAWIxt9ygX5RLUg2BfWhnnP8xLVgfnI cOPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JuwSz00A; 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 p5si2514548edj.169.2021.01.27.23.45.40; Wed, 27 Jan 2021 23:46:04 -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=JuwSz00A; 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 S232024AbhA1HpG (ORCPT + 99 others); Thu, 28 Jan 2021 02:45:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232157AbhA1Hnz (ORCPT ); Thu, 28 Jan 2021 02:43:55 -0500 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52EF7C0613D6 for ; Wed, 27 Jan 2021 23:43:15 -0800 (PST) Received: by mail-il1-x136.google.com with SMTP id p15so3666647ilq.8 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=ZP9fq5mJJlLYYkMzX3GQzHhIk1T2XJis9HGO4SvU/SrZhVQxM65mjD25hCFEU1StMB /KdPIZnOxjyRruHzfaWZxKY8OhfEDu+xBVXpCz6LYix2SmZdyxG/L8cvRMVKaAv/vzJJ jPO6iuT8v6iv4HuxBfMbW2S3g3He+mdUFIRuNZVAlREzhib68er8d6sDYS2b0+d9WK2a 9bCckjKH+3jKI9Mck4nhmsG72vnR/5r0t88djoD7/i7oUdNpVmWOk9YCNlUHTMt8sU6q WMiCYpgwVv006yphUGIXGNwr8p+U5jNnF+e9SWZ/2r79tfuILCu/kkH60eJT+VU+dtf3 1ZOQ== X-Gm-Message-State: AOAM5303ODr1nXh+Cq9xfO3F2b1ZE5yfzX5V/OVWMotZIWgkLzNZXIOR rMOniN5aRTVoGgObYaUhvz4osgG5NByzxUynUFs= 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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