lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <393a1314-79b4-421a-ae45-f33c1bb600f8@redhat.com>
Date: Fri, 6 Dec 2024 11:29:37 +0100
From: David Hildenbrand <david@...hat.com>
To: "Kirill A. Shutemov" <kirill@...temov.name>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
 cgroups@...r.kernel.org, x86@...nel.org, linux-fsdevel@...r.kernel.org,
 Andrew Morton <akpm@...ux-foundation.org>,
 "Matthew Wilcox (Oracle)" <willy@...radead.org>, Tejun Heo <tj@...nel.org>,
 Zefan Li <lizefan.x@...edance.com>, Johannes Weiner <hannes@...xchg.org>,
 Michal Koutný <mkoutny@...e.com>,
 Jonathan Corbet <corbet@....net>, Andy Lutomirski <luto@...nel.org>,
 Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
 Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>
Subject: Re: [PATCH v1 02/17] mm: factor out large folio handling from
 folio_nr_pages() into folio_large_nr_pages()

On 23.10.24 13:18, Kirill A. Shutemov wrote:
> On Thu, Aug 29, 2024 at 06:56:05PM +0200, David Hildenbrand wrote:
>> Let's factor it out into a simple helper function. This helper will
>> also come in handy when working with code where we know that our
>> folio is large.
>>
>> Make use of it in internal.h and mm.h, where applicable.
>>
>> While at it, let's consistently return a "long" value from all these
>> similar functions. Note that we cannot use "unsigned int" (even though
>> _folio_nr_pages is of that type), because it would break some callers
>> that do stuff like "-folio_nr_pages()". Both "int" or "unsigned long"
>> would work as well.
>>
>> Signed-off-by: David Hildenbrand <david@...hat.com>
>> ---
>>   include/linux/mm.h | 27 ++++++++++++++-------------
>>   mm/internal.h      |  2 +-
>>   2 files changed, 15 insertions(+), 14 deletions(-)
>>
>> diff --git a/include/linux/mm.h b/include/linux/mm.h
>> index 3c6270f87bdc3..fa8b6ce54235c 100644
>> --- a/include/linux/mm.h
>> +++ b/include/linux/mm.h
>> @@ -1076,6 +1076,15 @@ static inline unsigned int folio_large_order(const struct folio *folio)
>>   	return folio->_flags_1 & 0xff;
>>   }
>>   
>> +static inline long folio_large_nr_pages(const struct folio *folio)
>> +{
>> +#ifdef CONFIG_64BIT
>> +	return folio->_folio_nr_pages;
>> +#else
>> +	return 1L << folio_large_order(folio);
>> +#endif
>> +}
>> +
> 
> Maybe it would be cleaner to move #ifdef outside of the function?

Yes, can do that.

-- 
Cheers,

David / dhildenb


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ