Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp936100pxb; Thu, 28 Jan 2021 04:14:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNLb4g7JbKXGHgSwyV9xvtWZ/bkAA++N8L5T0mLw70SZnqit3VYKPZ8TDB2utkrsqs2eI6 X-Received: by 2002:a50:d7c7:: with SMTP id m7mr13307486edj.260.1611836095176; Thu, 28 Jan 2021 04:14:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611836095; cv=none; d=google.com; s=arc-20160816; b=liYXUne37niMVe8AxPIDmN1vkaAISWBVxN9HLVKVrTynuJIzf4KdeOQj6cyyyzntyO iJPw8BxqaxUIF6wiQIeHClfNtMvRX1q/0pVqoBG1KHnPizWD8BMaqWyr8oGz4uMKViaI wyVTvKGjfn6eVFCVua2/TM5aymJx67APy+8ZnntQbWCZXRA55LdP1YJW7IFBv1dxcVil bG/2pLeCRlOQIU8vc5E5q5TA0M6eeWM2zi6LnN6+Ut15fssbF9eXBMBPyCBbVFMqv31Q NPq4YdRqTIXWIJvIUwYFsD6shqIlpnOpWgsPDWl2RJ8YU69UMCfaLNsE1zHahT0xdDHa Zqsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=++IysbRj+LNN+010b+/vjkqqCykXiqpOI9wexROa+AQ=; b=r8kKSB+fyqtaafK+wwFTYdDoGFJVuW4xS/B19lKDdxNPOo/+WhoJm+cKL1K3Mu3laW F/NnmFiF5b14HjdZlBYNwdKOWEgtvx0bn/TB2EYqErcnFPSHwqEr9mdrXUWw8qL3487D UMh7ChkAnUAV7A1FUQ/fJMpfIRsPwEjqYuHCa5UMq+3vrhDwFYZxV3PjXn3xikinWYqU sMsLJMm6FppU2lv+5AVQaqjSLHjdrd56xv+E1I/KL82R5rQjWffHy/zzuz020IE1QwST GIwfRVH6QdG0s9PM/twErRgFvdMupfuqrv9qQpVhc6CMEWXvXG4RylkTeaGrjFCyHStj Tf6w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ch26si2679508edb.142.2021.01.28.04.14.31; Thu, 28 Jan 2021 04:14:55 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231289AbhA1MNd (ORCPT + 99 others); Thu, 28 Jan 2021 07:13:33 -0500 Received: from mga04.intel.com ([192.55.52.120]:60572 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231140AbhA1MNc (ORCPT ); Thu, 28 Jan 2021 07:13:32 -0500 IronPort-SDR: KQIsxC6qVn1epKINX0oSYHeNswnC3vLgAQLF++Z0xBUVjxL5TMWSec1TNEBxTmd0yjfD45tp9d el4eFuosvdSA== X-IronPort-AV: E=McAfee;i="6000,8403,9877"; a="177659408" X-IronPort-AV: E=Sophos;i="5.79,382,1602572400"; d="scan'208";a="177659408" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2021 04:11:46 -0800 IronPort-SDR: NRqnpaZs94Xm3cujH/NE9gw1GH+XGQjSV20xB4tNWEun0KolGuhZUcsDT4D7p9erKY9u4+5HAD JS9W9saPI1Hw== X-IronPort-AV: E=Sophos;i="5.79,382,1602572400"; d="scan'208";a="394393288" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2021 04:11:43 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1l569E-0002OU-0x; Thu, 28 Jan 2021 14:11:40 +0200 Date: Thu, 28 Jan 2021 14:11:40 +0200 From: Andy Shevchenko To: Yafang Shao Cc: david@redhat.com, vbabka@suse.cz, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, linux@rasmusvillemoes.dk, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] printk: dump full information of page flags in pGp Message-ID: References: <20210128021947.22877-1-laoar.shao@gmail.com> <20210128021947.22877-4-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210128021947.22877-4-laoar.shao@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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