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=1794240583; b=uBSXmAoRQdZYnpeYzTeRt9m51WriolCUPkOMJuJgCjl+jqv75CP6emj5xCAjtRwLMXuu XXeL2JLD5ecTh3a/zV9zFZmh0Ks+gCkjXl/9lCODp/GTwRKhO4c7Crtb+TAnHPz7cigLb gyu9U9Ulwl2h4rJeJhof9hFWUJudceQseWdaESBWWpfofYl2d4RzhTQ+lxFMV2q0sp+Ld HN7dWiqR7NEV5GlBfxJpNNWjK3U3AP/fgx1x8z998TPoBWaXGAppNSt5jD2/RHLdAMaiU 2i6HwuK3a/ZBo545W+n8BjFnnBdZXSCJgCPKXrOjOrvdj2EEwfZkiHQVKOjGurhOyPQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794240583; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=DXSPfaV7kxolJWnOKot1CieAHZ75QGSf+nsTqu3pO8o=; b=tb1Ldith1S6pJy9pkrisGyw+B+H1q0XP02BEzTPhazenvuopDU5wBIw2PhuRNAiH/Ijr q85S4Vz6fVZFKjs2yTULk+vxo+mjHO+oMVFp/Gsau4JcKcHKZHz3hrbpJZa5cqy9y9uCa BrOoGL2G/dgI2GAZkAMXtyi5zCfXBAacvaGKHHgCuRUPgDoL4lxfWaCT6/JpVlZFi+1mX WlnT1LQEjm22UcYoiDU8/EHui46tTiZsNnN9MiWGhYt7iEiDZfEeWcAQNnVrKto2rRCev o6gSFM7onV8iWQXdq1yUt+IXYT5bB5cyxRrNXm64NOLrC63vCBcELGrrQh4E8jbDnQw== 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=d3s0tNQp; 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 4EB98606A33A for ; Mon, 9 Nov 2026 16:09:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4EB98606A33A 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=d3s0tNQp DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794240582; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DXSPfaV7kxolJWnOKot1CieAHZ75QGSf+nsTqu3pO8o=; b=d3s0tNQp8gzqi9h/uDDSt5/63RE4gtqwGwrOt17clMXPrI/+aXPrkaEHkwcYpaZdTxnEsO QdEfgE/ZhYZFA8pYxywhgCfM6mR0w7wIsPWmJzmKFUVwMZy++J+a548TYYNdBt9zSPeLR3 iyKaoVeThlrwhuIZalASiKfbT/hLwf0= 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-343--w5wPgMrPUSsEI5tA3MoCw-1; Mon, 09 Nov 2026 11:09:37 -0500 X-MC-Unique: -w5wPgMrPUSsEI5tA3MoCw-1 X-Mimecast-MFC-AGG-ID: -w5wPgMrPUSsEI5tA3MoCw_1794240575 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (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 63A1A1956062; Mon, 9 Nov 2026 16:09:35 +0000 (UTC) Received: from llong-thinkpadp16vgen1.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8594726C; Mon, 9 Nov 2026 16:09:33 +0000 (UTC) From: Waiman Long To: Ridong Chen , Tejun Heo , Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Shuah Khan Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Guopeng Zhang , Waiman Long , Sashiko Subject: [PATCH 4/5] cgroup/cpuset: Correctly set cpus_updated in cpuset_hotplug_update_tasks() Date: Mon, 9 Nov 2026 11:09:11 -0500 Message-ID: <20261109160912.1369897-5-longman@redhat.com> In-Reply-To: <20261109160912.1369897-1-longman@redhat.com> References: <20261109160912.1369897-1-longman@redhat.com> 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 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 When cpuset_hotplug_update_tasks() is called with the conditions that either remote_partition_disable() or update_parent_effective_cpumask() has to be called, the cs->effective_cpus can be updated such that it matches what is computed in new_cpus. In such case, cpus_updated can be incorrectly set to false leading to stale CPU afinity remained in the tasks not matching the new cpuset value. Fix that by forcing cpus_updated to true whenever one of these partition helpers is being called. Fixes: 4b842da276a8a ("cpuset: Make CPU hotplug work with partition") Reported-by: Sashiko Link: https://sashiko.dev/#/bug/linux-ab90f7e8-0d60-40ca-83e9-e405075b24d2 Signed-off-by: Waiman Long --- kernel/cgroup/cpuset.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 1f25f27e0e9b..742a719b4180 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -3998,7 +3998,7 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp) { static cpumask_t new_cpus; static nodemask_t new_mems; - bool cpus_updated; + bool cpus_updated = false; bool mems_updated; int partcmd = -1; struct cpuset *parent; @@ -4011,12 +4011,18 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp) if (!tmp || !cs->partition_root_state) goto update_tasks; + /* + * cpus_updated should be set to true when remote_partition_disable() + * or update_parent_effective_cpumask() is called as cs->effective_cpus + * may have been updated. + */ if (is_remote_partition(cs) && (!cpumask_subset(cs->effective_xcpus, subpartitions_cpus) || (cpumask_empty(&new_cpus) && partition_is_populated(cs, NULL)))) { WRITE_ONCE(cs->prs_err, PERR_HOTPLUG); remote_partition_disable(cs, tmp); compute_effective_cpumask(&new_cpus, cs, parent); + cpus_updated = true; } /* @@ -4041,6 +4047,7 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp) partcmd = partcmd_update; if (partcmd >= 0) { + cpus_updated = true; update_parent_effective_cpumask(cs, partcmd, NULL, tmp); if (is_partition_valid(cs) || (partcmd == partcmd_invalidate)) { compute_effective_cpumask(&new_cpus, cs, parent); @@ -4049,7 +4056,7 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp) } update_tasks: - cpus_updated = !cpumask_equal(&new_cpus, cs->effective_cpus); + cpus_updated |= !cpumask_equal(&new_cpus, cs->effective_cpus); mems_updated = !nodes_equal(new_mems, cs->effective_mems); if (!cpus_updated && !mems_updated) goto unlock; /* Hotplug doesn't affect this cpuset */ -- 2.56.0