From nobody Thu Apr 2 06:31:34 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 8E48530F808 for ; Sat, 21 Feb 2026 18:55:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771700121; cv=none; b=epW+ZP8uuL46XfbfP4BmrAnULkbjgSlDuVpZEkalFcQ1aR5Bqf+4q7LJ0l5GECxu1mGWzo2UgS9fwKTPftXXjBc13MeCXrSOOoTXH2/7iXxquxbOJH//aeWClC7FlkezSZ5rVtrcvPQGARMP8XaTGShZrjWpXD8bRpE1FRg+sMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771700121; c=relaxed/simple; bh=Dm8ouI4wcPuZG9a1WrcqgvvWhTFB3pxL4rOFUvi12V8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QN2s2HeYKazaIrnGrzvcrSe/9/ldHH1SyZgu4fcbDjd2/TjJrbXvtA+ZGaJwbmlr57dsK/0aS5zlZhzrkPl0KsWSgWt6mXXED2gMYZSSLUh84OU9qs9m3lICjmEmV8e4RhtM50g1Vi7PtvO6dVHXkQVCBRTjFYwvI8bOGeTZ/mQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=APHzY4o5; arc=none smtp.client-ip=170.10.133.124 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.b="APHzY4o5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771700118; 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=52VEDWZxrhdgx5iTzfOlzrgMprmkKIqMic5dXsBw/Oo=; b=APHzY4o50XT+mS7fmUxKmplT08HzHNTchbXjj2nTL9DZGy+XVtDt3eBF+WLTCYW9JZDe7L 0x0LJccW9rZGstpvdDrvm3Rs5JavPz7e+qggwlA/K27jJ7lbpXfLS4zFOCIolI29yDFTXq ht7xz9JFBbONuRfYM268SmwxU5l+SEE= Received: from mx-prod-mc-01.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-138-hDjBKlOUPs6aCv5cB5W2Cw-1; Sat, 21 Feb 2026 13:55:13 -0500 X-MC-Unique: hDjBKlOUPs6aCv5cB5W2Cw-1 X-Mimecast-MFC-AGG-ID: hDjBKlOUPs6aCv5cB5W2Cw_1771700111 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 260EA19560A3; Sat, 21 Feb 2026 18:55:11 +0000 (UTC) Received: from llong-thinkpadp16vgen1.westford.csb (unknown [10.2.16.15]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B9F891955D85; Sat, 21 Feb 2026 18:55:06 +0000 (UTC) From: Waiman Long To: Chen Ridong , Tejun Heo , Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Frederic Weisbecker , Thomas Gleixner , Shuah Khan Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Waiman Long Subject: [PATCH v6 6/8] cgroup/cpuset: Move housekeeping_update()/rebuild_sched_domains() together Date: Sat, 21 Feb 2026 13:54:16 -0500 Message-ID: <20260221185418.29319-7-longman@redhat.com> In-Reply-To: <20260221185418.29319-1-longman@redhat.com> References: <20260221185418.29319-1-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" With the latest changes in sched/isolation.c, rebuild_sched_domains*() requires the HK_TYPE_DOMAIN housekeeping cpumask to be properly updated first, if needed, before the sched domains can be rebuilt. So the two naturally fit together. Do that by creating a new update_hk_sched_domains() helper to house both actions. The name of the isolated_cpus_updating flag to control the call to housekeeping_update() is now outdated. So change it to update_housekeeping to better reflect its purpose. Also move the call to update_hk_sched_domains() to the end of cpuset and hotplug operations before releasing the cpuset_mutex. Signed-off-by: Waiman Long Acked-by: Frederic Weisbecker --- kernel/cgroup/cpuset.c | 51 ++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 05adf6697030..3d0d18bf182f 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -130,10 +130,9 @@ static cpumask_var_t subpartitions_cpus; /* RWCS */ static cpumask_var_t isolated_cpus; /* CSCB */ =20 /* - * Set if isolated_cpus is being updated in the current cpuset_mutex - * critical section. + * Set if housekeeping cpumasks are to be updated. */ -static bool isolated_cpus_updating; /* RWCS */ +static bool update_housekeeping; /* RWCS */ =20 /* * A flag to force sched domain rebuild at the end of an operation. @@ -1188,7 +1187,7 @@ static void isolated_cpus_update(int old_prs, int new= _prs, struct cpumask *xcpus return; cpumask_andnot(isolated_cpus, isolated_cpus, xcpus); } - isolated_cpus_updating =3D true; + update_housekeeping =3D true; } =20 /* @@ -1306,22 +1305,22 @@ static bool prstate_housekeeping_conflict(int prsta= te, struct cpumask *new_cpus) } =20 /* - * update_isolation_cpumasks - Update external isolation related CPU masks + * update_hk_sched_domains - Update HK cpumasks & rebuild sched domains * - * The following external CPU masks will be updated if necessary: - * - workqueue unbound cpumask + * Update housekeeping cpumasks and rebuild sched domains if necessary. + * This should be called at the end of cpuset or hotplug actions. */ -static void update_isolation_cpumasks(void) +static void update_hk_sched_domains(void) { - int ret; - - if (!isolated_cpus_updating) - return; - - ret =3D housekeeping_update(isolated_cpus); - WARN_ON_ONCE(ret < 0); - - isolated_cpus_updating =3D false; + if (update_housekeeping) { + /* Updating HK cpumasks implies rebuild sched domains */ + WARN_ON_ONCE(housekeeping_update(isolated_cpus)); + update_housekeeping =3D false; + force_sd_rebuild =3D true; + } + /* force_sd_rebuild will be cleared in rebuild_sched_domains_locked() */ + if (force_sd_rebuild) + rebuild_sched_domains_locked(); } =20 /** @@ -1472,7 +1471,6 @@ static int remote_partition_enable(struct cpuset *cs,= int new_prs, cs->remote_partition =3D true; cpumask_copy(cs->effective_xcpus, tmp->new_cpus); spin_unlock_irq(&callback_lock); - update_isolation_cpumasks(); cpuset_force_rebuild(); cs->prs_err =3D 0; =20 @@ -1517,7 +1515,6 @@ static void remote_partition_disable(struct cpuset *c= s, struct tmpmasks *tmp) compute_excpus(cs, cs->effective_xcpus); reset_partition_data(cs); spin_unlock_irq(&callback_lock); - update_isolation_cpumasks(); cpuset_force_rebuild(); =20 /* @@ -1588,7 +1585,6 @@ static void remote_cpus_update(struct cpuset *cs, str= uct cpumask *xcpus, if (xcpus) cpumask_copy(cs->exclusive_cpus, xcpus); spin_unlock_irq(&callback_lock); - update_isolation_cpumasks(); if (adding || deleting) cpuset_force_rebuild(); =20 @@ -1932,7 +1928,6 @@ static int update_parent_effective_cpumask(struct cpu= set *cs, int cmd, partition_xcpus_add(new_prs, parent, tmp->delmask); =20 spin_unlock_irq(&callback_lock); - update_isolation_cpumasks(); =20 if ((old_prs !=3D new_prs) && (cmd =3D=3D partcmd_update)) update_partition_exclusive_flag(cs, new_prs); @@ -2900,7 +2895,6 @@ static int update_prstate(struct cpuset *cs, int new_= prs) else if (isolcpus_updated) isolated_cpus_update(old_prs, new_prs, cs->effective_xcpus); spin_unlock_irq(&callback_lock); - update_isolation_cpumasks(); =20 /* Force update if switching back to member & update effective_xcpus */ update_cpumasks_hier(cs, &tmpmask, !new_prs); @@ -3190,9 +3184,8 @@ ssize_t cpuset_write_resmask(struct kernfs_open_file = *of, } =20 free_cpuset(trialcs); - if (force_sd_rebuild) - rebuild_sched_domains_locked(); out_unlock: + update_hk_sched_domains(); cpuset_full_unlock(); if (of_cft(of)->private =3D=3D FILE_MEMLIST) schedule_flush_migrate_mm(); @@ -3300,6 +3293,7 @@ static ssize_t cpuset_partition_write(struct kernfs_o= pen_file *of, char *buf, cpuset_full_lock(); if (is_cpuset_online(cs)) retval =3D update_prstate(cs, val); + update_hk_sched_domains(); cpuset_full_unlock(); return retval ?: nbytes; } @@ -3474,6 +3468,7 @@ static void cpuset_css_killed(struct cgroup_subsys_st= ate *css) /* Reset valid partition back to member */ if (is_partition_valid(cs)) update_prstate(cs, PRS_MEMBER); + update_hk_sched_domains(); cpuset_full_unlock(); } =20 @@ -3881,10 +3876,12 @@ static void cpuset_handle_hotplug(void) rcu_read_unlock(); } =20 - /* rebuild sched domains if necessary */ - if (force_sd_rebuild) - rebuild_sched_domains_cpuslocked(); =20 + if (update_housekeeping || force_sd_rebuild) { + mutex_lock(&cpuset_mutex); + update_hk_sched_domains(); + mutex_unlock(&cpuset_mutex); + } free_tmpmasks(ptmp); } =20 --=20 2.53.0