Re: [PATCH -v2 08/10] m68k,mm: Extend table allocator for multiple sizes
From: Geert Uytterhoeven
Date: Fri Feb 07 2020 - 05:56:57 EST
Hoi Peter,
On Fri, Jan 31, 2020 at 1:56 PM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> In addition to the PGD/PMD table size (128*4) add a PTE table size
> (64*4) to the table allocator. This completely removes the pte-table
> overhead compared to the old code, even for dense tables.
Thanks for your patch!
> Notes:
>
> - the allocator gained a list_empty() check to deal with there not
> being any pages at all.
>
> - the free mask is extended to cover more than the 8 bits required
> for the (512 byte) PGD/PMD tables.
Being an mm-illiterate, I don't understand the relation between the number
of bits and the size (see below).
> - NR_PAGETABLE accounting is restored.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
WARNING: Missing Signed-off-by: line by nominal patch author 'Peter
Zijlstra <peterz@xxxxxxxxxxxxx>'
(in all patches)
I can fix that (the From?) up while applying.
> --- a/arch/m68k/mm/motorola.c
> +++ b/arch/m68k/mm/motorola.c
> @@ -72,24 +72,35 @@ void mmu_page_dtor(void *page)
> arch/sparc/mm/srmmu.c ... */
>
> typedef struct list_head ptable_desc;
> -static LIST_HEAD(ptable_list);
> +
> +static struct list_head ptable_list[2] = {
> + LIST_HEAD_INIT(ptable_list[0]),
> + LIST_HEAD_INIT(ptable_list[1]),
> +};
>
> #define PD_PTABLE(page) ((ptable_desc *)&(virt_to_page(page)->lru))
> #define PD_PAGE(ptable) (list_entry(ptable, struct page, lru))
> -#define PD_MARKBITS(dp) (*(unsigned char *)&PD_PAGE(dp)->index)
> +#define PD_MARKBITS(dp) (*(unsigned int *)&PD_PAGE(dp)->index)
> +
> +static const int ptable_shift[2] = {
> + 7+2, /* PGD, PMD */
> + 6+2, /* PTE */
> +};
>
> -#define PTABLE_SIZE (PTRS_PER_PMD * sizeof(pmd_t))
> +#define ptable_size(type) (1U << ptable_shift[type])
> +#define ptable_mask(type) ((1U << (PAGE_SIZE / ptable_size(type))) - 1)
So this is 0xff for PGD and PMD, like before, and 0xffff for PTE.
Why the latter value?
Thanks!
>
> -void __init init_pointer_table(unsigned long ptable)
> +void __init init_pointer_table(void *table, int type)
> {
> ptable_desc *dp;
> + unsigned long ptable = (unsigned long)table;
> unsigned long page = ptable & PAGE_MASK;
> - unsigned char mask = 1 << ((ptable - page)/PTABLE_SIZE);
> + unsigned int mask = 1U << ((ptable - page)/ptable_size(type));
>
> dp = PD_PTABLE(page);
> if (!(PD_MARKBITS(dp) & mask)) {
> - PD_MARKBITS(dp) = 0xff;
> - list_add(dp, &ptable_list);
> + PD_MARKBITS(dp) = ptable_mask(type);
> + list_add(dp, &ptable_list[type]);
> }
>
> PD_MARKBITS(dp) &= ~mask;
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds