[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2e8bf48a-b819-40b9-bb9b-f6ac6672059a@huaweicloud.com>
Date: Thu, 15 Jan 2026 08:52:50 +0800
From: Chen Ridong <chenridong@...weicloud.com>
To: Waiman Long <llong@...hat.com>, Yury Norov <ynorov@...dia.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Alistair Popple <apopple@...dia.com>, Byungchul Park <byungchul@...com>,
David Hildenbrand <david@...nel.org>, Gregory Price <gourry@...rry.net>,
Johannes Weiner <hannes@...xchg.org>, Joshua Hahn <joshua.hahnjy@...il.com>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
Matthew Brost <matthew.brost@...el.com>, Michal Hocko <mhocko@...e.com>,
Michal Koutný <mkoutny@...e.com>,
Mike Rapoport <rppt@...nel.org>, Rakie Kim <rakie.kim@...com>,
Suren Baghdasaryan <surenb@...gle.com>, Tejun Heo <tj@...nel.org>,
Vlastimil Babka <vbabka@...e.cz>, Ying Huang <ying.huang@...ux.alibaba.com>,
Zi Yan <ziy@...dia.com>, cgroups@...r.kernel.org
Cc: Yury Norov <yury.norov@...il.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] cgroup: use nodes_and() output where appropriate
On 2026/1/15 6:33, Waiman Long wrote:
> On 1/14/26 12:22 PM, Yury Norov wrote:
>> Now that nodes_and() returns true if the result nodemask is not empty,
>> drop useless nodes_intersects() in guarantee_online_mems() and
>> nodes_empty() in update_nodemasks_hier(), which both are O(N).
>>
>> Signed-off-by: Yury Norov <ynorov@...dia.com>
>> ---
>> kernel/cgroup/cpuset.c | 7 +++----
>> 1 file changed, 3 insertions(+), 4 deletions(-)
>>
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index 3e8cc34d8d50..e962efbb300d 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -456,9 +456,8 @@ static void guarantee_active_cpus(struct task_struct *tsk,
>> */
>> static void guarantee_online_mems(struct cpuset *cs, nodemask_t *pmask)
>> {
>> - while (!nodes_intersects(cs->effective_mems, node_states[N_MEMORY]))
>> + while (!nodes_and(*pmask, cs->effective_mems, node_states[N_MEMORY]))
>> cs = parent_cs(cs);
>> - nodes_and(*pmask, cs->effective_mems, node_states[N_MEMORY]);
>> }
>> /**
>> @@ -2862,13 +2861,13 @@ static void update_nodemasks_hier(struct cpuset *cs, nodemask_t *new_mems)
>> cpuset_for_each_descendant_pre(cp, pos_css, cs) {
>> struct cpuset *parent = parent_cs(cp);
>> - nodes_and(*new_mems, cp->mems_allowed, parent->effective_mems);
>> + bool has_mems = nodes_and(*new_mems, cp->mems_allowed, parent->effective_mems);
>> /*
>> * If it becomes empty, inherit the effective mask of the
>> * parent, which is guaranteed to have some MEMs.
>> */
>> - if (is_in_v2_mode() && nodes_empty(*new_mems))
>> + if (is_in_v2_mode() && !has_mems)
>> *new_mems = parent->effective_mems;
>> /* Skip the whole subtree if the nodemask remains the same. */
> Reviewed-by: Waiman Long <longman@...hat.com>
>
Reviewed-by: Chen Ridong <chenridong@...weicloud.com>
--
Best regards,
Ridong
Powered by blists - more mailing lists