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 A5F94C433E0 for ; Mon, 1 Feb 2021 13:27:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4B98364E8F for ; Mon, 1 Feb 2021 13:27:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4B98364E8F 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 C67F76B0078; Mon, 1 Feb 2021 08:27:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C18F96B007B; Mon, 1 Feb 2021 08:27:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B06976B007D; Mon, 1 Feb 2021 08:27:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id 9CD856B0078 for ; Mon, 1 Feb 2021 08:27:51 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 630588249980 for ; Mon, 1 Feb 2021 13:27:51 +0000 (UTC) X-FDA: 77769776742.25.rose12_4a178fb275c2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 39DD11804E3BE for ; Mon, 1 Feb 2021 13:27:51 +0000 (UTC) X-HE-Tag: rose12_4a178fb275c2 X-Filterd-Recvd-Size: 6727 Received: from mail-il1-f178.google.com (mail-il1-f178.google.com [209.85.166.178]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Mon, 1 Feb 2021 13:27:50 +0000 (UTC) Received: by mail-il1-f178.google.com with SMTP id p8so15525066ilg.3 for ; Mon, 01 Feb 2021 05:27:50 -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=BELtHAvSCgNIbArcYZ8LXqCZU44K+DZgMM7UPty4+Ck=; b=rxG5wyGX/Y6ekS24eiiM+iaARCjJBBzR493zvgJTN/Vs9/2DvSiuFE4uJInzu04i9u V9OvCgqiSbbagdd4uORfigyCy4gF5I0uNE018C5kb6VagrhjY2/zj/lEsy8b7mFhJg4c E+olhQMHnV3kd29b7CtPyT52NKRtE6ssFgDtTCMlOI1phOQyyeWCf+FJMyUKAOuB5oZz 4ImGmnwtTsxVYTlI0u3bXSXPL4KWPGroYmVnPm51/fKWUdujGjFoor5b8mua8sTl7i1N 1bMSJTCU3VP2nTHxvs/8DByiBEsc8V3tsocZ+0VD/9IbbwoHuCXRx7tfl9nb4OURgEL4 ZfgQ== 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=BELtHAvSCgNIbArcYZ8LXqCZU44K+DZgMM7UPty4+Ck=; b=SyQ6H87FLTuF+3Sgp9jBUPSxklt5gFldpMFUeNl6hvpTFNQp5R80QsW71Q0jBQHYTr B6cTF/BR/ZQWPEfWbP6VkU6U34JwOMkBd2LdrdFmOc9fITAV/ip/cOs5ULIVNMo2+dvq sCuqxqNGdWzC3OFURV5cSwHN8O4HcpX5Ftf/PK44Yk+yjmcFUr6Db2/+xTZ00Ok4jhqa wuCI5xCT22hYamxNW/nqJYQjRUOguOrBKvLVgHmWkOXkZVOqkXC0hlj5Rr3VmVr00tJ2 KDlJFi/mqlotQqDm0YDtQZNd1z4i+5dEvV2x/tHvosrZeX9MJ2hK81hFZCbv3pJm6sxq BgMQ== X-Gm-Message-State: AOAM5333VCBl11gJaiuNKdCXoXCOHwubYsJwPGrg/UqbDmzvSNO5h2t0 TPtac4g5sEEXe3jwyXPosqHZwGCLD2YvdGz64jc= X-Google-Smtp-Source: ABdhPJzV7Z6kKvJpPf0/EKLZ2SR/67ZFHUSyKbWOtrxHb1803ZxJDk0fr92/CvRT8dsPTS2WzyJaua3XToEUNvff4bY= X-Received: by 2002:a05:6e02:1447:: with SMTP id p7mr12795583ilo.93.1612186070191; Mon, 01 Feb 2021 05:27:50 -0800 (PST) MIME-Version: 1.0 References: <20210201115610.87808-1-laoar.shao@gmail.com> <20210201115610.87808-4-laoar.shao@gmail.com> <06481a01f551697d42c792506f3538d459ce8bdd.camel@perches.com> In-Reply-To: <06481a01f551697d42c792506f3538d459ce8bdd.camel@perches.com> From: Yafang Shao Date: Mon, 1 Feb 2021 21:27:14 +0800 Message-ID: Subject: Re: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp To: Joe Perches Cc: Andy Shevchenko , David Hildenbrand , Vlastimil Babka , Miaohe Lin , Christoph Lameter , penberg@kernel.org, David Rientjes , iamjoonsoo.kim@lge.com, Andrew Morton , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , 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 Mon, Feb 1, 2021 at 9:05 PM Joe Perches wrote: > > On Mon, 2021-02-01 at 19:56 +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, > > [ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head) > > > > - After the patch, > > [ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head) > > While debugfs is not an ABI, this format is exported in debugfs to > userspace via mm/page_owner.c read_page_owner/print_page_owner. > Right, the page_owner will be affected by this change. > Does changing the output format matter to anyone? > The user tools which parse the page_owner may be affected. If we don't want to affect the userspace tools, I think we can make a little change in page_owner as follows, unsigned long masked_flags = page->flags & (BIT(NR_PAGEFLAGS) - 1); snprintf("..., %#lx(%pGp)\n", page->flags, &masked_flags); > > diff --git a/lib/vsprintf.c b/lib/vsprintf.c > [] > > +static > > +char *format_page_flags(char *buf, char *end, unsigned long page_flags) > > +{ > > + unsigned long flags = page_flags & ((1UL << NR_PAGEFLAGS) - 1); > > + int size = ARRAY_SIZE(pfl); > > There's no real value in used-once variables. > > > + bool separator = false; > > + int i; > > + > > + for (i = 0; i < size; i++) { > > Use ARRAY_SIZE here instead > Sure > for (i = 0; i < ARRAY_SIZE(pfl); i++) { > > > + if (pfl[i].width == 0) > > + continue; > > + > > + if (separator) { > > + if (buf < end) > > + *buf = ','; > > + buf++; > > + } > > + > > + > > + buf = string(buf, end, pfl[i].name, *pfl[i].spec); > > + > > + buf = number(buf, end, (page_flags >> pfl[i].shift) & pfl[i].mask, > > + *pfl[i].spec); > > + separator = true; > > + } > > Style question: > Might this array be more intelligible with pointers instead of indexes? Good suggestion! I will change it in the next version. > Something like: > > struct page_flags_layout *p; > > for (p = pfl; p < pfl + ARRAY_SIZE(pfl); p++) { > if (p->width == 0) > continue; > > if (p > pfl) { > if (buf < end) > *buf = ','; > buf++; > } It doesn't work, because there's a 'continue' above, meaning that the p may be greater than pfl without doing anything. > > buf = string(buf, end, p->name, *p->spec); > buf = number(buf, end, (page_flags >> p->shift) & p->mask, *p->spec); > } > > > + > > + if (flags) { > > Maybe: > > if (page_flags & (BIT(NR_PAGEFLAGS) - 1)) { > Sure. > > + if (buf < end) > > + *buf = ','; > > + buf++; > > + } > > + > > + return buf; > > +} > > + > > -- Thanks Yafang