[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ed072ac6-cc70-9070-4e9d-281b9b60c9a6@linux.alibaba.com>
Date: Fri, 24 Jun 2022 16:52:34 +0800
From: Baolin Wang <baolin.wang@...ux.alibaba.com>
To: Matthew Wilcox <willy@...radead.org>,
Mike Rapoport <rppt@...ux.ibm.com>
Cc: akpm@...ux-foundation.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH v2 2/3] mm: Add PUD level pagetable account
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.
Powered by blists - more mailing lists