From nobody Sun Feb 8 22:58:27 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 2336230EF81 for ; Fri, 6 Feb 2026 20:37:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770410279; cv=none; b=PfY82meNZojLoxetol69y7Pj0rJn5nun70stMBgzBIH6qw2CViUTrumDBKjdDEFHpCIRJoU05oxcJn0P10mOcQ3+Y0AS0B8tgyz+4HSLZcXKklAq5jegXlPmUwb5ccTvFGlx4VcnPQbTl9hJI+mjnCw6HVIxNj0GCUDHoL7L0Mk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770410279; c=relaxed/simple; bh=71S3ObAXFhgNJHPY1eqOrJoW7VXUnIJajfUjoJSe1yk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lDRflaOwXYe+38Wckjq7jr66rFNyQfLPvj43z6DQoA4kIl5ub47TwFgjkpSIHxNtOALDRa3jE6j/42vdgikzOS7AlAxK7/qcPPTk9nqU5wJ4U3+Dp4vcLVsBdyVC9/ODq/QZ7J7EnzS6wxy9xgzHTN2+rVpgBgUNzvMi68Bur5Q= 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=B7KEynFb; arc=none smtp.client-ip=170.10.129.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="B7KEynFb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770410278; 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=MUME4hn48Lh+CEIYg2UpLJDShYrbNFkvPeAL4+NsAw8=; b=B7KEynFb/TwlnU8ICrct12JGGKXwUMNhEjrR9VybAX/lXcdc3j2lC12lgrRFmh4bhFukik ThQ8uFXnZMNalkS3FNgwypRZJVZBptM7qxiiZ3fq4gZzlfd6bRzG329Z2avQ97/ISu47iH 4E62Ew8e2KtNlv0f9a7sReW6ZkPsUgw= Received: from mx-prod-mc-03.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-589-RRQ9N5k2ONeO8GLTUDYibA-1; Fri, 06 Feb 2026 15:37:55 -0500 X-MC-Unique: RRQ9N5k2ONeO8GLTUDYibA-1 X-Mimecast-MFC-AGG-ID: RRQ9N5k2ONeO8GLTUDYibA_1770410273 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 95AE91955F0E; Fri, 6 Feb 2026 20:37:52 +0000 (UTC) Received: from llong-thinkpadp16vgen1.westford.csb (unknown [10.22.90.86]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EED8518003F6; Fri, 6 Feb 2026 20:37:48 +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 , Anna-Maria Behnsen , 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/for-next v4 4/4] cgroup/cpuset: Eliminate some duplicated rebuild_sched_domains() calls Date: Fri, 6 Feb 2026 15:37:12 -0500 Message-ID: <20260206203712.1989610-5-longman@redhat.com> In-Reply-To: <20260206203712.1989610-1-longman@redhat.com> References: <20260206203712.1989610-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.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Now that we are going to defer any changes to the HK_TYPE_DOMAIN housekeeping cpumasks to either task_work or workqueue where rebuild_sched_domains() call will be issued. The current rebuild_sched_domains_locked() call near the end of the cpuset critical section can be removed in such cases. Currently, a boolean force_sd_rebuild flag is used to decide if rebuild_sched_domains_locked() call needs to be invoked. To allow deferral that like, we change it to a tri-state sd_rebuild enumaration type. Signed-off-by: Waiman Long --- kernel/cgroup/cpuset.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index d26c77a726b2..e224df321e34 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -173,7 +173,11 @@ static bool isolcpus_twork_queued; /* T */ * Note that update_relax_domain_level() in cpuset-v1.c can still call * rebuild_sched_domains_locked() directly without using this flag. */ -static bool force_sd_rebuild; /* RWCS */ +static enum { + SD_NO_REBUILD =3D 0, + SD_REBUILD, + SD_DEFER_REBUILD, +} sd_rebuild; /* RWCS */ =20 /* * Partition root states: @@ -990,7 +994,7 @@ void rebuild_sched_domains_locked(void) =20 lockdep_assert_cpus_held(); lockdep_assert_cpuset_lock_held(); - force_sd_rebuild =3D false; + sd_rebuild =3D SD_NO_REBUILD; =20 /* Generate domain masks and attrs */ ndoms =3D generate_sched_domains(&doms, &attr); @@ -1377,6 +1381,9 @@ static void update_isolation_cpumasks(void) else isolated_cpus_updating =3D false; =20 + /* Defer rebuild_sched_domains() to task_work or wq */ + sd_rebuild =3D SD_DEFER_REBUILD; + /* * This function can be reached either directly from regular cpuset * control file write or via CPU hotplug. In the latter case, it is @@ -3011,7 +3018,7 @@ static int update_prstate(struct cpuset *cs, int new_= prs) update_partition_sd_lb(cs, old_prs); =20 notify_partition_change(cs, old_prs); - if (force_sd_rebuild) + if (sd_rebuild =3D=3D SD_REBUILD) rebuild_sched_domains_locked(); free_tmpmasks(&tmpmask); return 0; @@ -3288,7 +3295,7 @@ ssize_t cpuset_write_resmask(struct kernfs_open_file = *of, } =20 free_cpuset(trialcs); - if (force_sd_rebuild) + if (sd_rebuild =3D=3D SD_REBUILD) rebuild_sched_domains_locked(); out_unlock: cpuset_full_unlock(); @@ -3771,7 +3778,8 @@ hotplug_update_tasks(struct cpuset *cs, =20 void cpuset_force_rebuild(void) { - force_sd_rebuild =3D true; + if (!sd_rebuild) + sd_rebuild =3D SD_REBUILD; } =20 /** @@ -3981,7 +3989,7 @@ static void cpuset_handle_hotplug(void) } =20 /* rebuild sched domains if necessary */ - if (force_sd_rebuild) + if (sd_rebuild =3D=3D SD_REBUILD) rebuild_sched_domains_cpuslocked(); =20 free_tmpmasks(ptmp); --=20 2.52.0