From: SeongJae Park <sj@kernel.org>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-mm@kvack.org
Subject: Re: [PATCH 4/8] mm: Add __dump_folio()
Date: Wed, 28 Feb 2024 13:34:58 -0800 [thread overview]
Message-ID: <20240228213459.129930-1-sj@kernel.org> (raw)
In-Reply-To: <20240227192337.757313-5-willy@infradead.org>
Hi,
On Tue, 27 Feb 2024 19:23:31 +0000 "Matthew Wilcox (Oracle)" <willy@infradead.org> wrote:
> Turn __dump_page() into a wrapper around __dump_folio(). Snapshot the
> page & folio into a stack variable so we don't hit BUG_ON() if an
> allocation is freed under us and what was a folio pointer becomes a
> pointer to a tail page.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> mm/debug.c | 120 +++++++++++++++++++++++++++++------------------------
> 1 file changed, 66 insertions(+), 54 deletions(-)
>
> diff --git a/mm/debug.c b/mm/debug.c
> index ee533a5ceb79..96555fc78f1a 100644
> --- a/mm/debug.c
> +++ b/mm/debug.c
[...]
> +static void __dump_page(const struct page *page)
> +{
> + struct folio *foliop, folio;
> + struct page precise;
> + unsigned long pfn = page_to_pfn(page);
> + unsigned long idx, nr_pages = 1;
> + int loops = 5;
> +
> +again:
> + memcpy(&precise, page, sizeof(*page));
> + foliop = page_folio(&precise);
> + idx = folio_page_idx(foliop, page);
> + if (idx != 0) {
> + if (idx < (1UL << PUD_ORDER)) {
> + memcpy(&folio, foliop, 2 * sizeof(struct page));
> + nr_pages = folio_nr_pages(&folio);
> + }
> +
> + if (idx > nr_pages) {
> + if (loops-- > 0)
> + goto again;
> + printk("page does not match folio\n");
> + precise.compound_head &= ~1UL;
> + foliop = (struct folio *)&precise;
> + idx = 0;
> + }
> + }
> +
> + __dump_folio(foliop, &precise, pfn, idx);
> }
I just found one of my build tests that runs with a CONFIG_MMU disabled config
fails with below build error on mm-unstable starting from this patch. After
enabling CONFIG_MMU, the build didn't fail. I haven't had a time to look into
the code, but reporting first.
CC mm/debug.o
In file included from ...linux/include/asm-generic/pgtable-nopud.h:7,
from ...linux/arch/m68k/include/asm/pgtable_no.h:5,
from ...linux/arch/m68k/include/asm/pgtable.h:6,
from ...linux/include/linux/pgtable.h:6,
from ...linux/include/linux/mm.h:29,
from ...linux/mm/debug.c:10:
...linux/mm/debug.c: In function '__dump_page':
...linux/include/asm-generic/pgtable-nop4d.h:11:33: error: 'PGDIR_SHIFT' undeclared (first use in this function); did you mean 'PUD_SHIFT'?
11 | #define P4D_SHIFT PGDIR_SHIFT
| ^~~~~~~~~~~
...linux/include/asm-generic/pgtable-nopud.h:18:25: note: in expansion of macro 'P4D_SHIFT'
18 | #define PUD_SHIFT P4D_SHIFT
| ^~~~~~~~~
...linux/include/linux/pgtable.h:9:26: note: in expansion of macro 'PUD_SHIFT'
9 | #define PUD_ORDER (PUD_SHIFT - PAGE_SHIFT)
| ^~~~~~~~~
...linux/mm/debug.c:128:35: note: in expansion of macro 'PUD_ORDER'
128 | if (idx < (1UL << PUD_ORDER)) {
| ^~~~~~~~~
...linux/include/asm-generic/pgtable-nop4d.h:11:33: note: each undeclared identifier is reported only once for each function it appears in
11 | #define P4D_SHIFT PGDIR_SHIFT
| ^~~~~~~~~~~
...linux/include/asm-generic/pgtable-nopud.h:18:25: note: in expansion of macro 'P4D_SHIFT'
18 | #define PUD_SHIFT P4D_SHIFT
| ^~~~~~~~~
...linux/include/linux/pgtable.h:9:26: note: in expansion of macro 'PUD_SHIFT'
9 | #define PUD_ORDER (PUD_SHIFT - PAGE_SHIFT)
| ^~~~~~~~~
...linux/mm/debug.c:128:35: note: in expansion of macro 'PUD_ORDER'
128 | if (idx < (1UL << PUD_ORDER)) {
| ^~~~~~~~~
Thanks,
SJ
>
> void dump_page(struct page *page, const char *reason)
> --
> 2.43.0
next prev parent reply other threads:[~2024-02-28 21:35 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 19:23 [PATCH 0/8] PageFlags cleanups Matthew Wilcox (Oracle)
2024-02-27 19:23 ` [PATCH 1/8] mm: Separate out FOLIO_FLAGS from PAGEFLAGS Matthew Wilcox (Oracle)
2024-03-01 11:23 ` David Hildenbrand
2024-02-27 19:23 ` [PATCH 2/8] mm: Remove PageWaiters, PageSetWaiters and PageClearWaiters Matthew Wilcox (Oracle)
2024-03-01 11:24 ` David Hildenbrand
2024-02-27 19:23 ` [PATCH 3/8] mm: Remove PageYoung and PageIdle definitions Matthew Wilcox (Oracle)
2024-03-01 11:25 ` David Hildenbrand
2024-02-27 19:23 ` [PATCH 4/8] mm: Add __dump_folio() Matthew Wilcox (Oracle)
2024-02-28 21:34 ` SeongJae Park [this message]
2024-02-29 4:37 ` Matthew Wilcox
2024-02-29 5:05 ` SeongJae Park
2024-03-01 10:21 ` Ryan Roberts
2024-03-01 21:32 ` Matthew Wilcox
2024-03-04 19:02 ` Matthew Wilcox
2024-05-14 4:33 ` Kees Cook
2024-05-14 4:53 ` Matthew Wilcox
2024-05-14 14:25 ` Matthew Wilcox
2024-02-27 19:23 ` [PATCH 5/8] mm: Make dump_page() take a const argument Matthew Wilcox (Oracle)
2024-03-01 11:26 ` David Hildenbrand
2024-02-27 19:23 ` [PATCH 6/8] mm: Constify testing page/folio flags Matthew Wilcox (Oracle)
2024-03-01 11:28 ` David Hildenbrand
2024-02-27 19:23 ` [PATCH 7/8] mm: Constify more page/folio tests Matthew Wilcox (Oracle)
2024-03-01 11:28 ` David Hildenbrand
2024-02-27 19:23 ` [PATCH 8/8] mm: Remove cast from page_to_nid() Matthew Wilcox (Oracle)
2024-03-01 11:27 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240228213459.129930-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).