From nobody Thu Dec 18 22:20:09 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4579C4332F for ; Sun, 18 Dec 2022 10:19:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230350AbiLRKTg (ORCPT ); Sun, 18 Dec 2022 05:19:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230272AbiLRKTb (ORCPT ); Sun, 18 Dec 2022 05:19:31 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 763EEDEE3 for ; Sun, 18 Dec 2022 02:19:30 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id a9so6393815pld.7 for ; Sun, 18 Dec 2022 02:19:30 -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=uvPBeK/uQOTkS5bCd9KHq/uJNQrs6bRmNyv7cBW90YM=; b=cRiTctr0c+Y3PZWbi7kGhJ+34MYU3MF+KKnkl+m0yvYmeh883ce+JGBji2dZkDL2Wo hjL9TAemPLQTDRquzBzZeh7gEX9K3HNYkHV9ZLZRDL/TKyUe+k5cg4kICjxEiUuvvHzT /vjo03Bq5Fa77BDp79CFdE+HJdkWVffsveAnjyPESBtjDEWf9g6LV007LJr9icmfaraT gHoQiwsNbbjf8JegEPhFcZi7XGz0hJeLpj0Vp09qF6fDBlDkBxajEVETAzGafjUiRTKy mugTC9WZqfGT42wqXkQrr+4GNPLFab7/vpOtwly1RRFOOudqMFYz5g8lbt3jqqjaOK5W tGpg== 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=uvPBeK/uQOTkS5bCd9KHq/uJNQrs6bRmNyv7cBW90YM=; b=pafbpO8AJf9TK1B87KpiGAhXLxsnLM+9RmdUP718yjlcG0V/XDDyoylBlczNVT3dtV HVMMxqkaW39WCP5qdWJ7dSmfAWHEnSDjudAc2JThQgtyttpW6kXFIOeLYdZ9AQdE3hfL KAIvSEHWpp8CaF/kG4T3wOQQiLV6znmE/sbSWtgZfd8DL17CvpKtoLOPtrJ8y9khtdKB yBhL9eJLhe5c1y1A1lQKVtvqvN5G6vXA94N28WXu3b0W2nfM51Dm4BU87WCVJ7AWE7Pf y0Wa4PdM2xE2PuIALX8LTmv9jQPkBSVSm/aQAT5ijxaCzSitMuo/8ogUwD7berSugvTD VZCA== X-Gm-Message-State: ANoB5pklci6xQQuLQGaqOSAlPZvdx6GIh5GX6QMPo7eKNqk0BG6tdbnZ eDht9CFjUV1Ij8psDfDaFo0= X-Google-Smtp-Source: AA0mqf6JsU6eO2pxoS+w8HrBGNWmgAWd/51Yb3PiWN6hBjoaQOTnmocm7rbasPDj7XkU/fiBlRC6nw== X-Received: by 2002:a17:902:b618:b0:189:af28:fd8d with SMTP id b24-20020a170902b61800b00189af28fd8dmr37386097pls.1.1671358770040; Sun, 18 Dec 2022 02:19:30 -0800 (PST) Received: from hyeyoo.. ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id ik11-20020a170902ab0b00b001897bfc9800sm4789791plb.53.2022.12.18.02.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 02:19:29 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, =?UTF-8?q?HORIGUCHI=20NAOYA=28=E5=A0=80=E5=8F=A3=E3=80=80=E7=9B=B4=E4=B9=9F=29?= , Joe Perches , Petr Mladek , Andy Shevchenko , Matthew WilCox , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC v3 1/4] mm/hwpoison: remove MF_MSG_SLAB from action_page_types Date: Sun, 18 Dec 2022 19:18:58 +0900 Message-Id: <20221218101901.373450-2-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221218101901.373450-1-42.hyeyoo@gmail.com> References: <20221218101901.373450-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" As suggested by Naoya [1], identify_page_state() is never called when handling memory error on a slab page. Clean this up before moving PG_slab flag to page_type in later patch. [1] https://lore.kernel.org/linux-mm/Y2s+dnBsHAJu19ob@hyeyoo/#r Suggested-by: Naoya Horiguchi Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/memory-failure.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index c77a9e37e27e..74ad1db989e3 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -783,7 +783,6 @@ static const char *action_name[] =3D { static const char * const action_page_types[] =3D { [MF_MSG_KERNEL] =3D "reserved kernel page", [MF_MSG_KERNEL_HIGH_ORDER] =3D "high-order kernel page", - [MF_MSG_SLAB] =3D "kernel slab page", [MF_MSG_DIFFERENT_COMPOUND] =3D "different compound page after locking", [MF_MSG_HUGE] =3D "huge page", [MF_MSG_FREE_HUGE] =3D "free huge page", @@ -1146,7 +1145,6 @@ static int me_huge_page(struct page_state *ps, struct= page *p) #define mlock (1UL << PG_mlocked) #define lru (1UL << PG_lru) #define head (1UL << PG_head) -#define slab (1UL << PG_slab) #define reserved (1UL << PG_reserved) =20 static struct page_state error_states[] =3D { @@ -1156,13 +1154,6 @@ static struct page_state error_states[] =3D { * PG_buddy pages only make a small fraction of all free pages. */ =20 - /* - * Could in theory check if slab page is free or if we can drop - * currently unused objects without touching them. But just - * treat it as standard kernel for now. - */ - { slab, slab, MF_MSG_SLAB, me_kernel }, - { head, head, MF_MSG_HUGE, me_huge_page }, =20 { sc|dirty, sc|dirty, MF_MSG_DIRTY_SWAPCACHE, me_swapcache_dirty }, @@ -1189,7 +1180,6 @@ static struct page_state error_states[] =3D { #undef mlock #undef lru #undef head -#undef slab #undef reserved =20 /* --=20 2.32.0 From nobody Thu Dec 18 22:20:09 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45122C10F1E for ; Sun, 18 Dec 2022 10:19:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230030AbiLRKTm (ORCPT ); Sun, 18 Dec 2022 05:19:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230241AbiLRKTg (ORCPT ); Sun, 18 Dec 2022 05:19:36 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76352DEEF for ; Sun, 18 Dec 2022 02:19:35 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id t11-20020a17090a024b00b0021932afece4so10260017pje.5 for ; Sun, 18 Dec 2022 02:19:35 -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=raON8voEEt1U55vANTUkVu9dHTe8G6Xzm/P060fD0E0=; b=aoHQtnrtbDJuR+SHPkln9BK+Ce2XG9X2Tm3OXrkdy7uEqBL/lEDDi7bXc89+RWkOz4 8VsD9FX9V3o9MomGoYZyNUPJu2YXEv3xrSWKToSP7Wgpz26fA6EBSwUgGLBFC0ZLhN5J nWV8AVRwtIkbaFzYu+Z1tlRszVUp/55XiNeRiRvkHZGOOqaLnWCJc7gFcgvcQyoty7I3 DkvhiW1bLiH0EKYDH4rb39wXRLBD08rSf0n7i815kVib3FLUDgD+gjmWEYSPixi0rcZ0 8FvnrZ9JaIKWJ5LxPiEc0/7YNZDN7IU4Pnsu4r6aonF4/T8g2aYCbIRayGwvhn7VqUMs wQlg== 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=raON8voEEt1U55vANTUkVu9dHTe8G6Xzm/P060fD0E0=; b=upy0BoPIEAKfRWIcbwZFCjzYI0a6iKFD/Xv2ueHuG35cJLvokEATQuZxvwlpup7te3 lf1QtLDAx4o+uCrWop9Zig3nfkq9WNtlpp2d0bprFHuWWvaCulq/MrOK8352M8GQVkA4 yrIvJa3yOwnfHN47W3GB/mkc9QyPo4aUDk+g2Vxpq0OvYVIws2TADGY/FuBhUVP5p+p0 m3Zh4iKpTiEqghrqo+Zd6DqAFPL2ztHb95O6fDYGJ5BYYZYgjheOBxxff7KJDZHNrOUh abAznJ6GFvyX/sRKnEATlNPUwFN7oU2QnaGKHFz+JKawhv+4UhPAJlliQYVCNR1ihSHV y2jA== X-Gm-Message-State: ANoB5pmyuTLZyYCCARAYuWW98kNSGtgeCZYFzWbhy3SyVj5TxfWMD2Y/ dvl+G9euHHqbTKq2muTYhRI= X-Google-Smtp-Source: AA0mqf7v3O1EFl6BaQjH89235amk6nD6VFwkIrC0i6tMopHtMqNOigiE1dKJnbMEdjERJuqBZfzOoQ== X-Received: by 2002:a17:902:bb98:b0:188:edd2:318c with SMTP id m24-20020a170902bb9800b00188edd2318cmr38629112pls.26.1671358774773; Sun, 18 Dec 2022 02:19:34 -0800 (PST) Received: from hyeyoo.. ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id ik11-20020a170902ab0b00b001897bfc9800sm4789791plb.53.2022.12.18.02.19.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 02:19:33 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, =?UTF-8?q?HORIGUCHI=20NAOYA=28=E5=A0=80=E5=8F=A3=E3=80=80=E7=9B=B4=E4=B9=9F=29?= , Joe Perches , Petr Mladek , Andy Shevchenko , Matthew WilCox , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC v3 2/4] mm: move PG_slab flag to page_type Date: Sun, 18 Dec 2022 19:18:59 +0900 Message-Id: <20221218101901.373450-3-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221218101901.373450-1-42.hyeyoo@gmail.com> References: <20221218101901.373450-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" For now, only SLAB uses _mapcount field as a number of active objects in a slab, and other slab allocators do not. As 16 bits are enough for that, use remaining 16 bits of _mapcount as page_type even when SLAB is used. And then move PG_slab flag to page_type. As suggested by Matthew, store number of active objects in negative form and use helper when accessing or modifying it. page_type is always placed in upper half of _mapcount to avoid confusing normal _mapcount as page_type. As underflow (actually I mean, yeah, overflow) is not a concern anymore, use more lower bits. Add more folio helpers for PAGE_TYPE_OPS() not to break existing slab implementations. To preserve current behavior apply page policy in PAGE_TYPE_OPS() and use PF_NO_TAIL for slab pages and PF_ANY for others. Remove PG_slab check from PAGE_FLAGS_CHECK_AT_FREE. buddy will still check if _mapcount is properly set at free. Note that with this change, page_mapped() and folio_mapped() always return false for a slab page. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- fs/proc/page.c | 13 ++---- include/linux/mm_types.h | 11 +++-- include/linux/page-flags.h | 77 ++++++++++++++++++++++++---------- include/trace/events/mmflags.h | 1 - kernel/crash_core.c | 3 +- mm/slab.c | 44 ++++++++++++------- mm/slab.h | 3 +- 7 files changed, 98 insertions(+), 54 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 6249c347809a..e7524f21cefe 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -67,7 +67,7 @@ static ssize_t kpagecount_read(struct file *file, char __= user *buf, */ ppage =3D pfn_to_online_page(pfn); =20 - if (!ppage || PageSlab(ppage) || page_has_type(ppage)) + if (!ppage || page_has_type(ppage)) pcount =3D 0; else pcount =3D page_mapcount(ppage); @@ -124,11 +124,8 @@ u64 stable_page_flags(struct page *page) =20 /* * pseudo flags for the well known (anonymous) memory mapped pages - * - * Note that page->_mapcount is overloaded in SLOB/SLUB/SLQB, so the - * simple test in page_mapped() is not enough. */ - if (!PageSlab(page) && page_mapped(page)) + if (page_mapped(page)) u |=3D 1 << KPF_MMAP; if (PageAnon(page)) u |=3D 1 << KPF_ANON; @@ -178,16 +175,14 @@ u64 stable_page_flags(struct page *page) u |=3D 1 << KPF_OFFLINE; if (PageTable(page)) u |=3D 1 << KPF_PGTABLE; + if (PageSlab(page)) + u |=3D 1 << KPF_SLAB; =20 if (page_is_idle(page)) u |=3D 1 << KPF_IDLE; =20 u |=3D kpf_copy_bit(k, KPF_LOCKED, PG_locked); =20 - u |=3D kpf_copy_bit(k, KPF_SLAB, PG_slab); - if (PageTail(page) && PageSlab(compound_head(page))) - u |=3D 1 << KPF_SLAB; - u |=3D kpf_copy_bit(k, KPF_ERROR, PG_error); u |=3D kpf_copy_bit(k, KPF_DIRTY, PG_dirty); u |=3D kpf_copy_bit(k, KPF_UPTODATE, PG_uptodate); diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 3b8475007734..6b04ae65241d 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -207,10 +207,13 @@ struct page { atomic_t _mapcount; =20 /* - * If the page is neither PageSlab nor mappable to userspace, - * the value stored here may help determine what this page - * is used for. See page-flags.h for a list of page types - * which are currently stored here. + * If the page is not mappable to userspace, the value + * stored here may help determine what this page is used for. + * See page-flags.h for a list of page types which are currently + * stored here. + * + * Note that only upper half is used for page types and lower + * half is reserved for SLAB. */ unsigned int page_type; }; diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 69e93a0c1277..07063d60efe3 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -107,7 +107,6 @@ enum pageflags { PG_workingset, PG_waiters, /* Page has waiters, check its waitqueue. Must be bit #7 and= in the same byte as "PG_locked" */ PG_error, - PG_slab, PG_owner_priv_1, /* Owner use. If pagecache, fs may use*/ PG_arch_1, PG_reserved, @@ -482,7 +481,6 @@ PAGEFLAG(Active, active, PF_HEAD) __CLEARPAGEFLAG(Activ= e, active, PF_HEAD) TESTCLEARFLAG(Active, active, PF_HEAD) PAGEFLAG(Workingset, workingset, PF_HEAD) TESTCLEARFLAG(Workingset, workingset, PF_HEAD) -__PAGEFLAG(Slab, slab, PF_NO_TAIL) __PAGEFLAG(SlobFree, slob_free, PF_NO_TAIL) PAGEFLAG(Checked, checked, PF_NO_COMPOUND) /* Used by some filesystems = */ =20 @@ -906,42 +904,72 @@ static inline bool is_page_hwpoison(struct page *page) } =20 /* - * For pages that are never mapped to userspace (and aren't PageSlab), - * page_type may be used. Because it is initialised to -1, we invert the - * sense of the bit, so __SetPageFoo *clears* the bit used for PageFoo, and - * __ClearPageFoo *sets* the bit used for PageFoo. We reserve a few high = and - * low bits so that an underflow or overflow of page_mapcount() won't be - * mistaken for a page type value. + * For pages that are never mapped to userspace, page_type may be used. + * Because it is initialised to -1, we invert the sense of the bit, + * so __SetPageFoo *clears* the bit used for PageFoo, and __ClearPageFoo + * *sets* the bit used for PageFoo. We reserve a few high and low bits + * so that an underflow or overflow of page_mapcount() won't be mistaken + * for a page type value. */ =20 #define PAGE_TYPE_BASE 0xf0000000 -/* Reserve 0x0000007f to catch underflows of page_mapcount */ -#define PAGE_MAPCOUNT_RESERVE -128 -#define PG_buddy 0x00000080 -#define PG_offline 0x00000100 -#define PG_table 0x00000200 -#define PG_guard 0x00000400 +#define PG_buddy 0x00010000 +#define PG_offline 0x00020000 +#define PG_table 0x00040000 +#define PG_guard 0x00080000 +#define PG_slab 0x00100000 =20 #define PageType(page, flag) \ ((page->page_type & (PAGE_TYPE_BASE | flag)) =3D=3D PAGE_TYPE_BASE) =20 -static inline int page_has_type(struct page *page) +#define PAGE_TYPE_MASK 0xffff0000 + +static inline bool page_type_has_type(unsigned int page_type) { - return (int)page->page_type < PAGE_MAPCOUNT_RESERVE; + return ((int)page_type < (int)PAGE_TYPE_MASK); } =20 -#define PAGE_TYPE_OPS(uname, lname) \ +static inline bool page_has_type(struct page *page) +{ + return page_type_has_type(page->page_type); +} + + +#define PAGE_TYPE_OPS(uname, lname, policy) \ static __always_inline int Page##uname(struct page *page) \ { \ + page =3D policy(page, 0); \ + return PageType(page, PG_##lname); \ +} \ +static __always_inline int folio_test_##lname(struct folio *folio) \ +{ \ + struct page *page =3D &folio->page; \ + \ return PageType(page, PG_##lname); \ } \ static __always_inline void __SetPage##uname(struct page *page) \ { \ + page =3D policy(page, 1); \ + VM_BUG_ON_PAGE(!PageType(page, 0), page); \ + page->page_type &=3D ~PG_##lname; \ +} \ +static __always_inline void __folio_set_##lname(struct folio *folio) \ +{ \ + struct page *page =3D &folio->page; \ + \ VM_BUG_ON_PAGE(!PageType(page, 0), page); \ page->page_type &=3D ~PG_##lname; \ } \ static __always_inline void __ClearPage##uname(struct page *page) \ { \ + page =3D policy(page, 1); \ + VM_BUG_ON_PAGE(!Page##uname(page), page); \ + page->page_type |=3D PG_##lname; \ +} \ +static __always_inline void __folio_clear_##lname(struct folio *folio) \ +{ \ + struct page *page =3D &folio->page; \ + \ VM_BUG_ON_PAGE(!Page##uname(page), page); \ page->page_type |=3D PG_##lname; \ } @@ -950,7 +978,7 @@ static __always_inline void __ClearPage##uname(struct p= age *page) \ * PageBuddy() indicates that the page is free and in the buddy system * (see mm/page_alloc.c). */ -PAGE_TYPE_OPS(Buddy, buddy) +PAGE_TYPE_OPS(Buddy, buddy, PF_ANY) =20 /* * PageOffline() indicates that the page is logically offline although the @@ -974,7 +1002,10 @@ PAGE_TYPE_OPS(Buddy, buddy) * pages should check PageOffline() and synchronize with such drivers using * page_offline_freeze()/page_offline_thaw(). */ -PAGE_TYPE_OPS(Offline, offline) +PAGE_TYPE_OPS(Offline, offline, PF_ANY) + +/* PageSlab() indicates that the page is used by slab subsystem. */ +PAGE_TYPE_OPS(Slab, slab, PF_NO_TAIL) =20 extern void page_offline_freeze(void); extern void page_offline_thaw(void); @@ -984,12 +1015,12 @@ extern void page_offline_end(void); /* * Marks pages in use as page tables. */ -PAGE_TYPE_OPS(Table, table) +PAGE_TYPE_OPS(Table, table, PF_ANY) =20 /* * Marks guardpages used with debug_pagealloc. */ -PAGE_TYPE_OPS(Guard, guard) +PAGE_TYPE_OPS(Guard, guard, PF_ANY) =20 extern bool is_free_buddy_page(struct page *page); =20 @@ -1037,8 +1068,8 @@ static __always_inline void __ClearPageAnonExclusive(= struct page *page) (1UL << PG_lru | 1UL << PG_locked | \ 1UL << PG_private | 1UL << PG_private_2 | \ 1UL << PG_writeback | 1UL << PG_reserved | \ - 1UL << PG_slab | 1UL << PG_active | \ - 1UL << PG_unevictable | __PG_MLOCKED | LRU_GEN_MASK) + 1UL << PG_active | 1UL << PG_unevictable | \ + __PG_MLOCKED | LRU_GEN_MASK) =20 /* * Flags checked when a page is prepped for return by the page allocator. diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h index 412b5a46374c..8301912f8c25 100644 --- a/include/trace/events/mmflags.h +++ b/include/trace/events/mmflags.h @@ -113,7 +113,6 @@ {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" }, \ diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 87ef6096823f..1ea8198c26e1 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -482,13 +482,14 @@ static int __init crash_save_vmcoreinfo_init(void) VMCOREINFO_NUMBER(PG_private); VMCOREINFO_NUMBER(PG_swapcache); VMCOREINFO_NUMBER(PG_swapbacked); - VMCOREINFO_NUMBER(PG_slab); #ifdef CONFIG_MEMORY_FAILURE VMCOREINFO_NUMBER(PG_hwpoison); #endif VMCOREINFO_NUMBER(PG_head_mask); #define PAGE_BUDDY_MAPCOUNT_VALUE (~PG_buddy) VMCOREINFO_NUMBER(PAGE_BUDDY_MAPCOUNT_VALUE); +#define PAGE_SLAB_MAPCOUNT_VALUE (~PG_slab) + VMCOREINFO_NUMBER(PAGE_SLAB_MAPCOUNT_VALUE); #ifdef CONFIG_HUGETLB_PAGE VMCOREINFO_NUMBER(HUGETLB_PAGE_DTOR); #define PAGE_OFFLINE_MAPCOUNT_VALUE (~PG_offline) diff --git a/mm/slab.c b/mm/slab.c index 7a269db050ee..eee46f71c4b8 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -2269,6 +2269,21 @@ void __kmem_cache_release(struct kmem_cache *cachep) } } =20 +static inline unsigned int slab_get_active(struct slab *slab) +{ + return ~(slab->page_type | PG_slab); +} + +static inline void slab_inc_active(struct slab *slab) +{ + slab->page_type--; +} + +static inline void slab_dec_active(struct slab *slab) +{ + slab->page_type++; +} + /* * Get the memory for a slab management obj. * @@ -2291,7 +2306,6 @@ static void *alloc_slabmgmt(struct kmem_cache *cachep, void *addr =3D slab_address(slab); =20 slab->s_mem =3D addr + colour_off; - slab->active =3D 0; =20 if (OBJFREELIST_SLAB(cachep)) freelist =3D NULL; @@ -2510,8 +2524,8 @@ static void *slab_get_obj(struct kmem_cache *cachep, = struct slab *slab) { void *objp; =20 - objp =3D index_to_obj(cachep, slab, get_free_obj(slab, slab->active)); - slab->active++; + objp =3D index_to_obj(cachep, slab, get_free_obj(slab, slab_get_active(sl= ab))); + slab_inc_active(slab); =20 return objp; } @@ -2524,7 +2538,7 @@ static void slab_put_obj(struct kmem_cache *cachep, unsigned int i; =20 /* Verify double free bug */ - for (i =3D slab->active; i < cachep->num; i++) { + for (i =3D slab_get_active(slab); i < cachep->num; i++) { if (get_free_obj(slab, i) =3D=3D objnr) { pr_err("slab: double free detected in cache '%s', objp %px\n", cachep->name, objp); @@ -2532,11 +2546,11 @@ static void slab_put_obj(struct kmem_cache *cachep, } } #endif - slab->active--; + slab_dec_active(slab); if (!slab->freelist) slab->freelist =3D objp + obj_offset(cachep); =20 - set_free_obj(slab, slab->active, objnr); + set_free_obj(slab, slab_get_active(slab), objnr); } =20 /* @@ -2635,14 +2649,14 @@ static void cache_grow_end(struct kmem_cache *cache= p, struct slab *slab) =20 raw_spin_lock(&n->list_lock); n->total_slabs++; - if (!slab->active) { + if (!slab_get_active(slab)) { list_add_tail(&slab->slab_list, &n->slabs_free); n->free_slabs++; } else fixup_slab_list(cachep, n, slab, &list); =20 STATS_INC_GROWN(cachep); - n->free_objects +=3D cachep->num - slab->active; + n->free_objects +=3D cachep->num - slab_get_active(slab); raw_spin_unlock(&n->list_lock); =20 fixup_objfreelist_debug(cachep, &list); @@ -2744,7 +2758,7 @@ static inline void fixup_slab_list(struct kmem_cache = *cachep, { /* move slabp to correct slabp list: */ list_del(&slab->slab_list); - if (slab->active =3D=3D cachep->num) { + if (slab_get_active(slab) =3D=3D cachep->num) { list_add(&slab->slab_list, &n->slabs_full); if (OBJFREELIST_SLAB(cachep)) { #if DEBUG @@ -2783,7 +2797,7 @@ static noinline struct slab *get_valid_first_slab(str= uct kmem_cache_node *n, =20 /* Move pfmemalloc slab to the end of list to speed up next search */ list_del(&slab->slab_list); - if (!slab->active) { + if (!slab_get_active(slab)) { list_add_tail(&slab->slab_list, &n->slabs_free); n->free_slabs++; } else @@ -2865,9 +2879,9 @@ static __always_inline int alloc_block(struct kmem_ca= che *cachep, * There must be at least one object available for * allocation. */ - BUG_ON(slab->active >=3D cachep->num); + BUG_ON(slab_get_active(slab) >=3D cachep->num); =20 - while (slab->active < cachep->num && batchcount--) { + while (slab_get_active(slab) < cachep->num && batchcount--) { STATS_INC_ALLOCED(cachep); STATS_INC_ACTIVE(cachep); STATS_SET_HIGH(cachep); @@ -3162,7 +3176,7 @@ static void *____cache_alloc_node(struct kmem_cache *= cachep, gfp_t flags, STATS_INC_ACTIVE(cachep); STATS_SET_HIGH(cachep); =20 - BUG_ON(slab->active =3D=3D cachep->num); + BUG_ON(slab_get_active(slab) =3D=3D cachep->num); =20 obj =3D slab_get_obj(cachep, slab); n->free_objects--; @@ -3297,7 +3311,7 @@ static void free_block(struct kmem_cache *cachep, voi= d **objpp, STATS_DEC_ACTIVE(cachep); =20 /* fixup slab chains */ - if (slab->active =3D=3D 0) { + if (slab_get_active(slab) =3D=3D 0) { list_add(&slab->slab_list, &n->slabs_free); n->free_slabs++; } else { @@ -3352,7 +3366,7 @@ static void cache_flusharray(struct kmem_cache *cache= p, struct array_cache *ac) struct slab *slab; =20 list_for_each_entry(slab, &n->slabs_free, slab_list) { - BUG_ON(slab->active); + BUG_ON(slab_get_active(slab)); =20 i++; } diff --git a/mm/slab.h b/mm/slab.h index 7cc432969945..c6ffe6799436 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -20,7 +20,8 @@ struct slab { }; struct rcu_head rcu_head; }; - unsigned int active; + /* lower half of page_type is used as active objects counter */ + unsigned int page_type; =20 #elif defined(CONFIG_SLUB) =20 --=20 2.32.0 From nobody Thu Dec 18 22:20:09 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CDEEC4332F for ; Sun, 18 Dec 2022 10:20:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230221AbiLRKUA (ORCPT ); Sun, 18 Dec 2022 05:20:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbiLRKTv (ORCPT ); Sun, 18 Dec 2022 05:19:51 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02AF1DEE3 for ; Sun, 18 Dec 2022 02:19:40 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id s7so6406802plk.5 for ; Sun, 18 Dec 2022 02:19:39 -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=D+7GjecAQWYKdyIMijkjG0fslIItZloxZjhPMs3OBpw=; b=GB+cIi5ruQzrbOrlJbNzYlQ1gH9cgIK6ioIhYfetGCqlHswGzIRR+TzMfVrKR0C2sX n+F50/v7rHI0gvqm5BvXZClesXl4zQkvidtIZZF3tTXSePliVaxQ5fsuAGyppWUv0BLl Zx6Tbei1P6+mqoGTku/v3tvi92L60cjrk/4LQXalFfFxBVwUnUyfIIlxqKyrQgRHKJYX 9zv9KGOVZttO1NiJX0T9p/YQlFONDN1Bjr2E3N+qVvpzDLUbKlZK+SLK0LhphmCGBbKd zUUqqJAai4NSOX6qTtT8hN8A00XODki6V9A2BBFy386HS7wkbQr73yRAmuTDPDa91/2M Uviw== 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=D+7GjecAQWYKdyIMijkjG0fslIItZloxZjhPMs3OBpw=; b=WegJyFi2vVyutAFfQWeyZANDoZxN05/VpFi0gtxk7HBkYpaxbmCQ9MehvBqbeFZOLJ bUaWIsrf4PfFRLdwOHJ6j9mjLhhKBU4RmWn0aLBHrnUQ7y2nwd2ROrhcALnTX9IxKtBX w3Ki3DcfU/VAMOHp2uCGATP8GVggWwnrTb2595CGEkDIAcRtML4MEBFCPROk7SWGvb84 uwHEG4zXdMKDyf6HAulMwDvFNXnJa1oBi1hBEVV+BWfq8i0KM+I/FRBxtbLDWah9L0m/ Ig92iRgR2KiSuegmnXbuNG1GiH4h53fdnQMxSesVJYwUN8ZZejKZ2yO8N7HJ3xymMQgQ TXNw== X-Gm-Message-State: ANoB5plQhBmNbmyGuEtsSUBOve0o40XgJgUMtHrB/hxpECX6z2fYJGt4 bh543I9FeNc4hs4eJdrRDVY= X-Google-Smtp-Source: AA0mqf5oVPeB5bhp8aKBFuvgIKkQpspt6mh+LJK000FqqtoAAMJTJ0x6zwvVmJvhrD0/w2mwwG2NjQ== X-Received: by 2002:a17:902:d18b:b0:18f:8f1d:2352 with SMTP id m11-20020a170902d18b00b0018f8f1d2352mr26047426plb.30.1671358779463; Sun, 18 Dec 2022 02:19:39 -0800 (PST) Received: from hyeyoo.. ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id ik11-20020a170902ab0b00b001897bfc9800sm4789791plb.53.2022.12.18.02.19.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 02:19:38 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, =?UTF-8?q?HORIGUCHI=20NAOYA=28=E5=A0=80=E5=8F=A3=E3=80=80=E7=9B=B4=E4=B9=9F=29?= , Joe Perches , Petr Mladek , Andy Shevchenko , Matthew WilCox , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC v3 3/4] mm, printk: introduce new format %pGt for page_type Date: Sun, 18 Dec 2022 19:19:00 +0900 Message-Id: <20221218101901.373450-4-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221218101901.373450-1-42.hyeyoo@gmail.com> References: <20221218101901.373450-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" %pGp format is used 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. 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 page type names. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- Documentation/core-api/printk-formats.rst | 3 ++- include/trace/events/mmflags.h | 7 ++++++ lib/test_printf.c | 26 +++++++++++++++++++++++ lib/vsprintf.c | 21 ++++++++++++++++++ mm/debug.c | 5 +++++ mm/internal.h | 1 + 6 files changed, 62 insertions(+), 1 deletion(-) diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core= -api/printk-formats.rst index dbe1aacc79d0..582e965508eb 100644 --- a/Documentation/core-api/printk-formats.rst +++ b/Documentation/core-api/printk-formats.rst @@ -575,12 +575,13 @@ The field width is passed by value, the bitmap is pas= sed by reference. Helper macros cpumask_pr_args() and nodemask_pr_args() are available to ea= se printing cpumask and nodemask. =20 -Flags bitfields such as page flags, gfp_flags +Flags bitfields such as page flags, page_type, gfp_flags --------------------------------------------- =20 :: =20 %pGp 0x17ffffc0002036(referenced|uptodate|lru|active|private|node=3D0|zon= e=3D2|lastcpupid=3D0x1fffff) + %pGt 0xffefffff(slab) %pGg GFP_USER|GFP_DMA32|GFP_NOWARN %pGv read|exec|mayread|maywrite|mayexec|denywrite =20 diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h index 8301912f8c25..57f52d00e761 100644 --- a/include/trace/events/mmflags.h +++ b/include/trace/events/mmflags.h @@ -138,6 +138,13 @@ IF_HAVE_PG_SKIP_KASAN_POISON(PG_skip_kasan_poison, "sk= ip_kasan_poison") __def_pageflag_names \ ) : "none" =20 +#define __def_pagetype_names \ + {PG_slab, "slab" }, \ + {PG_offline, "offline" }, \ + {PG_guard, "guard" }, \ + {PG_table, "table" }, \ + {PG_buddy, "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 d34dc636b81c..e0d0770d5eec 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); } =20 +static void __init page_type_test(unsigned int page_type, const char *name, + char *cmp_buf) +{ + unsigned long size; + + size =3D scnprintf(cmp_buf, BUF_SIZE, "%#x(", page_type); + if (page_type_has_type(page_type)) + size +=3D 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; =20 cmp_buffer =3D kmalloc(BUF_SIZE, GFP_KERNEL); if (!cmp_buffer) @@ -687,6 +701,18 @@ flags(void) gfp |=3D __GFP_ATOMIC; test(cmp_buffer, "%pGg", &gfp); =20 + page_type =3D ~0; + page_type_test(page_type, "", cmp_buffer); + + page_type =3D 10; + page_type_test(page_type, "", cmp_buffer); + + page_type =3D ~PG_slab; + page_type_test(page_type, "slab", cmp_buffer); + + page_type =3D ~(PG_slab | PG_table | PG_buddy); + page_type_test(page_type, "slab|table|buddy", cmp_buffer); + kfree(cmp_buffer); } =20 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, unsign= ed long flags) return buf; } =20 +static +char *format_page_type(char *buf, char *end, unsigned int page_type) +{ + buf =3D number(buf, end, page_type, default_flag_spec); + + if (buf < end) + *buf =3D '('; + buf++; + + if (page_type_has_type(page_type)) + buf =3D format_flags(buf, end, ~page_type, pagetype_names); + + if (buf < end) + *buf =3D ')'; + 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 =3D *(unsigned long *)flags_ptr; names =3D vmaflag_names; diff --git a/mm/debug.c b/mm/debug.c index 7f8e5f744e42..5ce6b359004a 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -36,6 +36,11 @@ const struct trace_print_flags pageflag_names[] =3D { {0, NULL} }; =20 +const struct trace_print_flags pagetype_names[] =3D { + __def_pagetype_names, + {0, NULL} +}; + const struct trace_print_flags gfpflag_names[] =3D { __def_gfpflag_names, {0, NULL} diff --git a/mm/internal.h b/mm/internal.h index bcf75a8b032d..b4ba6fd6051c 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 */ =20 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[]; =20 --=20 2.32.0 From nobody Thu Dec 18 22:20:09 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAD6EC4332F for ; Sun, 18 Dec 2022 10:20:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230311AbiLRKUX (ORCPT ); Sun, 18 Dec 2022 05:20:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230382AbiLRKUA (ORCPT ); Sun, 18 Dec 2022 05:20:00 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2531DF4A for ; Sun, 18 Dec 2022 02:19:44 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so10268171pjs.4 for ; Sun, 18 Dec 2022 02:19:44 -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=USiySWTOh1CETJ0YaQTua6YhrtEN1JVTOEmqLQEb+nc=; b=bWK2HUZitrMe3mACDaUw2c6Wef/saP741RD5s+0F3g7SGx1ocQQGgA3KQo+0LBvYS/ 1AdRIdFNalVr6Szi/z72zeefH3ICn+Qd2dC6Egi/6wkaWWyA+Y8tlGU6Vs47aChPbtx9 O2bhTef3xY1/9W+oenTVALT0gBi6whnKo7eS8DdlerbX94y/feD283qBLf3rKcBD0RWJ Ly8Jz4yocDAlnLz43nG6gfP+R/veNmiX/jkOnAAJSZTii0CEIZwWBfSX3IBcpw3Fh4dY 0ZpF7xElp98dXVYTyhT5eI8lcFhxdm5C6i+8dRC08sLo9plyGPmZI4uv++OYORdWD2hu 8VxA== 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=USiySWTOh1CETJ0YaQTua6YhrtEN1JVTOEmqLQEb+nc=; b=UzNEefuQclERKbqk1E6A/3EH01/op6iwjmNxIRGHV4EoAvzs6e2jCEEUknyWrtxFzL xzvo0rM5lIjerWd3rrOnf+gpNqHbgCc4WffLNe1rF66pVq6en6XcWXtko5tychLkbp4V Y4rnCKC0I4G1c7pvOgPvoVjcRTlxGLGbBXiRWfU7MsEaVnAeRkaNpfjXb+Yw+yzK75qo xA08BqCe+P5IyP8tqIHwfuacMzCyZU64XHRsahrS2mOyPY8NwEzxl+Q38RHuv5T9sTNo M7VV1lUj95ALHHZiXB3KgMZ+0rNBsBMNNNEacsweohJ59wEcVj8fhz8wTJU8j5DTo+S5 pY9Q== X-Gm-Message-State: AFqh2koE4nbzXKpkveooMCIqrM/Rr8GwBKzd7AWcfCz1zRbY9sy1tszl R7o4b00PpdLzf5lSh0LqAlo= X-Google-Smtp-Source: AMrXdXvKE5/ZFpRCUmyw11BJzvZeV02MBGI0qTsOGM0h4S9hXXpZmBes+89J/16brPjl+7ootVUf/Q== X-Received: by 2002:a17:902:d4c6:b0:191:a19:e768 with SMTP id o6-20020a170902d4c600b001910a19e768mr7877083plg.48.1671358784136; Sun, 18 Dec 2022 02:19:44 -0800 (PST) Received: from hyeyoo.. ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id ik11-20020a170902ab0b00b001897bfc9800sm4789791plb.53.2022.12.18.02.19.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 02:19:43 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, =?UTF-8?q?HORIGUCHI=20NAOYA=28=E5=A0=80=E5=8F=A3=E3=80=80=E7=9B=B4=E4=B9=9F=29?= , Joe Perches , Petr Mladek , Andy Shevchenko , Matthew WilCox , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC v3 4/4] mm/debug: use %pGt to print page_type in dump_page() Date: Sun, 18 Dec 2022 19:19:01 +0900 Message-Id: <20221218101901.373450-5-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221218101901.373450-1-42.hyeyoo@gmail.com> References: <20221218101901.373450-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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:00000000e47d45a7 refcount:1 mapcount:0 mapping:0000000000000000 index:= 0x0 pfn:0x10175e flags: 0x200000000000000(node=3D0|zone=3D2) page_type: 0xffffffff() raw: 0200000000000000 0000000000000000 dead000000000122 0000000000000000 raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000 page dumped because: just after alloc_pages() page:00000000e47d45a7 refcount:1 mapcount:0 mapping:0000000000000000 index:= 0x0 pfn:0x10175e flags: 0x200000000000000(node=3D0|zone=3D2) page_type: 0xffefffff(slab) raw: 0200000000000000 0000000000000000 dead000000000122 0000000000000000 raw: 0000000000000000 0000000000000000 00000001ffefffff 0000000000000000 page dumped because: page with PG_slab set page:00000000e47d45a7 refcount:1 mapcount:2 mapping:0000000000000000 index:= 0x0 pfn:0x10175e flags: 0x200000000000000(node=3D0|zone=3D2) page_type: 0x1() raw: 0200000000000000 0000000000000000 dead000000000122 0000000000000000 raw: 0000000000000000 0000000000000000 0000000100000001 0000000000000000 page dumped because: page with _mapcount =3D=3D 1 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 5ce6b359004a..d6a0eb0a9bb8 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -120,6 +120,8 @@ static void __dump_page(struct page *page) =20 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); --=20 2.32.0