[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <83f17b85-c9fa-43a0-bec1-22c8565b67ad@redhat.com>
Date: Thu, 17 Apr 2025 09:18:39 +0200
From: David Hildenbrand <david@...hat.com>
To: Hugh Dickins <hughd@...gle.com>
Cc: Gavin Guo <gavinguo@...lia.com>, linux-mm@...ck.org,
akpm@...ux-foundation.org, willy@...radead.org, ziy@...dia.com,
linmiaohe@...wei.com, revest@...gle.com, kernel-dev@...lia.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/huge_memory: fix dereferencing invalid pmd migration
entry
On 17.04.25 07:36, Hugh Dickins wrote:
> On Wed, 16 Apr 2025, David Hildenbrand wrote:
>>
>> Why not something like
>>
>> struct folio *entry_folio;
>>
>> if (folio) {
>> if (is_pmd_migration_entry(*pmd))
>> entry_folio = pfn_swap_entry_folio(pmd_to_swp_entry(*pmd)));
>> else
>> entry_folio = pmd_folio(*pmd));
>>
>> if (folio != entry_folio)
>> return;
>> }
>
> My own preference is to not add unnecessary code:
> if folio and pmd_migration entry, we're not interested in entry_folio.
> But yes it could be written in lots of other ways.
While I don't disagree about "not adding unnecessary code" in general,
in this particular case just looking the folio up properly might be the
better alternative to reasoning about locking rules with conditional
input parameters :)
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists