Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp976928pxb; Thu, 28 Jan 2021 05:20:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwK67KXvA18sZHddyw4wPNGhWSMZm7gOezKydg46pOZMxV/4MxKJz0mS2LBAqg9d51120pX X-Received: by 2002:a05:6402:79a:: with SMTP id d26mr13684623edy.266.1611840046156; Thu, 28 Jan 2021 05:20:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611840046; cv=none; d=google.com; s=arc-20160816; b=QIU5MhCgjFtatNrasQ544XCBhY7+Y3aviBD5Yiql43z2FqiMVjkdpTR2vNYHTrkfC/ jhqZndXYT03BxOt2ItWo3KQCTAfOn9iVEyR24DTgLQep2cQJN7LjJ0+oLoEimYEmlkS+ 0nUsR3UsQkzGqARlBOCoSfu2pRaCMLuim4USWRXhqsIkc7IunbVqK/kl6t04tMN9M9Ih S0DbD30N3UbPeeQT6mtYZgX1WfDCxje7igDd+VRCstry4ks+epaVHcvLZ2LAQX3vDELi qGIafDb4Bu01D+ySdlAAMFisO3+vbjkOZUPypAL0aNdNKqlem63dgZhopU0ISEhU4hFR ROWg== 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=gjy6o/hBoBKHdPHDXM51PZiuX5YGQ+mMH4IEIhNoHVg=; b=tMXILhtd+zXQl9K/2Wm3MaPFXsc2sgPO7WHSOD+cB/KJldgMUTEc504TSZdwPgm9F9 0XA0IVsrtI+5tQwv0Pyb8oXvqS6INEGWXFBWMD0K5r34fKPLIn/qO1aAl1vD3nBg5oQf teT0qrPBalMfeVobyCUAHYUXNaZA+WJuq7MMa9YVA+MA94iwqMU9GngR7zzGxBugSH4j YPLOPzuz12qN+nIWxUswVvoHif4dfcEhVYdyFsHEXYzz/lUkx3/VLgm7/mQa/CfqzgHi 9jwVRw8OOTmkFz4q22/Gp5fo1tDNETnOmNPmH5NU5+hDpVHwCeZsGzZD1nhpvKNKLyjW N4hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p+lsnKT+; 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 o26si3002279edw.74.2021.01.28.05.20.20; Thu, 28 Jan 2021 05:20:46 -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=p+lsnKT+; 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 S231797AbhA1NTo (ORCPT + 99 others); Thu, 28 Jan 2021 08:19:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231377AbhA1NTl (ORCPT ); Thu, 28 Jan 2021 08:19:41 -0500 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04580C061574 for ; Thu, 28 Jan 2021 05:19:01 -0800 (PST) Received: by mail-io1-xd36.google.com with SMTP id n2so5497503iom.7 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=iru1d2r6yg93cfCt2ge/+CZ1KiYhWjZcrgxG7XddnoAx4E7Gxq65JMh75007hEvBHr JLjvM4aMXmsz9Uwv+9ptHDaZ6idD15716hG9Td0vnz8d6gKIwjBrszyQ7k/dIovzYXwK KUh0Aik3CI1Nt/RRFfSymL5+q30uXKZNNoXGEFQE9sZKyueipMvUiFtnP59ruFniPB35 cmiXs8bmnEykjwaIwiFDKuxFp651w31rsUJpEUaSdR6Vy+Yo8jWOkHLfw7g0IJHH+3jC n+aHDPVZiRq4WsjGPVZcPYyuf7xKGqhqyu6s79KJk+ynq4husLU9Jh3UipPZH6pRi2vN q8MQ== X-Gm-Message-State: AOAM530RCDyNMMn8rAPoVz22uY/j9FkAZ3xBbSwVB/65U+IN0WN37vxP 7q/hxiyuumeUSmF8k7zQY1I17z6HcOtpOOHihyQ= 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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