linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "David Hildenbrand (Red Hat)" <david@kernel.org>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: akpm@linux-foundation.org, lorenzo.stoakes@oracle.com,
	ziy@nvidia.com, baolin.wang@linux.alibaba.com,
	Liam.Howlett@oracle.com, npache@redhat.com, ryan.roberts@arm.com,
	dev.jain@arm.com, baohua@kernel.org, lance.yang@linux.dev,
	linux-mm@kvack.org
Subject: Re: [Patch v2] mm/huge_memory: consolidate order-related checks into folio_check_splittable()
Date: Mon, 5 Jan 2026 17:16:45 +0100	[thread overview]
Message-ID: <7ca733d2-ba0d-4792-bcd8-bc153e7b1b15@kernel.org> (raw)
In-Reply-To: <20260104023756.jufklyl3bl64fnck@master>

On 1/4/26 03:37, Wei Yang wrote:
> On Tue, Dec 23, 2025 at 12:25:39PM +0000, Wei Yang wrote:
>> The primary goal of the folio_check_splittable() function is to validate
>> whether a folio is suitable for splitting and to bail out early if it is
>> not.
>>
>> Currently, some order-related checks are scattered throughout the
>> calling code rather than being centralized in folio_check_splittable().
>>
>> This commit moves all remaining order-related validation logic into
>> folio_check_splittable(). This consolidation ensures that the function
>> serves its intended purpose as a single point of failure and improves
>> the clarity and maintainability of the surrounding code.
>>
>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> Cc: Zi Yan <ziy@nvidia.com>
>>
>> ---
> [...]
>> @@ -3719,28 +3723,33 @@ int folio_check_splittable(struct folio *folio, unsigned int new_order,
>> 		/* order-1 is not supported for anonymous THP. */
>> 		if (new_order == 1)
>> 			return -EINVAL;
>> -	} else if (split_type == SPLIT_TYPE_NON_UNIFORM || new_order) {
>> -		if (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) &&
>> -		    !mapping_large_folio_support(folio->mapping)) {
>> -			/*
>> -			 * We can always split a folio down to a single page
>> -			 * (new_order == 0) uniformly.
>> -			 *
>> -			 * For any other scenario
>> -			 *   a) uniform split targeting a large folio
>> -			 *      (new_order > 0)
>> -			 *   b) any non-uniform split
>> -			 * we must confirm that the file system supports large
>> -			 * folios.
>> -			 *
>> -			 * Note that we might still have THPs in such
>> -			 * mappings, which is created from khugepaged when
>> -			 * CONFIG_READ_ONLY_THP_FOR_FS is enabled. But in that
>> -			 * case, the mapping does not actually support large
>> -			 * folios properly.
>> -			 */
>> -			return -EINVAL;
>> +	} else {
>> +		if (split_type == SPLIT_TYPE_NON_UNIFORM || new_order) {
>> +			if (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) &&
>> +			    !mapping_large_folio_support(folio->mapping)) {
>> +				/*
>> +				 * We can always split a folio down to a
>> +				 * single page (new_order == 0) uniformly.
>> +				 *
>> +				 * For any other scenario
>> +				 *   a) uniform split targeting a large folio
>> +				 *      (new_order > 0)
>> +				 *   b) any non-uniform split
>> +				 * we must confirm that the file system
>> +				 * supports large folios.
>> +				 *
>> +				 * Note that we might still have THPs in such
>> +				 * mappings, which is created from khugepaged
>> +				 * when CONFIG_READ_ONLY_THP_FOR_FS is
>> +				 * enabled. But in that case, the mapping does
>> +				 * not actually support large folios properly.
>> +				 */
>> +				return -EINVAL;
>> +			}
>> 		}
> 
> Hi, Happy New Year to all :-)

Happy new year to you, too!

There was an offlist discussion about some of the text below, because a 
couple of people wondered whether it was an LLM-generated reply, and 
whether it is even worth the time to read.

So I am curious, did you end up using an LLM to compose this reply, and 
if so, to which degree? Only to improve your writing or also to come up 
with an analysis, code etc?

Feel free to use an LLM to improve your writing, analysis etc. Just a 
note that nobody here is interested in getting LLM-slopped, so don't 
send unfiltered/unchecked LLM output to the list.

In general, I think it was raised already in the past, please don't send 
patches for code you don't fully understand. It consumes quite some 
bandwidth for us reviewers/maintainers here and it just gets very likely 
to break things by accident.

The comment change suggestion below does not make any sense to fix a 
warning we trigger. If an LLM wrote it, you should never have sent it. 
If you wrote it, you should have invested more time to understand the 
problem and come up with a reasonable solution ... or not worked on it 
in the first place if you don't understand the details.


To the issue at hand: Zi Yan pointed this very thing out in v1 [1], no?

The patch as is cannot work: we cannot return -EINVAL for something that 
is not supposed to trigger a warning.

[1] 
https://lore.kernel.org/linux-mm/01FABE3A-AD4E-4A09-B971-C89503A848DF@nvidia.com/

-- 
Cheers

David


  reply	other threads:[~2026-01-05 16:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-23 12:25 Wei Yang
2025-12-23 17:50 ` [syzbot ci] " syzbot ci
2026-01-04  2:37 ` [Patch v2] " Wei Yang
2026-01-05 16:16   ` David Hildenbrand (Red Hat) [this message]
2026-01-05 16:29     ` Lorenzo Stoakes
2026-01-05 16:52       ` Matthew Wilcox
2026-01-06  9:54     ` Wei Yang
2026-01-06 12:28       ` Zi Yan
2026-01-06 12:51         ` Wei Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7ca733d2-ba0d-4792-bcd8-bc153e7b1b15@kernel.org \
    --to=david@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=dev.jain@arm.com \
    --cc=lance.yang@linux.dev \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=npache@redhat.com \
    --cc=richard.weiyang@gmail.com \
    --cc=ryan.roberts@arm.com \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox