Re: [PATCH 4/8] mm: Add __dump_folio()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Tue, 27 Feb 2024 19:23:31 +0000 "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx> 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@xxxxxxxxxxxxx>
> ---
>  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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux