lkml.org 
[lkml]   [2022]   [Jun]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC PATCH v2 2/3] mm: Add PUD level pagetable account
From


On 6/23/2022 9:28 PM, Matthew Wilcox wrote:
> On Wed, Jun 22, 2022 at 09:38:30AM -0500, Mike Rapoport wrote:
>> On Wed, Jun 22, 2022 at 04:58:53PM +0800, Baolin Wang wrote:
>>> +++ b/arch/loongarch/include/asm/pgalloc.h
>>> @@ -89,10 +89,15 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
>>> static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address)
>>> {
>>> pud_t *pud;
>>> + struct page *pg;
>>
>> struct page *page;
>>
>> looks better IMO.
>>
>>> +
>>> + pg = alloc_pages(GFP_KERNEL & ~__GFP_HIGHMEM, PUD_ORDER);
>
> GFP_KERNEL does not include __GFP_HIGHMEM, so you can just use
> GFP_KERNEL here.

Yes. Thanks.

>
>>> + if (!pg)
>>> + return NULL;
>>>
>>> - pud = (pud_t *) __get_free_pages(GFP_KERNEL, PUD_ORDER);
>>> - if (pud)
>>> - pud_init((unsigned long)pud, (unsigned long)invalid_pmd_table);
>>> + pgtable_set_and_inc(pg);
>>> + pud = (pud_t *)page_address(pg);
>>
>> I don't think __get_free_pages() should be replaced with alloc_pages()
>> here, just call pgtable_set_and_inc() with virt_to_page(pud).
>
> I don't understand why you want that. Take a look at the implementation
> of __get_free_pages(). Converting back to a struct page after calling
> that seems like a real waste of time to me.

IMO I have no strong preference. The code can be simpler with using
__get_free_pages(), however like Matthew said it will add more conversion.

\
 
 \ /
  Last update: 2022-06-24 10:54    [W:0.094 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site