From: Breno Leitao <leitao@debian.org>
To: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>, Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
Nico Pache <npache@redhat.com>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Barry Song <baohua@kernel.org>,
Lance Yang <lance.yang@linux.dev>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Breno Leitao <leitao@debian.org>,
kernel-team@meta.com
Subject: [PATCH v2 0/2] mm: huge_memory: clean up defrag sysfs with shared data tables
Date: Wed, 08 Apr 2026 08:46:59 -0700 [thread overview]
Message-ID: <20260408-thp_defrag-v2-0-bc544c1bde4e@debian.org> (raw)
Refactor defrag_store() and defrag_show() to use shared data tables
instead of duplicated if/else chains.
Patch 1 introduces an enum defrag_mode, a defrag_mode_strings[] table,
and a defrag_flags[] mapping array, then rewrites defrag_store() to use
sysfs_match_string() with a loop over defrag_flags[].
Patch 2 refactors defrag_show() to use the same arrays, replacing its
hardcoded if/else chain of test_bit() calls and string literals.
This follows the same pattern applied to anon_enabled_store() in commit
522dfb4ba71f ("mm: huge_memory: refactor anon_enabled_store() with
change_anon_orders()").
Breno Leitao (2):
mm: huge_memory: use sysfs_match_string() in defrag_store()
mm: huge_memory: refactor defrag_show() to use defrag_flags[]
Signed-off-by: Breno Leitao <leitao@debian.org>
---
Changes in v2:
- Do not be too verbose on enum defrag_mode (David Hildenbrand)
- Link to v1: https://patch.msgid.link/20260320-thp_defrag-v1-0-6ab15d0d26eb@debian.org
---
Breno Leitao (2):
mm: huge_memory: use sysfs_match_string() in defrag_store()
mm: huge_memory: refactor defrag_show() to use defrag_flags[]
mm/huge_memory.c | 98 ++++++++++++++++++++++++++++++++------------------------
1 file changed, 56 insertions(+), 42 deletions(-)
---
base-commit: f3e6330d7fe42b204af05a2dbc68b379e0ad179e
change-id: 20260320-thp_defrag-540fc4f1fa3d
Best regards,
--
Breno Leitao <leitao@debian.org>
next reply other threads:[~2026-04-08 15:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-08 15:46 Breno Leitao [this message]
2026-04-08 15:47 ` [PATCH v2 1/2] mm: huge_memory: use sysfs_match_string() in defrag_store() Breno Leitao
2026-04-08 15:47 ` [PATCH v2 2/2] mm: huge_memory: refactor defrag_show() to use defrag_flags[] Breno Leitao
2026-04-08 16:04 ` [PATCH v2 0/2] mm: huge_memory: clean up defrag sysfs with shared data tables Zi Yan
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=20260408-thp_defrag-v2-0-bc544c1bde4e@debian.org \
--to=leitao@debian.org \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=kernel-team@meta.com \
--cc=lance.yang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=npache@redhat.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