Re: [PATCH v1 3/5] mm: ptdump: Provide page size to notepage()

From: Christophe Leroy
Date: Fri Apr 16 2021 - 01:19:52 EST




Le 16/04/2021 à 01:12, Daniel Axtens a écrit :
Hi Christophe,

static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level,
- u64 val)
+ u64 val, unsigned long page_size)

Compilers can warn about unused parameters at -Wextra level. However,
reading scripts/Makefile.extrawarn it looks like the warning is
explicitly _disabled_ in the kernel at W=1 and not reenabled at W=2 or
W=3. So I guess this is fine...

There are a lot lot lot functions having unused parameters in the kernel , especially the ones that are re-implemented by each architecture.


@@ -126,7 +126,7 @@ static int ptdump_hole(unsigned long addr, unsigned long next,
{
struct ptdump_state *st = walk->private;
- st->note_page(st, addr, depth, 0);
+ st->note_page(st, addr, depth, 0, 0);

I know it doesn't matter at this point, but I'm not really thrilled by
the idea of passing 0 as the size here. Doesn't the hole have a known
page size?

The hole has a size for sure, I don't think we can call it a page size:

On powerpc 8xx, we have 4 page sizes: 8M, 512k, 16k and 4k.
A page table will cover 4M areas and will contain pages of size 512k, 16k and 4k.
A PGD table contains either entries which points to a page table (covering 4M), or two identical consecutive entries pointing to the same hugepd which contains a single PTE for an 8M page.

So, if a PGD entry is empty, the hole is 4M, it corresponds to none of the page sizes the architecture supports.


But looking at what is done with that size, it can make sense to pass it to notepage() anyway. Let's do that.


return 0;
}
@@ -153,5 +153,5 @@ void ptdump_walk_pgd(struct ptdump_state *st, struct mm_struct *mm, pgd_t *pgd)
mmap_read_unlock(mm);
/* Flush out the last page */
- st->note_page(st, 0, -1, 0);
+ st->note_page(st, 0, -1, 0, 0);

I'm more OK with the idea of passing 0 as the size when the depth is -1
(don't know): if we don't know the depth we conceptually can't know the
page size.

Regards,
Daniel