[PATCH v4 1/6] hugepages: Move THP helpers to generic hugepages abstraction

Wilco Dijkstra Wilco.Dijkstra@arm.com
Thu Mar 5 21:26:02 GMT 2026


Hi Rui,

I don't believe we need both malloc-hugepage.c/h as well as hugepage.c/h. That's
extra complexity and unnecessary abstraction for no gain.

+enum hugepages_thp_mode_t
+{
+  hugepages_thp_mode_always,
+  hugepages_thp_mode_madvise,
+  hugepages_thp_mode_never,
+  hugepages_thp_mode_not_supported
+};

This is getting very hard to read with double use of huge pages. Also it's 2026 and
we're still having to work around this crazy 80 character limit... So why not just:

enum thp_mode_t
{
  thp_mode_always,
  thp_mode_madvise,
  thp_mode_never,
  thp_mode_not_supported
};

Similarly get_thp_mode () and get_thp_size () would be easier to understand without
prefixes and redundant "__". We don't need malloc specific veneers for these.

It's best to remove the DEFAULT_THP_PAGESIZE check. MALLOC_DEFAULT_THP_PAGESIZE
can be defined by the hugepage.h header since it is directly related to huge pages, however
it doesn't need to be checked in get_thp_size().

Cheers,
Wilco



More information about the Libc-alpha mailing list