Subject: Re: [PATCH v2 4/6] ARM: mm: Aligned pte allocation to one page

From: Gregory CLEMENT <[email-masked]>
Date: Fri, 12 Jun 2020 13:56:34 +0200

Arnd Bergmann <[email-masked]> writes:

> On Thu, Jun 11, 2020 at 3:49 PM Gregory CLEMENT
> <[email-masked]> wrote:
>>
>> In pte_offset_kernel() the pte_index macro is used. This macro makes
>> the assumption that the address is aligned to a page size.
>>
>> In arm_pte_allocation, the size allocated is the size needed for 512
>> entries. Actually this size was calculated to fit in a 4K page. When
>> using larger page, the size of the table allocated is no more
>> aligned which end to give a wrong physical address.
>>
>> The solution is to round up the allocation to a page size instead of
>> the exact size of the tables (which is 4KB). It allows to comply with
>> the assumption of pte_index() but the drawback is a waste of memory
>> for the early allocation if page size is bigger than 4KB.
>
> Have you considered increasing PTRS_PER_PTE instead to fill up
> a logical page instead? If that doesn't work, can you explain here
> why not?

Actually for this situation I didn't try to do better but it is only
used very early during the boot. Then I'm expecting that the allocation
is done though slab so with object at the exact size we need.

However you also pointed modifying PTRS_PER_PTE for the overall memory
consumption in the cover letter and in this case, it could worth
modifying it.

Gregory

>        Arnd

-- 
Gregory Clement, Bootlin
Embedded Linux and Kernel engineering
http://bootlin.com

_______________________________________________
linux-arm-kernel mailing list
[email-masked]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel