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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0F09C4332F for ; Mon, 7 Nov 2022 11:19:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DF416B0071; Mon, 7 Nov 2022 06:19:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 268776B0072; Mon, 7 Nov 2022 06:19:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 109496B0073; Mon, 7 Nov 2022 06:19:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id F28386B0071 for ; Mon, 7 Nov 2022 06:19:04 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B69BEAB2C7 for ; Mon, 7 Nov 2022 11:19:04 +0000 (UTC) X-FDA: 80106399408.30.8C25360 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf27.hostedemail.com (Postfix) with ESMTP id 380DD40004 for ; Mon, 7 Nov 2022 11:19:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667819943; x=1699355943; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=cvxDWNtZzVvqQ3+pEhs6dDAy1QCbFhG4zWxy+4oWNiI=; b=MnesN7v0DX1jXyDCPHrDdLU+ny3serswjygsJn9JpMPrgYlbcbloxn+0 SrEDEXYJiOA1I9ipBLBe+DTUWxEiAiPnAqjvY9dfAbK/xWJruxefNhJ5L 5urBhDikZc/0o7GQcyeUh+8aMgcdxqf+bdFC5Ie8EvyuCQQQj/y4WahAB JbKpBurg/yra1L4+iA0K2PRU/6/tV3+1N5VnKOBP/Uj/7Fd6Wwk7xfdwZ IuFQY2Wz2nOwXpOSa1iBnnzefgpkSIZH833CXUfkXMLojxqcjtIxOkBbX gEMUIKsuFat5IcpErM49Oerv4PoTvH/WyImOxnLU+YGxFHHkJdRdI6v0l A==; X-IronPort-AV: E=McAfee;i="6500,9779,10523"; a="372507475" X-IronPort-AV: E=Sophos;i="5.96,143,1665471600"; d="scan'208";a="372507475" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 03:19:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10523"; a="725106215" X-IronPort-AV: E=Sophos;i="5.96,143,1665471600"; d="scan'208";a="725106215" Received: from smile.fi.intel.com ([10.237.72.54]) by FMSMGA003.fm.intel.com with ESMTP; 07 Nov 2022 03:18:55 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1os09U-008bap-0v; Mon, 07 Nov 2022 13:18:52 +0200 Date: Mon, 7 Nov 2022 13:18:52 +0200 From: Andy Shevchenko To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: linux-mm@kvack.org, Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Vlastimil Babka , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , Minchan Kim , Mel Gorman , Andrea Arcangeli , Dan Williams , Hugh Dickins , Muchun Song , David Hildenbrand , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Rasmus Villemoes , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC v2 3/3] mm, printk: introduce new format %pGt for page_type Message-ID: References: <20221106140355.294845-1-42.hyeyoo@gmail.com> <20221106140355.294845-4-42.hyeyoo@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221106140355.294845-4-42.hyeyoo@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667819943; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+wHjMAnz7v/IskSPhiKubAVcWtG3SxmIt6/fs85agUA=; b=y4cYXurlHrQJ/oGvyAMMyJt0edoEsicOJdBLtBmsybtuZo1mXuBTis/Zzc8K5g+OP9OUYx nxYjJCAoOJmVAGItEDzKT1EuElzn9+j3uvhcm2a0Nys9qdbxveB73y6io43bi8Rf00s/R4 x3rptdF4By42InNdYOVsoDhkJ3uFG7A= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=MnesN7v0; spf=none (imf27.hostedemail.com: domain of andriy.shevchenko@linux.intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=andriy.shevchenko@linux.intel.com; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667819943; a=rsa-sha256; cv=none; b=wDQVNV3gFnvGx3hehMANzFFTON6775fiR6uYIYtd63OLUAA7X6765wiAepczia/L7ny/B9 iYse3BTjT6kKRS98kkKwgo1NvFSyEe2Q1/EXJeG7oVJYYblAWyiCViaA9rvlZoSxk23Ug+ mgCH2VLdv2tP1s5pdL2GMyf1jg4NdtA= X-Rspamd-Queue-Id: 380DD40004 Authentication-Results: imf27.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=MnesN7v0; spf=none (imf27.hostedemail.com: domain of andriy.shevchenko@linux.intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=andriy.shevchenko@linux.intel.com; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none) X-Rspamd-Server: rspam10 X-Rspam-User: X-Stat-Signature: xudujbso8u8p3r7uimwmfm4z7txp3uiu X-HE-Tag: 1667819943-141888 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 Sun, Nov 06, 2022 at 11:03:55PM +0900, Hyeonggon Yoo wrote: > dump_page() uses %pGp format to print 'flags' field of struct page. > As some page flags (e.g. PG_buddy, see page-flags.h for more details) > are set in page_type field, introduce %pGt format which provides > human readable output of page_type. And use it in dump_page(). > > Note that the sense of bits are different in page_type. if page_type is > 0xffffffff, no flags are set. if PG_slab (0x00100000) flag is set, > page_type is 0xffefffff. Clearing a bit means we set the bit. Bits in > page_type are inverted when printing type names. > > Below is examples of dump_page(). One is just after alloc_pages() and > the other is after __SetPageSlab(). > > [ 1.814728] page:ffffea000415e200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x105788 > [ 1.815961] flags: 0x17ffffc0000000(node=0|zone=2|lastcpupid=0x1fffff) > [ 1.816443] page_type: 0xffffffff() Why do we have empty parentheses? I would expect either something there, or no parentheses at all. > [ 1.816704] raw: 0017ffffc0000000 0000000000000000 dead000000000122 0000000000000000 > [ 1.817291] raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000 > [ 1.817870] page dumped because: Before __SetPageSlab() > > [ 1.818258] page:ffffea000415e200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x105788 > [ 1.818857] flags: 0x17ffffc0000000(node=0|zone=2|lastcpupid=0x1fffff) > [ 1.819250] page_type: 0xffefffff(slab) > [ 1.819483] raw: 0017ffffc0000000 0000000000000000 dead000000000122 0000000000000000 > [ 1.819947] raw: 0000000000000000 0000000000000000 00000001ffefffff 0000000000000000 > [ 1.820410] page dumped because: After __SetPageSlab() > Cc: Petr Mladek > Cc: Steven Rostedt > Cc: Sergey Senozhatsky > Cc: Andy Shevchenko > Cc: Rasmus Villemoes > Cc: Jonathan Corbet > Cc: Andrew Morton > Cc: linux-doc@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Cc: linux-mm@kvack.org Can you utilize --cc parameter next time and avoid polluting commit message with this? We have archives where anybody can check this (and usually maintainers add a Link tag for that purpose). ... > + %pGt 0xffefffff(slab) No space before ( ? ... > +static > +char *format_page_type(char *buf, char *end, unsigned int page_type) > +{ > + if (!(page_type & PAGE_TYPE_BASE)) > + return string(buf, end, "no type for user-mapped page", default_str_spec); It's too long, can we make it shorten? > + buf = number(buf, end, page_type, default_flag_spec); > + > + if (buf < end) > + *buf = '('; > + buf++; > + if (page_type_has_type(page_type)) This should be check for the entire function. > + buf = format_flags(buf, end, ~page_type, pagetype_names); > + > + if (buf < end) > + *buf = ')'; > + buf++; > + > + return buf; > +} ... > @@ -36,6 +36,11 @@ const struct trace_print_flags pageflag_names[] = { > {0, NULL} > }; > > +const struct trace_print_flags pagetype_names[] = { > + __def_pagetype_names, > + {0, NULL} Hmm... I see it's already done like this above, but {} would suffice, why not to convert the rest first to the {} and use it here? > +}; ... > pr_warn("%sflags: %pGp%s\n", type, &head->flags, > page_cma ? " CMA" : ""); > + pr_warn("page_type: %pGt\n", &head->page_type); > + > print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32, > sizeof(unsigned long), page, > sizeof(struct page), false); > diff --git a/mm/internal.h b/mm/internal.h > index cb4c663a714e..956eaa9f12c0 100644 > --- a/mm/internal.h > +++ b/mm/internal.h > @@ -773,6 +773,7 @@ static inline void flush_tlb_batched_pending(struct mm_struct *mm) > #endif /* CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH */ > > extern const struct trace_print_flags pageflag_names[]; > +extern const struct trace_print_flags pagetype_names[]; > extern const struct trace_print_flags vmaflag_names[]; > extern const struct trace_print_flags gfpflag_names[]; I would split this to a separate change, but it's up to PRINTK maintainers. -- With Best Regards, Andy Shevchenko