[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4e148b62-a7c1-4162-a487-1ab0199b774e@redhat.com>
Date: Wed, 27 Aug 2025 11:35:30 +0200
From: David Hildenbrand <david@...hat.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Max Kellermann <max.kellermann@...os.com>
Cc: lorenzo.stoakes@...cle.com, ziy@...dia.com,
baolin.wang@...ux.alibaba.com, Liam.Howlett@...cle.com, npache@...hat.com,
ryan.roberts@....com, dev.jain@....com, baohua@...nel.org,
shikemeng@...weicloud.com, kasong@...cent.com, nphamcs@...il.com,
bhe@...hat.com, chrisl@...nel.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] huge_mm.h: is_huge_zero_folio(NULL) should return
false
On 27.08.25 03:55, Andrew Morton wrote:
> On Wed, 27 Aug 2025 01:16:24 +0200 Max Kellermann <max.kellermann@...os.com> wrote:
>
>> Calling is_huge_zero_folio(NULL) should not be legal - it makes no
>> sense, and a different (theoretical) implementation may dereference
>> the pointer. But currently, lacking any explicit documentation, this
>> call is legal.
>>
>> But if somebody really passes NULL, the function should not return
>> true - this isn't the huge zero folio after all! However, if the
>> `huge_zero_folio` hasn't been allocated yet, it's NULL, and
>> is_huge_zero_folio(NULL) just happens to return true, which is a lie.
>
> Isn't it a bug to call is_huge_zero_folio() before the huge_zero_folio
> has been created?
It's a bug to call a function that expects a folio without a folio.
>
> Being a simple soul, I'm thinking
>
> VM_BUG_ON(!huge_zero_folio);
> VM_BUG_ON(!folio);
We should just do VM_WARN_ON(!folio);
--
Cheers
David / dhildenb
Powered by blists - more mailing lists