[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YBKp/NHanaN4e0im@smile.fi.intel.com>
Date: Thu, 28 Jan 2021 14:11:40 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Yafang Shao <laoar.shao@...il.com>
Cc: david@...hat.com, vbabka@...e.cz, cl@...ux.com, penberg@...nel.org,
rientjes@...gle.com, iamjoonsoo.kim@....com,
akpm@...ux-foundation.org, pmladek@...e.com, rostedt@...dmis.org,
sergey.senozhatsky@...il.com, linux@...musvillemoes.dk,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] printk: dump full information of page flags in pGp
On Thu, Jan 28, 2021 at 10:19:47AM +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.
>
> - 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)
> + int i;
> +
> + for (i = 0; i < sizeof(pfl) / sizeof(struct page_flags_layout) && buf < end; i++) {
'buf < end' is redundant.
> + if (pfl[i].width == 0)
> + continue;
> +
> + buf = string(buf, end, pfl[i].name, default_str_spec);
> + if (buf >= end)
> + break;
Can you rather use usual patter, i.e.
if (buf < end) {
...do something...
}
buf++; // or whatever increase should be done
Moreover, number() and string() IIRC have the proper checks embedded into them.
> + buf = number(buf, end, (flags >> pfl[i].shift) & pfl[i].mask,
> + default_flag_spec);
> + if (buf >= end)
> + break;
> + *buf = ',';
> + buf++;
Here is a very standard pattern can be used, see code around
if (buf < end)
*buf = ',';
buf++;
> + }
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists