From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796061863; b=ZsK6RZCNr9hDGxMx/sS/p0b9H0VwInxeuJtp0Lmp5bCCo2TCqEkW9ZGTAT9o968utR8I 4u43JuuzsivkO7x4YP7BAe1PaRjYIcnFr0ePzZV2GuauVo+ZJO8A7W0yKjdbjYq7+pArj se0BsFwg3YRYK8pRJHewG78Li2XcEvlcOlzphb1M0dvJGC+2PYPC4IBFW84cAaEQX09iH jDcomLa6dLnvZzrwDnekjNxeMYs4Cv5c0NvAyhNAb1505m/KZm03nyHwoWrUeQwlFTMYB nUTFzBOUVJjvX6qGDZOCTcncuQFJ3Rp0wDzR6Wcmi8650Cj7tMjmWsDo3e4/31X4AnA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796061863; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:Message-ID:Date:MIME-Version: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-Scanned-By; bh=M5ZBKMEM5Lvp+Nb7WLl9V3t7dBBYQbHeXI6NodiJhkQ=; b=iBbLLe986qB2p/Sk29hoUDkrCcXt+F6s/66OEmXh0SnLEbjh2EgfywyHzI1w3j1saras D5f2EMXVKk1L0kz0WB41YENOO6h6MoeDzwRontNsyev7+pDZWI0oJVg4yBK9Qg04N4fiL VvTNaS+6YX6BV3+yFPU0WS6dnuuY6QypZFtmuZ853bXHsVt6DazEXIA5LrDl27JIYdjDp jXhPHlAyAXzT0ql23Y0j16YBbrq6W9zXfPJeBu2agZJSrztUX56ahKC5KwweQt6rE9v0/ 1VvqPYvkgucbl21ZxvWAAg7TesIYEv3tNPfFwXjuYRL1DRIeNs560tUInNFFJGPER/w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BYytXcTR; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65539606A31C for ; Mon, 30 Nov 2026 18:04:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 65539606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BYytXcTR DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796061861; 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=M5ZBKMEM5Lvp+Nb7WLl9V3t7dBBYQbHeXI6NodiJhkQ=; b=BYytXcTR0GdJG+BAKxvq5lp111ksidG9b2el0m6EocBKyadGPtJxhjBvZtxr7TAXSv4h7H JsErlTCY//D8MG748H+xldTtyCLOtRkIEK5RxJjjoz4pY5F9I+aRJAK0PqnrpKbafedNUg DFB3n/6rh3JOvGO4GRv6+w9JonLsoAY= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-625-g4ggaJk2NtSujgTVKolS-A-1; Mon, 30 Nov 2026 18:04:15 +0000 X-MC-Unique: g4ggaJk2NtSujgTVKolS-A-1 X-Mimecast-MFC-AGG-ID: g4ggaJk2NtSujgTVKolS-A_1796061850 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C22191955F3C; Mon, 30 Nov 2026 18:04:09 +0000 (UTC) Received: from [100.91.18.181] (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DBA3130002D6; Mon, 30 Nov 2026 18:04:08 +0000 (UTC) Message-ID: <7b9f5d97-5edf-4963-ace8-9385d159b887@redhat.com> Date: Mon, 30 Nov 2026 13:04:07 -0500 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 4/4] cgroup/cpuset: Skip sibling checks for v2 members without exclusive CPUs To: Chuyi Zhou , tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, ridong.chen@linux.dev Cc: linux-kernel@vger.kernel.org References: <7b9ec8acd1d5fbc2e977ac08450aaf5de5952ce0.1796039668.git.zhouchuyi@bytedance.com> Content-Language: en-US From: Waiman Long In-Reply-To: <7b9ec8acd1d5fbc2e977ac08450aaf5de5952ce0.1796039668.git.zhouchuyi@bytedance.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 On 11/30/26 7:04 AM, Chuyi Zhou wrote: > Changing cpuset.cpus on a cgroup v2 member calls validate_change(), > which walks all siblings under cpuset_mutex to check CPU and memory > exclusivity. The cost of changing one member's CPU mask grows with > the number of children under its parent. > > Skip the walk when the member's cpuset.cpus.exclusive stays empty. > An empty exclusive mask cannot intersect a sibling's exclusive mask. > The check for a sibling whose allowed CPUs are all in the member's > exclusive mask applies only when that mask changes. Only the top > cpuset is memory-exclusive on v2, so the walk can also be skipped > when changing cpuset.mems on these members. > > On a dual-socket Xeon Platinum 8582C with 240 online CPUs, the target > cpuset contained one sleeping task. A writer pinned to CPU 1 alternated > its cpuset.cpus between 2 and 2-3. Each table entry gives the median > latency of 256 write() calls. > > Children Before (ns) After (ns) > 1 861 859 > 64 1425 856 > 512 5184 855 > 2048 24056 853 > > Signed-off-by: Chuyi Zhou > --- > kernel/cgroup/cpuset.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c > index fb2c08b31b53..fb6359d72b68 100644 > --- a/kernel/cgroup/cpuset.c > +++ b/kernel/cgroup/cpuset.c > @@ -805,12 +805,21 @@ int validate_change(struct cpuset *cur, struct cpuset *trial) > !cpuset_cpumask_can_shrink(cur->effective_cpus, user_xcpus(trial))) > goto out; > > + xcpus_changed = !cpumask_equal(cur->exclusive_cpus, trial->exclusive_cpus); > + > + /* > + * On v2 an unchanged, empty exclusive CPU mask cannot conflict with > + * a sibling's CPU masks. Only the top cpuset is memory-exclusive. > + */ > + if (cpuset_v2() && cs_is_member(cur) && !xcpus_changed && > + cpumask_empty(trial->exclusive_cpus)) > + goto valid; > + > /* > * If either I or some sibling (!= me) is exclusive, we can't > * overlap. exclusive_cpus cannot overlap with each other if set. > */ > ret = -EINVAL; > - xcpus_changed = !cpumask_equal(cur->exclusive_cpus, trial->exclusive_cpus); > cpuset_for_each_child(c, css, par) { > if (c == cur) > continue; > @@ -820,6 +829,7 @@ int validate_change(struct cpuset *cur, struct cpuset *trial) > goto out; > } > > +valid: > ret = 0; > out: > rcu_read_unlock(); Reviewed-by: Waiman Long