[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0de24b30-70ad-498f-9eac-01596c8713df@redhat.com>
Date: Wed, 27 Aug 2025 22:01:45 +0200
From: David Hildenbrand <david@...hat.com>
To: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
Max Kellermann <max.kellermann@...os.com>
Cc: akpm@...ux-foundation.org, 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 v2] huge_mm.h: disallow is_huge_zero_folio(NULL)
> This seems not so great.
>
> I really think the VM_WARN_ON_ONCE() should be in folios_put_refs() based
> on what you've said.
No.
Everything in folio_put_refs() will dereference the folio and properly
crash the machine when doing something stupid.
This function, however, will silently swallow a "NULL" pointer.
>
>>
>> Signed-off-by: Max Kellermann <max.kellermann@...os.com>
>> ---
>> include/linux/huge_mm.h | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
>> index 7748489fde1b..bc9ca7798f2e 100644
>> --- a/include/linux/huge_mm.h
>> +++ b/include/linux/huge_mm.h
>> @@ -2,6 +2,7 @@
>> #ifndef _LINUX_HUGE_MM_H
>> #define _LINUX_HUGE_MM_H
>>
>> +#include <linux/mmdebug.h> // for VM_WARN_ON_ONCE()
>
> Please don't do //.
>
> This include is suspect though, huge_mm.h is included from mm.h and thus
> this very easily might break some arch that is weird about this stuff,
> because a ton of stuff includes mm.h including things that might absolutely
> baulk at mmdebug.
Jup. Very likely this is not required.
>
> I've had this kind of thing happen several times before.
>
>> #include <linux/mm_types.h>
>>
>> #include <linux/fs.h> /* only for vma_is_dax() */
>> @@ -479,6 +480,8 @@ extern unsigned long huge_zero_pfn;
>>
>> static inline bool is_huge_zero_folio(const struct folio *folio)
>> {
>> + VM_WARN_ON_ONCE(folio == NULL);
>> +
>
> Convention is VM_WARN_ON_ONCE(!folio);
Wanted to comment the same thing.
--
Cheers
David / dhildenb
Powered by blists - more mailing lists