From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) (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 812CC28D830 for ; Wed, 11 Mar 2026 01:39:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.113 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773193183; cv=none; b=qVuGSc2BDGNYriW1ragFIBXaSSfA13FYDBg19ytqP3upFaBN2gFvRbi8U7sIpFSyj+PqVGu5RYE+aRaW340tvIN9C0+ocsom1lJKutlCxM/kJttks0HWQzb5TRJVkxNKFwVCZ0KHLDfIH30Wk1arD7EnvB0mGxErB/ZA+OMYXkw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773193183; c=relaxed/simple; bh=MA4b3KTqYYK/w3HVg50eFJxUFbfpDAS2JqQG5ZM1yfc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=MOSYdfUDtEe+wj8dvrJQnKiItAoMaDZjePyseJWPBjyxUkU8f1kfKFLHLI8qADaTvg9m/ehGmfnLviMp4OLUOUBz3HIak/X4d8GR0PLHeI0MVZaWN3VCzcg024pzHI/H2J+hHJKPlveKS2nqBLfF8TpJcgefTPVEDKrE4humQUU= 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=cxumdm5/; arc=none smtp.client-ip=115.124.30.113 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="cxumdm5/" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1773193179; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=6rlL3rMH7IAqCMlpwtM16c9Atr/f+hEaClH0Myc424I=; b=cxumdm5/ISTqG68bHq+JZhh1rrqzsxJz4bNHI98ZEm/xhyIFVAEvL5PZ4+rRoHWJl+wVy2DnIPX00qhcCXT1H890/uHy8pvKBSUo+HBp3RvP6WB315AB5NvFYX6JDvDg0uj8iPhaw008Zr6artWu1NavhRkG9dmDi01dTzbKjXk= Received: from 30.74.144.123(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X-hr21m_1773193177 cluster:ay36) by smtp.aliyun-inc.com; Wed, 11 Mar 2026 09:39:37 +0800 Message-ID: <5f3f7b93-5e22-47a9-82b7-dd961a80f532@linux.alibaba.com> Date: Wed, 11 Mar 2026 09:39:36 +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 3/4] mm: huge_memory: refactor enabled_store() with change_enabled() 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-3-686099175bf6@debian.org> From: Baolin Wang In-Reply-To: <20260310-thp_logs-v5-3-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: > Refactor enabled_store() to use a new change_enabled() helper. > Introduce a separate enum global_enabled_mode and > global_enabled_mode_strings[], mirroring the anon_enabled_mode > pattern from the previous commit. > > A separate enum is necessary because the global THP setting does > not support "inherit", only "always", "madvise", and "never". > Reusing anon_enabled_mode would leave a NULL gap in the string > array, causing sysfs_match_string() to stop early and fail to > match entries after the gap. > > The helper uses the same loop pattern as set_anon_enabled_mode(), > iterating over an array of flag bit positions and using > __test_and_set_bit()/__test_and_clear_bit() to track whether the state > actually changed. > > Signed-off-by: Breno Leitao > Reviewed-by: Lorenzo Stoakes (Oracle) > --- LGTM. Reviewed-by: Baolin Wang