Re: [PATCH mm-new v2 0/5] mm: remove unused functions
From: Dev Jain
Date: Wed Nov 18 2026 - 22:56:17 EST
On 19/11/26 12:25 am, Garg, Shivank wrote:
> On Wed, 2026-11-18 at 22:44 +0530, Dev Jain wrote:
>>
>> On 18/11/26 10:35 pm, Dev Jain wrote:
>>>
>>>
>>> On 17/11/26 12:46 pm, Shivank Garg wrote:
>>>> This series removes five functions and one variable in mm that have no
>>>> users left anywhere in the tree. I found them with the kunused scripts
>>>> [1], which I wrote with LLM's help. The v1 cover letter [2] has more
>>>> details on the scripts and how LLM was used.
>>>>
>>>> Changes in v2:
>>>> - Split v1 [2] up by MM tree, as David suggested. These five patches
>>>> are based on mm-new.
>>>> - No changes to the patches themselves.
>>>>
>>>> [1] https://github.com/AMDESE/linux-mm/tree/shivank/kunused
>>>> [2] https://lore.kernel.org/r/20261026-unused-sym-v1-0-82ca2dceabe1@xxxxxxx
>>>>
>>>> Signed-off-by: Shivank Garg <shivankg@xxxxxxx>
>>>> ---
>>>
>>> Okay I just recalled that there have been numerous cases where people ran
>>> scripts / compiler with flags etc and sent patches to remove unused functions,
>>> but maintainers rejected them citing they are there for a future use. Here
>>> are some of those instances:
>>>
>>> https://lore.kernel.org/all/20240907021506.4018676-1-Liam.Howlett@xxxxxxxxxx/
>>> https://lore.kernel.org/linux-mm/20100211052247.GA15392@localhost/
>>>
>>> So I think the commit messages need to do more, they need to prove that the
>>> unused function was a genuine oversight.
>>>
>>
>> One way to do that would be to mention the commit and its date, if its too old,
>> or, if it was part of a patch series but then the author changed their
>> strategy in the later patches making the function redundant, etc etc.
>>
>> In patch 1, you remove mapping_clear_release_always() but d73065e60dcc 's description
>> implies it is going to get used, which is confusing. Maybe we are missing
>> a genuine bug, or the author forgot to drop the stale description across
>> revisions.
>>
>
> Hi Dev,
>
> Thanks for the review. I agree that some unused symbols may be kept
> intentionally for a planned future user, which I checked for before
> sending.
>
> For most patches I had included some history, like the commit that
> removed the last caller or the commit that added them without one. I
> missed that for mapping_clear_release_always() in this patch and for
> make_guard_swp_entry() in patch 2, so here is the history for both:
>
> - mapping_clear_release_always() was added in b4fa966f03b7 ("mm, netfs,
> fscache: stop read optimisation when folio removed from pagecache") and
> never had a caller. Earlier version of had called it from ->evict_inode()
> but V4 dropped those calls as unnecessary [1] leaving the helper.
>
> - make_guard_swp_entry() was added in 7c53dfbdb024 ("mm: add PTE_MARKER_GUARD
> PTE marker"), has never had a caller, and none has been posted in 2 years.
>
> I left some symbols out because a posted series adds callers, for
> example folio_dup_file_rmap_pmd() and folio_is_pfmemalloc(), or because
> they are one half of a pair whose other half is still used, like
> kmsan_poison_memory().
>
> [1] https://lore.kernel.org/all/166924370539.1772793.13730698360771821317.stgit@xxxxxxxxxxxxxxxxxxxxxx
Thanks! Sounds good, you can reply to the individual patches with the additions
so that akpm/David H. can fold that in.
>
> Thanks,
> Shivank