Re: [PATCH mm-unstable] mm: clarify folio_set_compound_order() zero support

From: Muchun Song
Date: Tue Dec 13 2022 - 22:00:48 EST




> On Dec 10, 2022, at 05:20, John Hubbard <jhubbard@xxxxxxxxxx> wrote:
>
> On 12/9/22 13:10, John Hubbard wrote:
>> On 12/9/22 06:27, Muchun Song wrote:
>>> From you advise, I think we can remove VM_BUG_ON and handle non-zero
>>> order page, something like:
>> Yes, and thanks for summarizing all the individual feedback into a
>> proposed solution.
>> If we go this route, then I'd suggest a little note above the function,
>> such as:
>> /*
>> * For non-large folios, this will have no effect, other than possibly
>> * generating a warning, if the caller attempts to set a non-zero folio order
>> * for a non-large folio.
>> */
>>> static inline void folio_set_order(struct folio *folio,
>>> unsigned int order)
>>> {
>>> if (!folio_test_large(folio)) {
>>> WARN_ON(order);
>
> Although, on second thought...I'm still a little confused about why
> keeping the same name is so important?

Just my personal preference. I like its simplicity. I'm not against
large_folio_set_order, but suggest folio_set_order.

Thanks.

>
> A very direct approach that has more accurate naming (and therefore no
> need for a strange comment explaining the behavior) would be:
>
>
> static inline void large_folio_set_order(struct folio *folio,
> unsigned int order)
> {
> if (WARN_ON_ONCE(!folio_test_large(folio)))
> return;
>
> folio->_folio_order = order;
> #ifdef CONFIG_64BIT
> folio->_folio_nr_pages = order ? 1U << order : 0;
> #endif
> }
>
>
> thanks,
> --
> John Hubbard
> NVIDIA