From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) (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 822A4309EFC for ; Fri, 3 Apr 2026 05:09:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775192961; cv=none; b=uP9EFyJ514Wt/QJXMmdjWjtZY2THbH4721oFq/AVewk0xlVwOpj4KqYXzNxz9qUlDWYWI11MiAIN1doiKxl340c2DGo0/1wDb/KuJYYjvyqk+Om3zjQsnMvBIDBgfCk7yP4aTTqwpjTq1muEMh+cObNaCMbY4NsD7wrmvNXFHZM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775192961; c=relaxed/simple; bh=YdpnKr9fBRJhSs6nd3YO7FWZm0vYV2FOAB9KHAZ16bw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=DCDluYFmhKtXaUT2PmuUPr5o5nv1+8zNhEomdELa+Op1s1CjaSWOw6/I9DZlyahxai1PVxoPGzkn1L8qd/d8dIG3Y8IEYCAlg8+T9W2tPXjmjqCssQseMhIIddeza573zs7WoKnUusEw61ZVKYL+CxtebrffKvDx7O7wJ2WTTw4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=p2FhMQJk; arc=none smtp.client-ip=95.215.58.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="p2FhMQJk" Message-ID: <0be813e8-1117-48c1-aeba-c584cda9aa31@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1775192957; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3EO3KZcrJUWPCB4Hstcu+7wwY1J06Wb0Uds4H2tFoho=; b=p2FhMQJknXonfhMlg8x6dU8op9V7lepg5A5gFInMx8Eir2oQv8LJ2Lpj8S0mZdnlkH2nvs xYtAj7FODrkAuYpa48E6xc6SNkjXtuTpxq7//mVesG9nIGt0s+yIzmWbm4ICpIEXyWmF8u c2v1B3ogQ8VvF4CwQDjn397mu3xFcaM= Date: Fri, 3 Apr 2026 13:09:05 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH 1/2] mm: huge_memory: use sysfs_match_string() in defrag_store() Content-Language: en-US To: Breno Leitao Cc: linux-mm@kvack.org, Nico Pache , "Liam R. Howlett" , Zi Yan , Ryan Roberts , David Hildenbrand , Barry Song , linux-kernel@vger.kernel.org, kernel-team@meta.com, Lorenzo Stoakes , Dev Jain , Baolin Wang , Andrew Morton References: <20260320-thp_defrag-v1-0-6ab15d0d26eb@debian.org> <20260320-thp_defrag-v1-1-6ab15d0d26eb@debian.org> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Lance Yang In-Reply-To: <20260320-thp_defrag-v1-1-6ab15d0d26eb@debian.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2026/3/21 00:05, Breno Leitao wrote: > Replace the if/else chain of sysfs_streq() calls in defrag_store() > with sysfs_match_string() and a defrag_mode_strings[] table. > > Introduce enum defrag_mode and defrag_flags[] array mapping each mode > to its corresponding transparent_hugepage_flag. The store function now > loops over defrag_flags[], setting the bit for the selected mode and > clearing the others. When mode is DEFRAG_NEVER (index 4), no index > in the 4-element defrag_flags[] matches, so all flags are cleared. > > Note that the enum ordering (always, defer, defer+madvise, madvise, > never) differs from the original if/else chain order in defrag_store() > (always, defer+madvise, defer, madvise, never). This is intentional to > match the display order used by defrag_show(). > > This is a follow-up cleanup to commit 522dfb4ba71f ("mm: huge_memory: > refactor anon_enabled_store() with change_anon_orders()") which applied > the same sysfs_match_string() pattern to anon_enabled_store(). > > Signed-off-by: Breno Leitao > --- Thanks. Tested-by: Lance Yang With David's comments addressed, feel free to add: Reviewed-by: Lance Yang Cheers, Lance