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 AF9EE3CEBAC for ; Fri, 20 Mar 2026 16:06:28 +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=1774022792; cv=none; b=dTanmN0A0BhZ1cMgSggo8Q4P2ie+Ca7E2aHWP3Ohe39C3p3IEippWGM7wYPdL5b+iY2kvUb87cD46uIXG0NRqGHDy4sLCJ4DNvtoct9c26O/xgFi9uWIY+4wndWCpT8qA7UrOlxreXydAwsLm5fWDJh+UJzVxIWxImH+Zoj0qm8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774022792; c=relaxed/simple; bh=UGsJnKeScicwgBdocc9aajUpugkBYpAy3Js1cC2djLU=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=REKBaXYHvqrvMly0an2sorDxaN9l9cyBjgZ6N/U2uwLjHCSe0/BxJdGT3dq/d16FYrdlr4GbfKcMwjuS+iy8hbUx//b3tH9mq7UbPSU7g8048MwaWnHefa0HEs4tgsjCCETVnVQZdxJj/zfctkAJuskt0LUQpZa8FUWo6Et0/RI= 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=bNYp0mZl; 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="bNYp0mZl" 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=pGpNwDo+f1ausatMeb9NVGgU/g8VF/Bac4ooJHeFm+k=; b=bNYp0mZlRsTWoWlEWxvt7ymdDT XbGsJ6fFDWHu/4zmFFnpSpoo155CcIttoKcCNcGa70B1cd7n15qzeIEu8uClLJZltkfRwnr5lTQW9 3li50gw378Zkglr+2P8HUOq0GbXEDF3P2Lijxo7w/vC6RW863j1S9qC0gygKI8w2Da3Qt4LenTl82 lfxm3OHs/U2Gm8vjldNB6ViLT2r/k/6hcrwaPnoqLmNXQM/UzgfIOqjLCbJHtRADxEiIHuzUz+gfU Ne9/nZZa7ROrSn9Dcat/UOcGgO7Ysp1e62qXfwBrhIw0EKCVWkm8mJIDaG6ddVRxisfFXiF203yEj OY/i2bgA==; Received: from authenticated user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2) (envelope-from ) id 1w3cMM-005Jzm-Ex; Fri, 20 Mar 2026 16:06:01 +0000 From: Breno Leitao Subject: [PATCH 0/2] mm: huge_memory: clean up defrag sysfs with shared data tables Date: Fri, 20 Mar 2026 09:05:23 -0700 Message-Id: <20260320-thp_defrag-v1-0-6ab15d0d26eb@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=H4sIAERwvWkC/yXMQQqDMBAF0KsMf20gRusiVymlpMmMjgsriYog3 r1ol2/zDhTOygWeDmTetOh3gqe6IsQhTD0bTfAEZ11nG2fNMszvxJJDbx6tldhKLaFJqAhzZtH 9zp6vv8v6GTku14Dz/AFGyVK4bgAAAA== 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.15-dev-363b9 X-Developer-Signature: v=1; a=openpgp-sha256; l=1274; i=leitao@debian.org; h=from:subject:message-id; bh=UGsJnKeScicwgBdocc9aajUpugkBYpAy3Js1cC2djLU=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBpvXBjRMwsF8ICE7/H7S7/LmmV0dP1A9rv1VPfn aRd58RANK+JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCab1wYwAKCRA1o5Of/Hh3 bR9qD/0bg8cG1ks2LE9vrdmVytx8BjhPmeOC/6BgKO3lP8KeSRghWVGYwTih7CVDThWcUq4KICZ UGwT9M7OsRzb7QnJIMPRHmiyjhlZJduxe8gVoX2XeMUZ5XU+MG3hyY6xXyajKmNI9oZIShsqKFO t6R8TZpNuQPvv6So7M6tLwjQYT7lx9djnWIVBs1SAUUx+F7KHaeh2VdKChUUk3yji0iA2rRBzZ5 5CpDzWOUPFz4FMU3jq5/HIUlR1wJOhf5L6rVwba/G8hC/njTxJsz18PKHcTPFjTbXWIZCgxTtrk PieGOjhsWFqjTgBXxkw/3eZ0MtK8xZfQoUXkEt5KTxnxpfexhxhrOkaAbroudJxfZd4P7Crf2Mt Nc97Nb5IZxC8UCUZxUhMgPVEV+qqjHxpFUcezyJrYVuu5drx5pF/wt7oH5J6RmKwQkKDL+5AzO2 VANeo3IRJ9OZZpIAwrpQnfly1ev+6M2YYHuPP+1D3iTQiAzehtBYf/3sr0z899OVyUqdLkBJ2G+ qgciZKlWFxQYLEv+ImPmIkweC/WolMsOHeJ4AfTI/YIRei34lPjSa8DBtPbVzikEbTtDrkbKdBY SoYlWECu2JgqQJC+VSaNEo/v0BLCbnh+khwIuc1kSW8lohTxA1uK9Nvthbe6LFlEw1yT6GFP7MO mMs5dMX9tW04ZDg== 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 --- 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: 785f0eb2f85decbe7c1ef9ae922931f0194ffc2e change-id: 20260320-thp_defrag-540fc4f1fa3d Best regards, -- Breno Leitao