Re: [PATCH 4/5] m68k,mm: Extend table allocator for multiple sizes

Peter Zijlstra
2020-01-29T12:43:57Z

On Wed, Jan 29, 2020 at 12:17:53PM +0000, Will Deacon wrote:
> On Wed, Jan 29, 2020 at 11:39:45AM +0100, Peter Zijlstra wrote:

> > +extern void *get_pointer_table(int type);
>
> Could be prettier/obfuscated with an enum type?

Definitely, but then we get to bike-shed on names :-)

enum m68k_table_type {
TABLE_BIG = 0,
TABLE_SMALL,
};

Is not exactly _that_ much better, and while TABLE_PTE works,
TABLE_PGD_PMD is a bit crap.

> > --- a/arch/m68k/mm/memory.c
> > +++ b/arch/m68k/mm/memory.c

> > -pmd_t *get_pointer_table (void)
> > +void *get_pointer_table (int type)
> > {
> > - ptable_desc *dp = ptable_list.next;
> > - unsigned char mask = PD_MARKBITS (dp);
> > - unsigned char tmp;
> > - unsigned int off;
> > + ptable_desc *dp = ptable_list[type].next;
> > + unsigned int mask, tmp, off;
>
> nit, but if you do:
>
> unsigned int mask = list_empty(&ptable_list[type]) ? 0 : PD_MARKBITS(dp);
>
> then you can leave the existing mask logic as-is.

Indeed!