[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <u3mwngmik3i2qgj3ymjx26chbabsjzrtf42dtvh3ejara2opa7@osasxccmufb7>
Date: Wed, 23 Oct 2024 14:18:16 +0300
From: "Kirill A. Shutemov" <kirill@...temov.name>
To: David Hildenbrand <david@...hat.com>
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 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?
Otherwise:
Reviewed-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
--
Kiryl Shutsemau / Kirill A. Shutemov
Powered by blists - more mailing lists