From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-174.mta0.migadu.com (out-174.mta0.migadu.com [91.218.175.174]) (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 3DEC53AF651 for ; Wed, 11 Mar 2026 11:44:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773229468; cv=none; b=sUMc/i/85mP73blbd3xs7A+2trGoAdG4tMrjO9lkIr0/ufwY4oeIhsg+7gipVHm5/xr/Ais0IKLoj/+3C4w/dx5ImG2vl2t88oJnltoctNwQuglSnGDbIATbiMBFFVnQQGlIAZJV1ahcB97heo8YGHsLd8r1OoehvLdEnDI5+mo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773229468; c=relaxed/simple; bh=Xv3CwUmKD7pjFGUL/RMT4FcE0yGwOQH4yyFDi7vVF9Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ZT71V/1kHEaDCcpCLz24uV7G0ILu3OZGZHZcW4MC7cRSlzCFfF3vYqCzj5NHwZkJeZZoKohL7NnX0hmXwrWqkvd6AT32+hNp1qrtamr8PETjZVbdjysakPLw/Cmz4tGZav5PfQdYJYfkkKA6F7YtQ2FIqc9fFfOe4sQrU6BjPI4= 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=oX0/qMxh; arc=none smtp.client-ip=91.218.175.174 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="oX0/qMxh" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1773229464; 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=J34oKXAGHt0kDLlGsV2li619UZ6TwOGEO+ecUWnzr6Y=; b=oX0/qMxhM9vQxBBOeW/tWwiiKCL3PRyhhmuNM3+BJZ6d/Z2lZcxB5ZUgsVPYagoKvtkdPw affC25J/2cLwQo/X2IADmBZKJbveeJeBV435NDuD22Tpct1TKsReFFlQ8fEfO4U9uqrVdk Rp7huVeylRmN8mPOteVd5PAo5D85fRA= Date: Wed, 11 Mar 2026 19:44:08 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v6 2/4] mm: huge_memory: refactor anon_enabled_store() with change_anon_orders() Content-Language: en-US To: Breno Leitao Cc: linux-mm@kvack.org, Mike Rapoport , Vlastimil Babka , linux-kernel@vger.kernel.org, Dev Jain , usamaarif642@gmail.com, Baolin Wang , kas@kernel.org, Michal Hocko , Suren Baghdasaryan , Nico Pache , Zi Yan , kernel-team@meta.com, "Lorenzo Stoakes (Oracle)" , "Liam R. Howlett" , David Hildenbrand , Lorenzo Stoakes , Brendan Jackman , Andrew Morton , Barry Song , Johannes Weiner , Ryan Roberts References: <20260311-thp_logs-v6-0-421e30d881e0@debian.org> <20260311-thp_logs-v6-2-421e30d881e0@debian.org> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Lance Yang In-Reply-To: <20260311-thp_logs-v6-2-421e30d881e0@debian.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2026/3/11 18:17, Breno Leitao wrote: > Consolidate the repeated spin_lock/set_bit/clear_bit pattern in > anon_enabled_store() into a new change_anon_orders() helper that > loops over an orders[] array, setting the bit for the selected mode > and clearing the others. > > Introduce enum anon_enabled_mode and anon_enabled_mode_strings[] > for the per-order anon THP setting. > > Use sysfs_match_string() with the anon_enabled_mode_strings[] table > to replace the if/else chain of sysfs_streq() calls. > > The helper uses test_and_set_bit()/test_and_clear_bit() to track > whether the state actually changed, so start_stop_khugepaged() is > only called when needed. When the mode is unchanged, > set_recommended_min_free_kbytes() is called directly to preserve > the watermark recalculation behavior of the original code. > > Signed-off-by: Breno Leitao > Reviewed-by: Lorenzo Stoakes (Oracle) > --- Thanks! Tested-by: Lance Yang