From nobody Mon Apr 6 10:45:05 2026 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 A655930EF84 for ; Fri, 20 Mar 2026 06:20:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773987625; cv=none; b=BK7WTRdNX1KzL0NMhzdvt3U3tMU8bNAvv28IDn4P48UzWpVKckFCG05qTjX+HdzN4zPhIqiqgqPHWo9w0WEMsW9AzykK4DjjClOi6zwxguEbzE979VY5nxPXs3s9/Ddtv7zWO3xlIOxXB99z0wf+HJ9kmfiepbStfblCalvtPPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773987625; c=relaxed/simple; bh=BH+34rIPuqcGgkeZKYsf4qYdGBuZa3T7EyMVzBtqm1A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=afK+ewB0r+Nc44coZR6Wjm5gzAAOkq23GXYKCz4zFtcKwIvoCMXMNQF4SDIi/uRQfr/WEhtNCp8AMhWbbks6ezTM20+/GXZgu/0Bc1R8qIEre581PzGFa51tssKZL0GQuM0bZWoW5sn34NM6M8EeyHxKqYzqNM9o8p5nCPfHDBI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=Yu5k3MaY; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=Yu5k3MaY; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="Yu5k3MaY"; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="Yu5k3MaY" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=WuLQczoA8ClYDlFZEuQEW6s57B8Rs8eJ8ySS9FCTbi8=; b=Yu5k3MaYhSxEtoiQBf4GRUnfBoqV1rDtL5eAfIqOrmrSwVMZM/MKHWD3NhLz940JIU3m77bf1 oMfjjB8+fRlcl/1V0Mi5/4bT2mEWtiJV9J+i8HYUJABmJnJ/0B903JEVOEgZpvppugDqV+LiOVI LYNpoFKYLQ2KaKdMQyla1sw= Received: from canpmsgout03.his.huawei.com (unknown [172.19.92.159]) by szxga01-in.huawei.com (SkyGuard) with ESMTPS id 4fcXTL5ltNz1BG2x for ; Fri, 20 Mar 2026 14:19:18 +0800 (CST) dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=WuLQczoA8ClYDlFZEuQEW6s57B8Rs8eJ8ySS9FCTbi8=; b=Yu5k3MaYhSxEtoiQBf4GRUnfBoqV1rDtL5eAfIqOrmrSwVMZM/MKHWD3NhLz940JIU3m77bf1 oMfjjB8+fRlcl/1V0Mi5/4bT2mEWtiJV9J+i8HYUJABmJnJ/0B903JEVOEgZpvppugDqV+LiOVI LYNpoFKYLQ2KaKdMQyla1sw= Received: from mail.maildlp.com (unknown [172.19.162.223]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4fcXN41BJXzpStF; Fri, 20 Mar 2026 14:14:44 +0800 (CST) Received: from kwepemr500016.china.huawei.com (unknown [7.202.195.68]) by mail.maildlp.com (Postfix) with ESMTPS id 1514940561; Fri, 20 Mar 2026 14:20:11 +0800 (CST) Received: from huawei.com (10.67.174.242) by kwepemr500016.china.huawei.com (7.202.195.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 20 Mar 2026 14:20:10 +0800 From: Chen Jinghuang To: , , , , CC: , , , , , , , Subject: [RFC PATCH v5 3/9] sched/topology: Provide cfs_overload_cpus bitmap Date: Fri, 20 Mar 2026 05:59:14 +0000 Message-ID: <20260320055920.2518389-4-chenjinghuang2@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260320055920.2518389-1-chenjinghuang2@huawei.com> References: <20260320055920.2518389-1-chenjinghuang2@huawei.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-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemr500016.china.huawei.com (7.202.195.68) Content-Type: text/plain; charset="utf-8" From: Steve Sistare Define and initialize a sparse bitmap of overloaded CPUs, per last-level-cache scheduling domain, for use by the CFS scheduling class. Save a pointer to cfs_overload_cpus in the rq for efficient access. Signed-off-by: Steve Sistare Signed-off-by: Chen Jinghuang --- include/linux/sched/topology.h | 1 + kernel/sched/sched.h | 2 ++ kernel/sched/topology.c | 25 +++++++++++++++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index 45c0022b91ce..472c3dcf5a34 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -67,6 +67,7 @@ struct sched_domain_shared { atomic_t ref; atomic_t nr_busy_cpus; int has_idle_cores; + struct sparsemask *cfs_overload_cpus; int nr_idle_scan; }; =20 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index b82fb70a9d54..4989a92eeb9b 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -85,6 +85,7 @@ struct cfs_rq; struct rt_rq; struct sched_group; struct cpuidle_state; +struct sparsemask; =20 #if defined(CONFIG_PARAVIRT) && !defined(CONFIG_HAVE_PV_STEAL_CLOCK_GEN) # include @@ -1173,6 +1174,7 @@ struct rq { struct cfs_rq cfs; struct rt_rq rt; struct dl_rq dl; + struct sparsemask *cfs_overload_cpus; #ifdef CONFIG_SCHED_CLASS_EXT struct scx_rq scx; struct sched_dl_entity ext_server; diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index fac1b9155b6e..7bf1f68dac32 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -6,6 +6,7 @@ #include #include #include "sched.h" +#include "sparsemask.h" =20 DEFINE_MUTEX(sched_domains_mutex); void sched_domains_mutex_lock(void) @@ -683,7 +684,9 @@ DEFINE_STATIC_KEY_FALSE(sched_cluster_active); =20 static void update_top_cache_domain(int cpu) { + struct sparsemask *cfs_overload_cpus =3D NULL; struct sched_domain_shared *sds =3D NULL; + struct rq *rq =3D cpu_rq(cpu); struct sched_domain *sd; int id =3D cpu; int size =3D 1; @@ -693,8 +696,10 @@ static void update_top_cache_domain(int cpu) id =3D cpumask_first(sched_domain_span(sd)); size =3D cpumask_weight(sched_domain_span(sd)); sds =3D sd->shared; + cfs_overload_cpus =3D sds->cfs_overload_cpus; } =20 + rcu_assign_pointer(rq->cfs_overload_cpus, cfs_overload_cpus); rcu_assign_pointer(per_cpu(sd_llc, cpu), sd); per_cpu(sd_llc_size, cpu) =3D size; per_cpu(sd_llc_id, cpu) =3D id; @@ -2474,7 +2479,22 @@ static void __sdt_free(const struct cpumask *cpu_map) =20 static int sd_llc_alloc(struct sched_domain *sd) { - /* Allocate sd->shared data here. Empty for now. */ + struct sched_domain_shared *sds =3D sd->shared; + struct cpumask *span =3D sched_domain_span(sd); + int nid =3D cpu_to_node(cpumask_first(span)); + int flags =3D __GFP_ZERO | GFP_KERNEL; + struct sparsemask *mask; + + /* + * Allocate the bitmap if not already allocated. This is called for + * every CPU in the LLC but only allocates once per sd_llc_shared. + */ + if (!sds->cfs_overload_cpus) { + mask =3D sparsemask_alloc_node(nr_cpu_ids, 3, flags, nid); + if (!mask) + return 1; + sds->cfs_overload_cpus =3D mask; + } =20 return 0; } @@ -2486,7 +2506,8 @@ static void sd_llc_free(struct sched_domain *sd) if (!sds) return; =20 - /* Free data here. Empty for now. */ + sparsemask_free(sds->cfs_overload_cpus); + sds->cfs_overload_cpus =3D NULL; } =20 static int sd_llc_alloc_all(const struct cpumask *cpu_map, struct s_data *= d) --=20 2.34.1