Re: [PATCH] mm/huge_memory: refactor after-split (page) cache code.

From: Zi Yan
Date: Thu Jul 17 2025 - 15:27:27 EST


On 17 Jul 2025, at 15:22, Dan Carpenter wrote:

> On Thu, Jul 17, 2025 at 11:45:13AM -0400, Zi Yan wrote:
>>
>>>>
>>>> Since we no longer need to make new_folio->index >= end work for anon
>>>> folios, can we drop the end = -1 in the if (is_anon) { ... } branch?
>>>
>>> Sure.
>>
>> A second thought on this one. If I remove end = -1, can static analysis
>> tools understand that end is not used when a folio is anonymous?
>> Probably, I can initialize end to -1 and remove end = -1 in is_anon
>> branch.
>
> Smatch says that "if "mapping" is non-NULL then "end" is initialized"
> and it doesn't trigger a warning. I don't know how the other checkers
> handle it.

Great. Thank you for running smatch for it.

>
> Btw, the only thing you really have to pay attention to is Clang because
> we treat build warnings as failure. You're always free to ignore other
> checkers.

Good to know. I will compile my code using clang to get a sense on how
checkers will react to my changes. Thank you for the information.

Best Regards,
Yan, Zi