From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) (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 075B331A061 for ; Wed, 11 Mar 2026 01:37:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.110 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773193071; cv=none; b=bTJF0vulfKYXooTcd6FVCZqjUxFrh7wXgZPGXuPd/jAYhaHLHVifS3OJOSfZnM9iljZZ9JVLK0C9Zz/QEL4vOTgQljzi8coyDkIeqIbjoU1L2Fy+1mcaorPof9a8oVE6vy1XFtnt7IRfHLOUmvjQwNbsIj7WLiH/LDIcAK1EkIU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773193071; c=relaxed/simple; bh=Q1j1Sz67Dzf4W3MCc9aMjrG/Z7y1RFpB+EfjzcdiwNo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=u5Z3l5EzixzP+1pvAIeGE0FOZdawTio3j1xvgGqPHxA8RD8wBcF0oPBCkozGPgf6nEOEZEkjgeMbi698iuTn8ma6HCvnLKnRLcSCHgAW38ItshHHDzhTlxmYgAcIyRhxtz1cjgParCiBClmjbdgnlH3ovthZGy+y1KBghTYRxPY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=gl+vhfFu; arc=none smtp.client-ip=115.124.30.110 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="gl+vhfFu" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1773193061; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=OgU6nTqZrRU2uknMVZdkalSe93rsrUBZvBhDOt8pxv4=; b=gl+vhfFucg0681wzEq/imYrFyKreWYoyRV+h8EjBI1HOJ73meLcfLAu8iTcVeVkZbBM/k0mx1kSDKgkMNetM5EE02k9PPA/TMzum3SEheFkbl27zr2q9tPca0s44JOnNZlwejCpThabcQy2RMH4bJGHS4jKZ28EiBWaKB77Bz04= Received: from 30.74.144.123(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X-hom3e_1773193058 cluster:ay36) by smtp.aliyun-inc.com; Wed, 11 Mar 2026 09:37:39 +0800 Message-ID: <1b33c5ce-99c2-41f0-8064-c1da5834cff7@linux.alibaba.com> Date: Wed, 11 Mar 2026 09:37:37 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 2/4] mm: huge_memory: refactor anon_enabled_store() with change_anon_orders() To: Breno Leitao , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , Zi Yan , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Mike Rapoport Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, usamaarif642@gmail.com, kas@kernel.org, kernel-team@meta.com, "Lorenzo Stoakes (Oracle)" References: <20260310-thp_logs-v5-0-686099175bf6@debian.org> <20260310-thp_logs-v5-2-686099175bf6@debian.org> From: Baolin Wang In-Reply-To: <20260310-thp_logs-v5-2-686099175bf6@debian.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 3/11/26 1:57 AM, 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) > --- LGTM. Reviewed-by: Baolin Wang