From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF7A61EE7C6 for ; Wed, 8 Apr 2026 15:47:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775663255; cv=none; b=NpWTveez1psFpm30Sb3iUe5BJ43N+4dWLnpeUey8z6j5yL+CjiezGcw8RsFTZ2N6Dx6XSDlUOPPb5NpdJgo73RMTFmFNSarn5yb0/lz6YhLIDTVpKGTEC/iuf1ILTh8pS8cPgD9iskrCbvdLUPzW6wl+Gexp5el9u8LGw4TEasg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775663255; c=relaxed/simple; bh=ORU6TEMuXSX3gagyRoSqYOuhy7BGhkP/KFoWhinuBco=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=cmNIDew2bx4pGtpU2cKENSBafwBZ5cNIHawltALv/QzeHZbumASPKhUQsqUYDU9NcMSmFS3xDVrXfKg4MIIyMwpnyetk4gYad/lBgoIIsWjmSGuJ1RiskoGO0hkR3NueHQPYM4xy3dx6MBsMUREofUWrmUHlsH9AY+52RWm+a08= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=none smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=dSVEcEoS; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="dSVEcEoS" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-Id:Date:Subject:From:Reply-To:Content-ID: Content-Description:In-Reply-To:References; bh=WQBQpmhO7K+JMC5pO21nDiBudOMp6NAQQ2jDhZLgte8=; b=dSVEcEoS8p6QTo+xy94ju+Qawi PJErsOo3PJUalqQGUNXd0n83zV0tqzvaLojM35OgHgZ9XzUEyTrqZlKygNblrm186SGKhhoxUsAlZ sUrDJZK3OiOzaQKyKVq6hlCADXx7s/UF41ec9g1JJyfOYDqLiZKaYFiYLqyU9yWqkvC7d83CirmMT +tHSrQW16uAjWOmRP5oPWmzvkvOQAPa/l3+2Fp2glsmQTrwovJ4xT5TShwJdK7BS4rA+Gm9DVXdmD Uv1MgaI1nEK2kFayaDCwVJN3r+RHrG1DtnjVpmY9UtelsvysreuazckrJSCvJWktKNs8O2hqtN4DC PeNnipbg==; Received: from authenticated user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wAV7l-008Wdv-0C; Wed, 08 Apr 2026 15:47:25 +0000 From: Breno Leitao 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 Message-Id: <20260408-thp_defrag-v2-0-bc544c1bde4e@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAHN41mkC/23NSwrDIBSF4a3IHcei5jHIqPsooWi8mttBDGpCS 3DvxXTa4YGf75yQMBImGNkJEQ9KFFYYmWoYzItePXKyMDJQQg2iVYLnZXtadFF73nfCzZ2TTrc WGgZbREfvC3tMv51288I5V6EWC6Uc4ud6O2Tt/sKH5IIP2sjeCqsGNHeLhvR6C9HDVEr5Av96O CW3AAAA X-Change-ID: 20260320-thp_defrag-540fc4f1fa3d To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , Zi Yan , Baolin Wang , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-453a6 X-Developer-Signature: v=1; a=openpgp-sha256; l=1451; i=leitao@debian.org; h=from:subject:message-id; bh=ORU6TEMuXSX3gagyRoSqYOuhy7BGhkP/KFoWhinuBco=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBp1niIlESg6fWs0gSoTm/P8RGRLGG25TN6LPR/t vS9X4EUD0KJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCadZ4iAAKCRA1o5Of/Hh3 bYLQEACetudlSIF7MfyrhfJbDvQvmBuzC6e39WlDdqt6c6ZswIF5L9ZLisjupWui436LVvrgWLt 6W95zLXcrJYDb2XMQXbH4B/VFmDyK1VwGlqk7f7NybBg6wi+CRHZOIarsPNhd7vofKLbl/Ck7a5 KtDNzQ3Jm4uofs5jLwvgUSMQwFAglSLumwp06dBLvnHJdTscbBQ4Utg7o1trwNxd8D3jj22PejA Wmh4MiIOrdXEi3ZLysfvqAHxVH4MNZwg8AMW1hA0ztfer3wtdbTls5bQtNUP+KN7K0a8Edh8EO5 bBrT1rd2wNad7UricvrPcjQmgBvRx+OkkcQw949w7ydCjMhBiX3Kb7QDAPn30/A7749YS3P/6S0 KVV+GKGYLl7VRfxdQ3PWUoI1mhQuACCaxnMFfVI1k3jCn+RtTuLmb3KvnHfX3FDqRSbtWZRCNOt JNwPYZKJDhBihvkGEjLfflCkcfuj9W5cuFHBwJOPqwgoTY6o7Q/iQ9IpkX/N0U0tNHY/FPZz01P oo+FYvhrWv8E+e+sMAivUtGbQo6z0KxDUZKPSpx262euW03JycQhNOCiWwL00lbcsi/k9HKb83x UzL1OLr5ntZ/wEnEC63+uPhv63B0X+7+FrUQWhrGPaF9HQyoSW1C4H36e2NLNp5BliwoXdzi+fO h6MP9cGQnmyvvAA== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao 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 --- 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