Re: [PATCH] mm/migrate_device: Cleanup up PMD Checks and warnings

David Hildenbrand (Arm)
2026-04-17T08:55:54Z

On 4/17/26 01:52, SeongJae Park wrote:
> On Thu, 16 Apr 2026 21:44:15 +0200 "David Hildenbrand (Arm)" <david@kernel.org> wrote:
>
>> On 4/14/26 16:13, Sunny Patel wrote:
> [...]
>>> @@ -865,12 +864,13 @@ static int migrate_vma_insert_huge_pmd_page(struct migrate_vma *migrate,
>>> if (userfaultfd_missing(vma))
>>> goto unlock_abort;
>>>
>>> - if (!pmd_none(*pmdp)) {
>>> + if (pmd_present(*pmdp)) {
>>> if (!is_huge_zero_pmd(*pmdp))
>>> goto unlock_abort;
>>> flush = true;
>>> - } else if (!pmd_none(*pmdp))
>>> + } else if (!pmd_none(*pmdp)) {
>>> goto unlock_abort;
>>> + }
>>>
>>> add_mm_counter(vma->vm_mm, MM_ANONPAGES, HPAGE_PMD_NR);
>>> folio_add_new_anon_rmap(folio, vma, addr, RMAP_EXCLUSIVE);
>>
>> is_huge_zero_pmd() checks pmd_present(), so we didn't have a bug before.
>>
>> We could also do:
>>
>> if (is_huge_zero_pmd(*pmdp)) {
>> flush = true;
>> } else if (!pmd_none(*pmdp)) {
>> goto unlock_abort;
>> }
>
> Then we could even further remove the braces and reduce one more line, nice!

Indeed :)

--
Cheers,

David