From patchwork Mon Jan 30 04:25:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyeonggon Yoo <42.hyeyoo@gmail.com> X-Patchwork-Id: 13120405 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 A2E9DC54EED for ; Mon, 30 Jan 2023 04:25:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 16F0D6B0072; Sun, 29 Jan 2023 23:25:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 11F538E0002; Sun, 29 Jan 2023 23:25:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F027E6B0074; Sun, 29 Jan 2023 23:25:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E230D6B0072 for ; Sun, 29 Jan 2023 23:25:44 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B6572A0AFD for ; Mon, 30 Jan 2023 04:25:44 +0000 (UTC) X-FDA: 80410177008.25.D8D2C74 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf29.hostedemail.com (Postfix) with ESMTP id D585C12000B for ; Mon, 30 Jan 2023 04:25:42 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=TrsrcayB; spf=pass (imf29.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675052742; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Ddl5ubdJXdhY37QXaqSPFuWOXoIoME8XjzTIYCn2FfM=; b=JW0Od4milPX4Dfuj8uzxEFakVQd26S4YI1oQ4ryvEyIiWn9EeUuE7xlyM1ugxpkWsHQ2IS RTu5pBJUo051uHNoikSvqrwnuXZQdsl5j6MBp4CT9NVbJtZrviBex6UP3SlirrT67ai3FU YwDaGvFUCqkdh1ysJdGOLgPNzPpASHA= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=TrsrcayB; spf=pass (imf29.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675052742; a=rsa-sha256; cv=none; b=3m7aghsnFYhBbHgosEqDhS95K/bKqXrH4bA9EbJ2G+U785vVl2iKaTplb9zxrhBM8A2FZj zRtl6TNl2SjGK+D57Gd3k2mttmBfQuQPdWN6ULUBZE6hiFGgvJVuG3JfMgKfRZa0Qy6lRO zgU6wtB8hkVNRYe8zPIXKzibdoDvTZI= Received: by mail-pf1-f176.google.com with SMTP id n2so6842272pfo.3 for ; Sun, 29 Jan 2023 20:25:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ddl5ubdJXdhY37QXaqSPFuWOXoIoME8XjzTIYCn2FfM=; b=TrsrcayBW/ufr6B0b7ySUMgYrDdrlI1lmymJVug4Ai+xm9Efhi9PJpmJAq0XdcYAEi nQT+yasgYhwPxylv5Ay2NG7qWqlQEidG/nPOxhClNZYhEh1uCdBq6Cz66BopIlWiSax7 ZyAW40TGTUCdLLapAVdvy0LIAAidA2fB8uXqJ2+s1diIMYaNAA50slhM1O5gSS1CO2/D BM0Q6Af/Vk/ESFCz1P/NZBOr74dhaWS7ufOGHTwk9VFYGKrE8iV/LHBDBXLClRsiB4ai VYKlqSwQ8MYwtAExxiSyESGSy1lnp8BlLj+/HPJSFN+MhPhMRElH7chEMLvlGGW9hRtm eRKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ddl5ubdJXdhY37QXaqSPFuWOXoIoME8XjzTIYCn2FfM=; b=bs4VDNLmE07ZkCkmFthFlMO0FcyBzWoPdmMyCiAzIGDvCD0Uvudj3IjfDZSFwKBuah F5vzmDsV+g9ajGFblzLJMbOqnGP+IeqfcxWtMKtRT4SwHATpqtOS0hXW5PFljDMJt8dy OfLmIheHjelmL38HQdXPhuROORgl/6vIVN3Pt7RbUJl031BMQXMLrUfpCLFrYmNqw0LH HMLjhKltr/dNWLMFlcQ5MS0w0UD3KhQQxN1Z1AxnyoSlqFoEdFqcyjdI2PULg69+/cWV 78WSWAPXmjWaZXbq6NTXjVh8Gu+Md787zd4ieWnnMWlEDCWKcFJrltZO99dsZqGpGFKE ek9Q== X-Gm-Message-State: AO0yUKXCJso9xVluwNp1dhg3JZuONG7q78WtQ+POMPw7Vg/KpkiGvPvk YDP3hS7GlBCyNAR8/aE1xPU= X-Google-Smtp-Source: AK7set/g64z3OvggFkD0Z2RB8lO0nvGTzCuFS0OJ7oPDugPEV5kn1VJtceRXiEDz6GS84tqVRQdhbg== X-Received: by 2002:a62:1742:0:b0:590:772c:b990 with SMTP id 63-20020a621742000000b00590772cb990mr16502661pfx.15.1675052741760; Sun, 29 Jan 2023 20:25:41 -0800 (PST) Received: from localhost.localdomain ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id 138-20020a621790000000b0059312530b54sm4275969pfx.180.2023.01.29.20.25.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jan 2023 20:25:40 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Andrew Morton Cc: Joe Perches , Petr Mladek , Andy Shevchenko , Steven Rostedt , Vlastimil Babka , Matthew WilCox , David Hildenbrand , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH mm-unstable v4 1/3] mmflags.h: use less error prone method to define pageflag_names Date: Mon, 30 Jan 2023 13:25:12 +0900 Message-Id: <20230130042514.2418-2-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130042514.2418-1-42.hyeyoo@gmail.com> References: <20230130042514.2418-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: gsjfhjypfu6g1wtfi1a9ad6jc4bx3n93 X-Rspamd-Queue-Id: D585C12000B X-HE-Tag: 1675052742-367931 X-HE-Meta: U2FsdGVkX18kIC+WVn3yNzJCPJ2j5Ll2LTjhezIVdzxLckwxcJUkaXNPlBG/Nw34htFDyY0uvdFyt4XkJN+CeqfWc7XwczA7cSHiz5QqcZq7JztX97gOiJ4fEcWepKEz+lpqyRffpZCRsDT2eeR3uD29PlWITDHfIfipIj93JboVry+qZ73Njp6TV0xYFd8V3BTQ/TWcX4RkPpGO8jmzDy6n4iLYeBeQWehQsXrckayjKM4svdQuo98kOaIjbdsOTcsms/U1l6gRQ9OfRxzwVNvhQ6L6opUVPcYGLXtUi9cvP/papb9AWiE9tIxp2aMFVPbazwjE04e4NZ9+MR7Ngvq1p32hBPObrlEe+S2NxmrxKEyortdh75x1bOihpik3X9SUqB1EkBpYOLkFMUSwG2W+zZwLXTo8Lp4cu7KIwIltAisWzBaPIEeLdE4hbQJrn3DJxiE3v6Ix4ZWmHUyZQ1eLK4THEh+jehdkE0lk0XPono5n5OxrCDYQ+zEn/qLw17DywVpBKC+EcEd5GknjOcJQuzKpBB9SHqAcr7wuPy4HZfGZbO9plX9fps714hXQ2I33p4+dmwMWuzuSAfF5JwlBKXzC/XEqoMRSKhXBpjRKk/+pzMOir1z2p8/qw/e5ZJ3TvGYmmrd2PsHfHE+ySJN7hj2ucy4I6lja9gVIrRzKKE+8rn2LmX4PgXXROrP5Ol7VJurX95omkOr7xVSJ6/j59JyIUQh8VDBuf0BZucY5S/UpL7aDt9NEDMhwg3fZzrzacDFsYiD6cmYpOrD2lhLFjqzQG4S0yJ8DU+NXK49SNjut61XDK+xuBnlX68nfKVcQQ9hW8YhzOaCM7+F7mpWJqtEKzXiVtP6QyEN+NGpHGFZGpTrAA+5pxlSHlCYMdAYmAf6pdgT9u6vlP9HdGLTJqVTCwkAgMX5fxeNZ8ILmsiALWFzO1FlBr6ubGeJxUnK3yAL4CtYfQHlkCB4 6qCjiHvh NNWx635fpblBWWQfQm/+eQuU/1THb52ekw2FmCZpbTzTcBUcnMmQSE3Pww2dqitnCXLicYE6lkyLzbcGNfVbE5cw2L7+TaLBMxrIi2E5Zk4sz90uwsLonrfnIMxUXPgtmJDBeDUNlAVRxrcUUGE6CfiV+bQ/gBKYcWNcw9tqL7xgjqmySaafhgxiDL74VyJjiexh4DhbuPyVHlcdGT3vpkzyFSoQnJLMfmmsVb5Zc0coIlgaHlw18stxeFvQqCyM5XASQfWEFyn9vhyBaRKCGfeHO3ka9Fg97noAav6Di0BD4HDRViXQnuI1yOM8ffQf9CusTkCjUW0W996qUaz/NHGTl7n7dm2uky80Y2zJDYvKESY80ajQQtIJ0O4UOEGkXqne0EQ2o25vtryFSQZVDtZeH/6qCl134ggeRr5KQc1/KIZT04I20yy6ZGURgjVqW2N/PqNjVDP0fE52H/nwtkSJVEawQLKDStLd0iUEnIj/4YiJqoQe+7/05vs4sHA5qU9dTrk1TtieWlVTYNgGZON5IcD9jQxhrSBQjAk7A3PIiiMI6cON4GR9x240h9/YasX1+lDTPXQarQIN23QgxxqgwPoOLObOIJp8bxGn+eFko6wAYbrwdCZNlm980IAP8FJxiRoySuE/EC2ZidrW4ifO/sCZqcbZnWZm9pApQhm5QZRnVai5/XKVURgpSTTPN3kuN 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: As suggested by Andy Shevchenko, use helper macro to decrease chances of typo when defining pageflag_names. Link: https://lore.kernel.org/lkml/Y6AycLbpjVzXM5I9@smile.fi.intel.com Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Andy Shevchenko --- include/trace/events/mmflags.h | 85 ++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h index 9db52bc4ce19..f453babe29b3 100644 --- a/include/trace/events/mmflags.h +++ b/include/trace/events/mmflags.h @@ -67,71 +67,74 @@ ) : "none" #ifdef CONFIG_MMU -#define IF_HAVE_PG_MLOCK(flag,string) ,{1UL << flag, string} +#define IF_HAVE_PG_MLOCK(_name) ,{1UL << PG_##_name, __stringify(_name)} #else -#define IF_HAVE_PG_MLOCK(flag,string) +#define IF_HAVE_PG_MLOCK(_name) #endif #ifdef CONFIG_ARCH_USES_PG_UNCACHED -#define IF_HAVE_PG_UNCACHED(flag,string) ,{1UL << flag, string} +#define IF_HAVE_PG_UNCACHED(_name) ,{1UL << PG_##_name, __stringify(_name)} #else -#define IF_HAVE_PG_UNCACHED(flag,string) +#define IF_HAVE_PG_UNCACHED(_name) #endif #ifdef CONFIG_MEMORY_FAILURE -#define IF_HAVE_PG_HWPOISON(flag,string) ,{1UL << flag, string} +#define IF_HAVE_PG_HWPOISON(_name) ,{1UL << PG_##_name, __stringify(_name)} #else -#define IF_HAVE_PG_HWPOISON(flag,string) +#define IF_HAVE_PG_HWPOISON(_name) #endif #if defined(CONFIG_PAGE_IDLE_FLAG) && defined(CONFIG_64BIT) -#define IF_HAVE_PG_IDLE(flag,string) ,{1UL << flag, string} +#define IF_HAVE_PG_IDLE(_name) ,{1UL << PG_##_name, __stringify(_name)} #else -#define IF_HAVE_PG_IDLE(flag,string) +#define IF_HAVE_PG_IDLE(_name) #endif #ifdef CONFIG_ARCH_USES_PG_ARCH_X -#define IF_HAVE_PG_ARCH_X(flag,string) ,{1UL << flag, string} +#define IF_HAVE_PG_ARCH_X(_name) ,{1UL << PG_##_name, __stringify(_name)} #else -#define IF_HAVE_PG_ARCH_X(flag,string) +#define IF_HAVE_PG_ARCH_X(_name) #endif #ifdef CONFIG_KASAN_HW_TAGS -#define IF_HAVE_PG_SKIP_KASAN_POISON(flag,string) ,{1UL << flag, string} +#define IF_HAVE_PG_SKIP_KASAN_POISON(_name) \ + ,{1UL << PG_##_name, __stringify(_name)} #else -#define IF_HAVE_PG_SKIP_KASAN_POISON(flag,string) +#define IF_HAVE_PG_SKIP_KASAN_POISON(_name) #endif +#define DEF_PAGEFLAG_NAME(_name) { 1UL << PG_##_name, __stringify(_name) } + #define __def_pageflag_names \ - {1UL << PG_locked, "locked" }, \ - {1UL << PG_waiters, "waiters" }, \ - {1UL << PG_error, "error" }, \ - {1UL << PG_referenced, "referenced" }, \ - {1UL << PG_uptodate, "uptodate" }, \ - {1UL << PG_dirty, "dirty" }, \ - {1UL << PG_lru, "lru" }, \ - {1UL << PG_active, "active" }, \ - {1UL << PG_workingset, "workingset" }, \ - {1UL << PG_slab, "slab" }, \ - {1UL << PG_owner_priv_1, "owner_priv_1" }, \ - {1UL << PG_arch_1, "arch_1" }, \ - {1UL << PG_reserved, "reserved" }, \ - {1UL << PG_private, "private" }, \ - {1UL << PG_private_2, "private_2" }, \ - {1UL << PG_writeback, "writeback" }, \ - {1UL << PG_head, "head" }, \ - {1UL << PG_mappedtodisk, "mappedtodisk" }, \ - {1UL << PG_reclaim, "reclaim" }, \ - {1UL << PG_swapbacked, "swapbacked" }, \ - {1UL << PG_unevictable, "unevictable" } \ -IF_HAVE_PG_MLOCK(PG_mlocked, "mlocked" ) \ -IF_HAVE_PG_UNCACHED(PG_uncached, "uncached" ) \ -IF_HAVE_PG_HWPOISON(PG_hwpoison, "hwpoison" ) \ -IF_HAVE_PG_IDLE(PG_young, "young" ) \ -IF_HAVE_PG_IDLE(PG_idle, "idle" ) \ -IF_HAVE_PG_ARCH_X(PG_arch_2, "arch_2" ) \ -IF_HAVE_PG_ARCH_X(PG_arch_3, "arch_3" ) \ -IF_HAVE_PG_SKIP_KASAN_POISON(PG_skip_kasan_poison, "skip_kasan_poison") + DEF_PAGEFLAG_NAME(locked), \ + DEF_PAGEFLAG_NAME(waiters), \ + DEF_PAGEFLAG_NAME(error), \ + DEF_PAGEFLAG_NAME(referenced), \ + DEF_PAGEFLAG_NAME(uptodate), \ + DEF_PAGEFLAG_NAME(dirty), \ + DEF_PAGEFLAG_NAME(lru), \ + DEF_PAGEFLAG_NAME(active), \ + DEF_PAGEFLAG_NAME(workingset), \ + DEF_PAGEFLAG_NAME(slab), \ + DEF_PAGEFLAG_NAME(owner_priv_1), \ + DEF_PAGEFLAG_NAME(arch_1), \ + DEF_PAGEFLAG_NAME(reserved), \ + DEF_PAGEFLAG_NAME(private), \ + DEF_PAGEFLAG_NAME(private_2), \ + DEF_PAGEFLAG_NAME(writeback), \ + DEF_PAGEFLAG_NAME(head), \ + DEF_PAGEFLAG_NAME(mappedtodisk), \ + DEF_PAGEFLAG_NAME(reclaim), \ + DEF_PAGEFLAG_NAME(swapbacked), \ + DEF_PAGEFLAG_NAME(unevictable) \ +IF_HAVE_PG_MLOCK(mlocked) \ +IF_HAVE_PG_UNCACHED(uncached) \ +IF_HAVE_PG_HWPOISON(hwpoison) \ +IF_HAVE_PG_IDLE(idle) \ +IF_HAVE_PG_IDLE(young) \ +IF_HAVE_PG_ARCH_X(arch_2) \ +IF_HAVE_PG_ARCH_X(arch_3) \ +IF_HAVE_PG_SKIP_KASAN_POISON(skip_kasan_poison) #define show_page_flags(flags) \ (flags) ? __print_flags(flags, "|", \ From patchwork Mon Jan 30 04:25:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyeonggon Yoo <42.hyeyoo@gmail.com> X-Patchwork-Id: 13120406 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 7F1AAC54EAA for ; Mon, 30 Jan 2023 04:25:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E48A900002; Sun, 29 Jan 2023 23:25:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 194BB8E0002; Sun, 29 Jan 2023 23:25:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03521900002; Sun, 29 Jan 2023 23:25:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E5CBF8E0002 for ; Sun, 29 Jan 2023 23:25:48 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B257480ACA for ; Mon, 30 Jan 2023 04:25:48 +0000 (UTC) X-FDA: 80410177176.05.9C06A2F Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf02.hostedemail.com (Postfix) with ESMTP id DFEA980002 for ; Mon, 30 Jan 2023 04:25:46 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=RfLhOWGi; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675052746; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LwwzdAzQtrDpCWVBIKiBhOmPzUd7VlYgWQiD6C21IJ0=; b=VgEhJz5tF+mQhqhSpdjDvpQnWFrQ+gvYxUOvT0KWpXWkqRjQyXhRoBgR2KNsHNFBfNavs1 frMhPEAURzqDEaEuAetF5Q1+gRjXCpbyHdsP34FDyTu/Tn0/wBNtEy4Z2cp3IRB4ycPEKa PB22P9OHngV+JFRISKudjgoKjqZS47g= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=RfLhOWGi; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675052746; a=rsa-sha256; cv=none; b=QMAkcMXCcp9pF0HCkn/GmVEL0F5eS3BU84gpSyyDAuoJ6AmxfMZ1v8oV92KoyTo0sU2NCQ 4agamb3fdoFGDMyrJgrw0LoP+eqEy/7SzJrVdkNo3o3tOBilweV47fjBEZ1Jx/tXnSvVhO HlGQfPvZlC/bAN/uteijsdaPxaB2afo= Received: by mail-pj1-f44.google.com with SMTP id e8-20020a17090a9a8800b0022c387f0f93so9146935pjp.3 for ; Sun, 29 Jan 2023 20:25:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LwwzdAzQtrDpCWVBIKiBhOmPzUd7VlYgWQiD6C21IJ0=; b=RfLhOWGiR1DflwvehJodiK8eZGsp/vBq6+Phyd26hga+7Av2OBhSct+0XSH2B9FRzM p1m4/SQPUKR7nuT6kdKVjud9HnaisdGTqP1VRrO/3BwlrFVhBImkRKsi4K4VVNzjcjdn RAqpjAGeRVnTJPYjcazViD5yOdR3PZhnv4z0CbFzR6dqDpSAxiypyotLgJEFeCyZce89 UyYEt7oiwQTWtM1yzJ0MzCOp3gSP1mICANOrnWpW0e2bnbSjr6gncWosiiu1EbAiAlHa 2AcRJ8BLB3xryqSf4gogQqDj0vhzoMOIBasWKNCWxcwFhQCtBWdHd/KLlRPfEhnd3xb7 dQqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LwwzdAzQtrDpCWVBIKiBhOmPzUd7VlYgWQiD6C21IJ0=; b=tK6a00rOugOZsjUeCVq8QQ18DlmpW5TWkay0U7XVr5mW2Hbb59RjMMJb0RNKxQGFPS p1eXOZXA0eMTbSux9GoBbXLY2PDj34B2DBJKsz8y0P1pGFo7SBwikeGMTO4goHN8dLTi v7HsYNYvkko7x63nJiwxCCbt6ugSs9e3RWKaBNl8KRUZVPUlDPujcoACUJyVQdiuzd0G z4PIlbCdLBZsO+TiH/wCz48g76Qjw1uYNOa2Ji9OmEKTqruVZPLyJg7qZtuwjpWXt2ss AOx+Wz+W1yhstb70NbtuvA9QsV95Knp30dL4vjbuaO68/34URx9s2RXf/H6FAdwRhBLk 6XGA== X-Gm-Message-State: AFqh2kqY4hZg3NNi0xQpVYZ4/23SoOXYfbkTeW5ybKPQX8Qt9GMUbj1+ A0uCER1dK59y+UBhZsodpoI= X-Google-Smtp-Source: AMrXdXv0rqldkq324IZrmBFFJnO7fSD5oeWo9f+jtU8Ml/KRwPeLY0lgIYkFlO23Jcdrd2YCCrAdqA== X-Received: by 2002:a05:6a20:3d86:b0:b8:d032:6486 with SMTP id s6-20020a056a203d8600b000b8d0326486mr67733142pzi.16.1675052745607; Sun, 29 Jan 2023 20:25:45 -0800 (PST) Received: from localhost.localdomain ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id 138-20020a621790000000b0059312530b54sm4275969pfx.180.2023.01.29.20.25.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jan 2023 20:25:44 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Andrew Morton Cc: Joe Perches , Petr Mladek , Andy Shevchenko , Steven Rostedt , Vlastimil Babka , Matthew WilCox , David Hildenbrand , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH mm-unstable v4 2/3] mm, printk: introduce new format %pGt for page_type Date: Mon, 30 Jan 2023 13:25:13 +0900 Message-Id: <20230130042514.2418-3-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130042514.2418-1-42.hyeyoo@gmail.com> References: <20230130042514.2418-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: DFEA980002 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: nkatnbmodssnqytdncmi9ceypccknr99 X-HE-Tag: 1675052746-726143 X-HE-Meta: U2FsdGVkX19LUEqI18kybcPXn7H1//7bbRerqmXgg/2P8qDstWfe89jgGwKAzPuccyyCaMHmoMEUMDHcye6eQZjBqjSafMd6VjkXV9UhAvLrM2kep/CW/5rVYQe4KPPwQPe/xy6XAjrMa00D11l/41xAASUSIuK/bKMEAw1z4SwWB9glhQvMYrWXpwFU+28qMmZCnZ7OLPuZszW3WDfH7G5XSx0HAxY/3xqVeLG4fPxF/CHso1HyEc5fJPhh4oL8bJB7QpuLBi77O7g4tX8ophU4zHoZrUuAQnxaJUdLauqUJ8ahDBlE4NYnhfexJ1yZ03FryaNH+bWah6uNCscgMJAm+fgTmlb8BwOzWuTPaUdnDKwfUlqaSRJXhnP4g/Q2M77v/cqB8hmlNDBXG8326Yp6xpBbhSpFpsvUsk5pke+7tcNiettT3wXiNy3BWnfJHlExLsK1DYPz2cle2Tgezssftgi3A0BtqKHwLGwGTY5qPrJXPJBQaAxNMmj/NRUx/vIsnNZK+9CAj2llaB7yCjvXlDgo7Rd5HGnWXNqB+BSt6FZGzcMoBEaChGTE/7LX8v63DA9mlDmz7zi3jiSoVJkE1V00xxkLuc8QKXUTYp8ihb+KV1p4IZjUfDWpasw65WxXPTWJaEcrvJcEAGgLJGNieuz6Bl2dZWTDJ09+y5rPdX+qSK/5Gt7YKs+NbmT/9xMVM52Pf+Jf/HQZV0OaKoyRsNM19cwEfbleSQg1FMGWe0xcKM+Frc7giDUIOlJmI0l0MKdI93/yikkfmlDLwfHfVpbB1Mj5Gfks44ex4vJuhWzA0pA8TwvLUgnWRu+YTEevCQV1NP+h30qwBCWatz3ZEpJrDRMaOM0eOi2wRnD8c96IcKbrFc1b1vDKjc4HtbrvjJXftWT4n2kesGJtk/7UFEBctoBwrqPmsiBP7y6waUwVIwSwOKqomtvLzZnpZEWV4JvCqZN8jDwYQV8 q+rJy6Tr LXJHcuw+G+j3eTSYBEetzyb7513mKxx9fOyTRZkR56nWu2lvwXTTZR3smKs3b0ajyW0Nrl/0V4YAWBMkwwmUuvZWAXP7xcflCzIWWKWyd7x/PWEp25MRbTjnBIH/+M1IOBw3wzq7nstQKsYhgXdMvdgHizRmwEar9cdwIAx+Pkyo9KcsBi3Yv4nmROXsK5xzJIki2YHcOZnCAQx9JwOGsXBq3JJjOpcJeLRHv8Un7JPxTepfb8Mq/5w558jRthvp2V406DptFND8UcRX3uYzLT1U3b0kVY5kQgKShndlKlrVIQMogjAX7PyzgoIRtJiZ2yZkgKX4QspZkzDRSHUSsf69Mq298wMnWVfKJ+202Xz8q2CBq5Aidg2A0wl04Q2NVSPI9Zu/Z0hIg7nukgOlBwtkTamWry8vYxRdDeydaW/jeDn1y0MesiO6TgjKDMpGiWZQPEeQDHJtmi8I5e7pnch7NvwS7WNUvN1Yg4YOqMUo/vQ6I8kGEvK5G4PMXPuhUvHtsnruV7Q/p0f81P2u1qfykCiwmqQ5yKbb/ukkCdZhGJv7jeeALCQxWW3Vs1CVLaM5GbuDhFyD7q9w8y85Q31VSqb+vzfAcpvXCgPVt27wTRwA= 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: %pGp format is used to display 'flags' field of a struct page. However, some page flags (i.e. PG_buddy, see page-flags.h for more details) are stored in page_type field. To display human-readable output of page_type, introduce %pGt format. It is important to note the meaning of bits are different in page_type. if page_type is 0xffffffff, no flags are set. Setting PG_buddy (0x00000080) flag results in a page_type of 0xffffff7f. Clearing a bit actually means setting a flag. Bits in page_type are inverted when displaying type names. Only values for which page_type_has_type() returns true are considered as page_type, to avoid confusion with mapcount values. if it returns false, only raw values are displayed and not page type names. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Petr Mladek # for vsprintf part --- Documentation/core-api/printk-formats.rst | 16 +++++++++----- include/linux/page-flags.h | 7 +++++- include/trace/events/mmflags.h | 8 +++++++ lib/test_printf.c | 26 +++++++++++++++++++++++ lib/vsprintf.c | 21 ++++++++++++++++++ mm/debug.c | 5 +++++ mm/internal.h | 1 + 7 files changed, 78 insertions(+), 6 deletions(-) diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst index dbe1aacc79d0..dfe7e75a71de 100644 --- a/Documentation/core-api/printk-formats.rst +++ b/Documentation/core-api/printk-formats.rst @@ -575,20 +575,26 @@ The field width is passed by value, the bitmap is passed by reference. Helper macros cpumask_pr_args() and nodemask_pr_args() are available to ease printing cpumask and nodemask. -Flags bitfields such as page flags, gfp_flags ---------------------------------------------- +Flags bitfields such as page flags, page_type, gfp_flags +-------------------------------------------------------- :: %pGp 0x17ffffc0002036(referenced|uptodate|lru|active|private|node=0|zone=2|lastcpupid=0x1fffff) + %pGt 0xffffff7f(buddy) %pGg GFP_USER|GFP_DMA32|GFP_NOWARN %pGv read|exec|mayread|maywrite|mayexec|denywrite For printing flags bitfields as a collection of symbolic constants that would construct the value. The type of flags is given by the third -character. Currently supported are [p]age flags, [v]ma_flags (both -expect ``unsigned long *``) and [g]fp_flags (expects ``gfp_t *``). The flag -names and print order depends on the particular type. +character. Currently supported are: + + - p - [p]age flags, expects value of type (``unsigned long *``) + - t - page [t]ype, expects value of type (``unsigned int *``) + - v - [v]ma_flags, expects value of type (``unsigned long *``) + - g - [g]fp_flags, expects value of type (``gfp_t *``) + +The flag names and print order depends on the particular type. Note that this format should not be used directly in the :c:func:`TP_printk()` part of a tracepoint. Instead, use the show_*_flags() diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index a7e3a3405520..57287102c5bd 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -926,9 +926,14 @@ static inline bool is_page_hwpoison(struct page *page) #define PageType(page, flag) \ ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) +static inline int page_type_has_type(unsigned int page_type) +{ + return (int)page_type < PAGE_MAPCOUNT_RESERVE; +} + static inline int page_has_type(struct page *page) { - return (int)page->page_type < PAGE_MAPCOUNT_RESERVE; + return page_type_has_type(page->page_type); } #define PAGE_TYPE_OPS(uname, lname) \ diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h index f453babe29b3..b28218b7998e 100644 --- a/include/trace/events/mmflags.h +++ b/include/trace/events/mmflags.h @@ -141,6 +141,14 @@ IF_HAVE_PG_SKIP_KASAN_POISON(skip_kasan_poison) __def_pageflag_names \ ) : "none" +#define DEF_PAGETYPE_NAME(_name) { PG_##_name, __stringify(_name) } + +#define __def_pagetype_names \ + DEF_PAGETYPE_NAME(offline), \ + DEF_PAGETYPE_NAME(guard), \ + DEF_PAGETYPE_NAME(table), \ + DEF_PAGETYPE_NAME(buddy) + #if defined(CONFIG_X86) #define __VM_ARCH_SPECIFIC_1 {VM_PAT, "pat" } #elif defined(CONFIG_PPC) diff --git a/lib/test_printf.c b/lib/test_printf.c index 46b4e6c414a3..7677ebccf3c3 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -642,12 +642,26 @@ page_flags_test(int section, int node, int zone, int last_cpupid, test(cmp_buf, "%pGp", &flags); } +static void __init page_type_test(unsigned int page_type, const char *name, + char *cmp_buf) +{ + unsigned long size; + + size = scnprintf(cmp_buf, BUF_SIZE, "%#x(", page_type); + if (page_type_has_type(page_type)) + size += scnprintf(cmp_buf + size, BUF_SIZE - size, "%s", name); + + snprintf(cmp_buf + size, BUF_SIZE - size, ")"); + test(cmp_buf, "%pGt", &page_type); +} + static void __init flags(void) { unsigned long flags; char *cmp_buffer; gfp_t gfp; + unsigned int page_type; cmp_buffer = kmalloc(BUF_SIZE, GFP_KERNEL); if (!cmp_buffer) @@ -687,6 +701,18 @@ flags(void) gfp |= __GFP_HIGH; test(cmp_buffer, "%pGg", &gfp); + page_type = ~0; + page_type_test(page_type, "", cmp_buffer); + + page_type = 10; + page_type_test(page_type, "", cmp_buffer); + + page_type = ~PG_buddy; + page_type_test(page_type, "buddy", cmp_buffer); + + page_type = ~(PG_table | PG_buddy); + page_type_test(page_type, "table|buddy", cmp_buffer); + kfree(cmp_buffer); } diff --git a/lib/vsprintf.c b/lib/vsprintf.c index be71a03c936a..fbe320b5e89f 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -2052,6 +2052,25 @@ char *format_page_flags(char *buf, char *end, unsigned long flags) return buf; } +static +char *format_page_type(char *buf, char *end, unsigned int page_type) +{ + buf = number(buf, end, page_type, default_flag_spec); + + if (buf < end) + *buf = '('; + buf++; + + if (page_type_has_type(page_type)) + buf = format_flags(buf, end, ~page_type, pagetype_names); + + if (buf < end) + *buf = ')'; + buf++; + + return buf; +} + static noinline_for_stack char *flags_string(char *buf, char *end, void *flags_ptr, struct printf_spec spec, const char *fmt) @@ -2065,6 +2084,8 @@ char *flags_string(char *buf, char *end, void *flags_ptr, switch (fmt[1]) { case 'p': return format_page_flags(buf, end, *(unsigned long *)flags_ptr); + case 't': + return format_page_type(buf, end, *(unsigned int *)flags_ptr); case 'v': flags = *(unsigned long *)flags_ptr; names = vmaflag_names; diff --git a/mm/debug.c b/mm/debug.c index 96d594e16292..01cf0435723b 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -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} +}; + const struct trace_print_flags gfpflag_names[] = { __def_gfpflag_names, {0, NULL} diff --git a/mm/internal.h b/mm/internal.h index 90bb2078444c..11c3258809a9 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -802,6 +802,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[]; From patchwork Mon Jan 30 04:25:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyeonggon Yoo <42.hyeyoo@gmail.com> X-Patchwork-Id: 13120407 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 276BAC54EAA for ; Mon, 30 Jan 2023 04:25:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A21E88E0003; Sun, 29 Jan 2023 23:25:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D1798E0002; Sun, 29 Jan 2023 23:25:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8730A8E0003; Sun, 29 Jan 2023 23:25:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 78BAC8E0002 for ; Sun, 29 Jan 2023 23:25:52 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4452F80ACC for ; Mon, 30 Jan 2023 04:25:52 +0000 (UTC) X-FDA: 80410177344.19.33DFCD1 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by imf25.hostedemail.com (Postfix) with ESMTP id 7A1B0A0005 for ; Mon, 30 Jan 2023 04:25:50 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=hKdHkX18; spf=pass (imf25.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.180 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675052750; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7+2uSEts9I7Ewx+xS7afTWjlA6S/QLMMkQDB6ml0kj0=; b=rEqqRsKBixeCsZs44M0OjAeCVd8NCQQjjc9pM9d2db0vqCfEQdmo+N1LmWka/IGUj+uOcz 8wLNpNRI3EQQtpka/X+32b+R530smHUw6wAfHGYah4raF6HygEOEP77BWGQ2XARi7uVEr+ 3XYA5GbBhyq+WCEbx8024tOLvgNeEYE= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=hKdHkX18; spf=pass (imf25.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.180 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675052750; a=rsa-sha256; cv=none; b=XZhPzrDvhmI3hzGT8Oxz078Sn36INf8A709AsH800qqLFqoCUbgl7JWZYyhQfwXJ5naQbH e0aHbO2opaO5Je/4TA204W0ySgFfByyBglVl5+KeNr1ZY8pEbmwF4kL2ND20RdBJYpqeJ6 dbzNGTwQMUX/Kf+RrPU+LyBnzq1uYwk= Received: by mail-pg1-f180.google.com with SMTP id g68so6762296pgc.11 for ; Sun, 29 Jan 2023 20:25:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7+2uSEts9I7Ewx+xS7afTWjlA6S/QLMMkQDB6ml0kj0=; b=hKdHkX186An3SlPIdCV6Z762EQ3Mp+tUKDZoyrcHW4XH0L3AXgSWzAsinGVxCJr3iL o7ET8OmEff0FDqiWcyWz2HksAKY0eqrS2JhdnHs4xoHvbxotnBAsJDlH4cFwn9sZ5uPJ Mx6zVjix4c6pHAUF30Zhvibm1eolctdmqCeeqMYN/dqDEtywpaIczX7OifZ3R+jRG6hd CFeZohdbVbwh5Ahc31iEbp95nM8NbxoCnAIVR6icduxEirkVOZLncYjoVM7XKzfO6oEr b9KjhqYvZnMA66sE9SRqYxYTOhNRiff2Vh/hylLUBahbTvtYNv9HOoVtpVuwM8uNWJT2 rbcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7+2uSEts9I7Ewx+xS7afTWjlA6S/QLMMkQDB6ml0kj0=; b=FgTbI53/Zr3epqYWFQPtUY+UsDWAKmiUNs2iwNePi824AZ+bhqlQHlVckJmui4OTAM 1uhiV89m9J4zXQrjZamrtrHj+ZGkJ8kHBnYaENMiHQ9dLVKwDAAFebTo5JGt648JuCCR 89roi3jRTzaoJgdB45zKLWlLDDXXOEcwccYiUyylnBYUOltgsVy2MZtYcizbGrpIvYJp Wm+RtKL/4ew45z2qgVNOWl/TnGl8eAaB8Wwccy5qWYwMkE8st6wPgu1EnmZYwDxrYICI NHMlLEaB4Boy/Ois3afNgk1wKKC4zhenYwJbVOkYo/jIj0UmdquarT/H+5jM45qull5Z LuVg== X-Gm-Message-State: AFqh2krUpPkIJ28d4fK/dmfx0wIjunOy9DkCFYPsiNjXeGk9hPjb/ZOL Nv/XaOIq5GwYD4GWfBEJCEE= X-Google-Smtp-Source: AMrXdXt/vTOJEaTIid9fdett6eIQmY9527OXjpDlZK3RUh7rX89GJQs62AZMfIi62ZnaGn5d/ZYSpQ== X-Received: by 2002:a05:6a00:3315:b0:582:294d:f465 with SMTP id cq21-20020a056a00331500b00582294df465mr49045478pfb.13.1675052749382; Sun, 29 Jan 2023 20:25:49 -0800 (PST) Received: from localhost.localdomain ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id 138-20020a621790000000b0059312530b54sm4275969pfx.180.2023.01.29.20.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jan 2023 20:25:48 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Andrew Morton Cc: Joe Perches , Petr Mladek , Andy Shevchenko , Steven Rostedt , Vlastimil Babka , Matthew WilCox , David Hildenbrand , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH mm-unstable v4 3/3] mm/debug: use %pGt to display page_type in dump_page() Date: Mon, 30 Jan 2023 13:25:14 +0900 Message-Id: <20230130042514.2418-4-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130042514.2418-1-42.hyeyoo@gmail.com> References: <20230130042514.2418-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7A1B0A0005 X-Stat-Signature: um4xbg1x33k6ttd3kzbmezorm8b3o3ah X-HE-Tag: 1675052750-389758 X-HE-Meta: U2FsdGVkX18ItYAxE1k9OmHLUw/2G4+zicGS/yuVUXSBtvi2nEq5tR1aRBckOXs0Rx1Pno8+DnIkIJ33SBH+2WXzGu3w9f3crNhB7/1bWwzldG7N4lQ9qCuG3kZlW+P7naP/7FdvgmZ6GIecsDaep0CCN31u4KYSIpx2wz0uePcyiTkK8r+SfnCdaFXi6kWSRyYBbz/12VnTgVi/fJK1KqapNuGeyASXgXPXfmYQkeH4bz7+ubqcW9AMlgWiC2sIEoKrrOmeOzwFoZPe7TEeCs4yiJXmbdveSke8N45h1rjFmOt+fc483ZB0zuiGQOxU0QEo5f49xrffhP54XVDv+4Fy9Dj39bSCyA05Qb7Q9WFhkf556/7sVv6lNHtXEnU+HIjyPEzurOtSM+MDYFffONizJcfO4zEk/kXaeODUpib8LGTLdUkcPZhZnirP2cuV7DVIJI1cZgOlsTyy8WnalgE65gka5SMiF2l8sK69nu/icQf1aOG7P8vCNTOid2hBahb4R/VISNK2EdsUOSKQQxP2B6nRsA06TFJj+em4lb674fAjMMqVfzmuK4icoBxLjmKkm9Ow54vXMRg2HJr8Bv645PRTlCA6hd9KpuNtc3H3M4GXGLxBVTQFVwfIgKQCLhFsreIbaXId7xyED5i6Gtvr/JKQsquivHq0YiRB0MLpLzEufwyD5fxYEQr57PCaTTyS+TUg3rRNlL7c5tztgsL58l0OMthycArB21USPZR+ODH3m2vA5NIYAvMXnpEaU0ORXW1RWd8RbFrrPC6m6fCK+8Xpt5GqGiqB/eDJRnTImPKZxD2LaXIcHOroumg+X/uryARMp2RDwPZ/kP8Nw44JphQ3fs4fxcQIEPJlBqJfqSIHKGrbBoep+jkMrtmukZ1c0FuU/L7ReSJG8QiaPKgizeHpzsVesjIppz09PL8251+iiETqC/JvQPXFL12mU1mrynipWsO1SmlNEN1 x7JlG07Z CiZTfDpJHpneOFd+WP+98qzQBTFqOjjwh8+S5GBhKRPB3s3H0RvyINrJ0AefG93fhra0xNymTspDxze2jxg5ABvCeEthv5MxKj/IYxzxR+gnpW4vHytTdv3GJct/tmgtNPLhD/u+zRYQijEhUOoCEUhm7uX2Rtb9kCeRejs6W8FSh9VYW9ondr2GCorT1sb0wMH61Dm7s749kW0PsjwGRXo30CKVGT9DkzVPaCeCnDe4eXqXpKihGSRYJMPYX3/slxby78Sk+2vM0RtmDlpBURTNTNbbdiVh205xSf8fJaKSyaoVa/vyDvAUHLy37UpbDBQrsFwGK39z9HLAUQDdwkSaQlj9y+xk0Hi9LFrseo7ppAoiD4kafyDtttHEAKxIa80arAjtLS/vDz0BcRQXPQYZVhO1RiHzb/takkqHrO0mQAjccwiJYZg2FHjAoZnxnLOLNc796UlDak38qGz+HvnrkWsGI+36V/P/nnm7RcIvVSXAeVlYPy5fNNpYTmqMevcKCVlh7t4T0m3bkjUdM/OQu9FYWxoYgT2bOMRUqhLCUISdIkbVMcbYg3iieWVYnYrfzn3fRAFLAwx7hFEgMtFSvJhqdBIZ3oW081YwJpPXYSpg= 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: Some page flags are stored in page_type rather than ->flags field. Use newly introduced page type %pGt in dump_page(). Below are some examples: page:00000000da7184dd refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x101cb3 flags: 0x2ffff0000000000(node=0|zone=2|lastcpupid=0xffff) page_type: 0xffffffff() raw: 02ffff0000000000 0000000000000000 dead000000000122 0000000000000000 raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000 page dumped because: newly allocated page page:00000000da7184dd refcount:0 mapcount:-128 mapping:0000000000000000 index:0x0 pfn:0x101cb3 flags: 0x2ffff0000000000(node=0|zone=2|lastcpupid=0xffff) page_type: 0xffffff7f(buddy) raw: 02ffff0000000000 ffff88813fff8e80 ffff88813fff8e80 0000000000000000 raw: 0000000000000000 0000000000000000 00000000ffffff7f 0000000000000000 page dumped because: freed page page:0000000042202316 refcount:3 mapcount:2 mapping:0000000000000000 index:0x7f634722a pfn:0x11994e memcg:ffff888100135000 anon flags: 0x2ffff0000080024(uptodate|active|swapbacked|node=0|zone=2|lastcpupid=0xffff) page_type: 0x1() raw: 02ffff0000080024 0000000000000000 dead000000000122 ffff8881193398f1 raw: 00000007f634722a 0000000000000000 0000000300000001 ffff888100135000 page dumped because: user-mapped page Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/debug.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/debug.c b/mm/debug.c index 01cf0435723b..c7b228097bd9 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -120,6 +120,8 @@ static void __dump_page(struct page *page) 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);