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=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,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 0BB92C433DB for ; Thu, 28 Jan 2021 13:19:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 94C4064DE0 for ; Thu, 28 Jan 2021 13:19:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94C4064DE0 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 EA86B6B0075; Thu, 28 Jan 2021 08:19:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E588A6B0078; Thu, 28 Jan 2021 08:19:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D96C76B007B; Thu, 28 Jan 2021 08:19:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0126.hostedemail.com [216.40.44.126]) by kanga.kvack.org (Postfix) with ESMTP id C19476B0075 for ; Thu, 28 Jan 2021 08:19:01 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 87F101F06 for ; Thu, 28 Jan 2021 13:19:01 +0000 (UTC) X-FDA: 77755239282.13.sleep97_4d12fb32759f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 6F8FC18140B60 for ; Thu, 28 Jan 2021 13:19:01 +0000 (UTC) X-HE-Tag: sleep97_4d12fb32759f X-Filterd-Recvd-Size: 5166 Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Thu, 28 Jan 2021 13:19:00 +0000 (UTC) Received: by mail-io1-f43.google.com with SMTP id y19so5524737iov.2 for ; Thu, 28 Jan 2021 05:19:00 -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=gjy6o/hBoBKHdPHDXM51PZiuX5YGQ+mMH4IEIhNoHVg=; b=p+lsnKT+rIJdPmdWBsl7+xoHGQ3RV0xpDcav7tLVH2vgSgvZhvgXnmQw43jJsCHwvf Qkw7HFMCbtMH2UmHdidk1u3ryARbgEVHuhgK++8rlIegsBjsGzNzzwu426gzFtZm5S6w jHwTXJjxjkCZEElzYuHoknqDkYQDRgxSGX1EggkcbOdEWmU0VadQiN+kyOC6gpc7rHDq 59o1+0+r+H02hg7RyV+ZxyVimN0ovWlCWUr1k9U/kFvmpnldXNXQ1sWRx9EVL3qgm5UN dDXw+agUJa1OzFvlfqxM2lqkuofpP35o1BoebAkkfvXG+uDbVLLmcnS9GdSPM/b/e+jI fNJw== 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=gjy6o/hBoBKHdPHDXM51PZiuX5YGQ+mMH4IEIhNoHVg=; b=ZiuBXqB8jCNzxMH78IC0pGqYVJ2oafhn7nLDdc1HpvlZ2FeAtxxjkId4B9pkN902BK 0paxjK4wgmSFL69/MZjKAiB0Zj1dJLKE+wQVSHygQ+URaVOdJDtRxpdQscE0bFOUR8fx ewsVAZZ7BM6Qa/XCsqdFllZ9RtBprTbsjkrit+Csaz/WuUIGtMPcdwlUGrU022XZUGpv tXOaoHswgGpnj84dlLv1+PC6cA1RE7U+TF1yWFxZlkceeuhqIQazpPCTaYitlUAkYaLB CpNC+cG8N21FRGXxmu7QJm1Hb0tJCMaS30OqLYUgsCWMR9C7GjYWvN/IXL+wMss4hrwv 7SSg== X-Gm-Message-State: AOAM5311OkR82ffQAU1o1qoIK8/ACHKVuwfU6eQR7bkW3fn3cZ2ie0Te Qmo95xWbaZBuUytMea1NPmwVqtaYIsCl67f2s6w= X-Google-Smtp-Source: ABdhPJwCE8tynFIbe8qGDUc9yNjnhzR6XHtmoxy88HRWO1HvCwvh5LdWN4aM9o1DIWHdj5/hdQAP5PGAKVNEjnRcnJ8= X-Received: by 2002:a5d:9487:: with SMTP id v7mr11210434ioj.202.1611839940515; Thu, 28 Jan 2021 05:19:00 -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 21:18:24 +0800 Message-ID: Subject: Re: [PATCH 3/3] printk: dump full information of page flags in pGp To: Andy Shevchenko Cc: David Hildenbrand , Vlastimil Babka , 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 Thu, Jan 28, 2021 at 8:11 PM Andy Shevchenko wrote: > > 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. > Thanks for pointing this out. > > + 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. > I will take a look at the detail in these two functions. > > + 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++; > > > + } > Thanks for the explanation. I will change it as you suggested. -- Thanks Yafang