Re: [PATCH v4 0/2] mm/hugetlb: refactor sysfs/sysctl interfaces

From: Oscar Salvador

Date: Wed Nov 05 2025 - 09:16:22 EST


On Wed, Nov 05, 2025 at 10:42:42AM +0800, Hui Zhu wrote:
> From: Hui Zhu <zhuhui@xxxxxxxxxx>
>
> The hugetlb.c file has grown significantly and become difficult to
> maintain. This patch series extracts the sysfs and sysctl interface
> code into separate dedicated files to improve code organization.
>
> The refactoring includes:
> - Patch 1: Extract sysfs interface into mm/hugetlb_sysfs.c
> - Patch 2: Extract sysctl interface into mm/hugetlb_sysctl.c
>
> No functional changes are introduced in this series. The code is moved
> as-is, with only minor formatting adjustments for code style
> consistency. This should make future maintenance and enhancements to
> the hugetlb subsystem easier.
>
> Testing: The patch series has been compile-tested and maintains the
> same functionality as the original code.
>
> Changelog:
> v4:
> According to the comments of David Hildenbrand, add copyright of
> hugetlb.c to hugetlb_internal.h, hugetlb_sysctl.c and hugetlb_sysfs.c.
> v3:
> According to the comments of SeongJae Park, updated MAINTAINERS to
> add new files.
> Removed the wrong copyright in hugetlb_internal.h.
> v2:
> According to the comments of David Hildenbrand, removed the wrong
> copyright in the file headers.
>
> Hui Zhu (2):
> mm/hugetlb: extract sysfs into hugetlb_sysfs.c
> mm/hugetlb: extract sysctl into hugetlb_sysctl.c

I am replying here as a response to https://lore.kernel.org/linux-mm/58d3c50f-2b4a-4053-a846-613434d5bcd9@xxxxxxxxxx/T/#mf694af3f5a6ca56b76adf66352cbb88d022fe36c

So, taking a look at patch#1 as an example,which moves sysfs stuff into hugetlb_sysfs.c.
I have the feeling we are moving too much stuff. It is true that drawing a line
is not easy, but e.g: you mention

The following components are moved to mm/hugetlb_sysfs.c:
- hugetlb page demote functions (demote_free_hugetlb_folios,
demote_pool_huge_page)

I __think__ that moving demote_store() into hugetlb_sysfs.c is fine, but although
demote_pool_huge_page and demote_free_hugetlb_folios are only called from there,
they look more than a sysfs interface and more like hugetlb generic code.

Again, drawing a like might be difficult, but I think that e.g: we should only move
sysfs entry points functions into hugetlb_sysfs.c

Does that make sense?


--
Oscar Salvador
SUSE Labs