[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4785ad95-7af7-4d41-9997-e97b2a8e9666@arm.com>
Date: Mon, 27 Nov 2023 11:28:47 +0000
From: Ryan Roberts <ryan.roberts@....com>
To: Barry Song <21cnbao@...il.com>
Cc: akpm@...ux-foundation.org, anshuman.khandual@....com,
catalin.marinas@....com, david@...hat.com, fengwei.yin@...el.com,
hughd@...gle.com, itaru.kitayama@...il.com, jhubbard@...dia.com,
kirill.shutemov@...ux.intel.com,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, mcgrof@...nel.org, rientjes@...gle.com,
shy828301@...il.com, vbabka@...e.cz, wangkefeng.wang@...wei.com,
willy@...radead.org, ying.huang@...el.com, yuzhao@...gle.com,
ziy@...dia.com
Subject: Re: [RESEND PATCH v7 04/10] mm: thp: Support allocation of anonymous
small-sized THP
On 27/11/2023 03:41, Barry Song wrote:
>> + if ((nr_pages == 1 && vmf_pte_changed(vmf)) ||
>> + (nr_pages > 1 && !pte_range_none(vmf->pte, nr_pages))) {
>> + for (i = 0; i < nr_pages; i++)
>> + update_mmu_tlb(vma, addr + PAGE_SIZE * i, vmf->pte + i);
>> goto release;
>> }
>
> Hi Ryan,
> what has stopped nr_pages == 1 from using !pte_range_none(vmf->pte, 1)
> directly, then the code can become,
> + if (!pte_range_none(vmf->pte, nr_pages)) {
> + for (i = 0; i < nr_pages; i++)
> + update_mmu_tlb(vma, addr + PAGE_SIZE * i, vmf->pte + i);
> goto release;
> }
>
> for both 1 and > 1 cases?
We can get to do_anonymous_page() from 2 routes:
- page fault on unallocated memory (pte_none())
- page fault on uffd_wp pte marker
In the latter case, we guarrantee that we are only operating on nr_pages == 1
because when uffd is in the picture we need to preserve any uffd state per-pte.
It also means we can't just check the pte is none because in this case it is not
none, it has a pte marker so we need to check it hasn't changed.
I was previously abstracting this in vmf_pte_range_changed() but there were
complaints [1] about the semantic being different based on the number of pages,
so this was my attempt to make it more understandable.
[1] https://lore.kernel.org/linux-mm/a6fa0847-a950-4044-972c-e5dc8cbc7922@arm.com/
Thanks,
Ryan
>
> Thanks
> Barry
>
Powered by blists - more mailing lists