From nobody Thu Apr 2 17:01:53 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 BF2D933BBB1 for ; Tue, 10 Feb 2026 22:13:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770761603; cv=none; b=C0Ig+W7IzWDti+3rGYjUc5KFVRVrX0TVzG1Et+RvTagFt9rdWHyp5Rho3dE2QKZ7AWsyq/WM98+xeQsRH5ygoP67txnLVPdf0kDjXY0duIbKvjCekXMyNt0rGJH1JzU3wdxkXA6PHtA5iGjYDgVlXS2pwH3szNk1/dPhm58A3xg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770761603; c=relaxed/simple; bh=h8EaW97unXwqr3Zm62BEQ6Jz9Y52LZhXe+5mCa90Ga8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LuIQz21nYGQHPO7uJJAJ45nDLRPcNqNwvC1lOh9uO4/EaPlpgngiYOeQBvbYznP4Y2BiJuLt+k6P+w9sDp9KZCpjwOAm1P7MYkBCyOXf8zWmI3fuSd9kK77JVRXKLDgJlAZD7PIOx3kGUgV0jdCSvToWVL/Xbti0fwUMv1DyMsM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=glOugbil; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="glOugbil" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770761602; x=1802297602; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=h8EaW97unXwqr3Zm62BEQ6Jz9Y52LZhXe+5mCa90Ga8=; b=glOugbilH1PQc8KdYJ8uRolEJhViBrL219XjjE01mq5Bm1iQs2ALFYnj j2p7RiR+dHP0qYSuRjFDLzkVWKkRsKelbhUeaLakkcyl1KztbPq+R3Htz 8E1ykcIxoF1KmfeHSBl6lA9Mj1w9fW/im8FZnpoi5L+bNW1YwClcZIrEE osQpSLqiupOlUgqCLwsZ2B5T4+RA0m3oaK3yXEjKNACRmXV5Qy6nTNJen p0mjh87isA7bG4Jd3yhcz92seI1hcl8glAvhyuXr93vzqoe63zpYXo/aa U5jGEWELL0+VFO3uw/xMAHDKCFZZRWnbMqFTBGsewNWA8W6VMqG5esKja g==; X-CSE-ConnectionGUID: i/3QiOSmRxqJcSyzjv1o7g== X-CSE-MsgGUID: 45sp/AO6RrmCtAmJ825RKg== X-IronPort-AV: E=McAfee;i="6800,10657,11697"; a="82631400" X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="82631400" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 14:13:22 -0800 X-CSE-ConnectionGUID: QuYWffTFSP6QPG/1OcbvPg== X-CSE-MsgGUID: aunmfRrgTDmCm3s+6M9UjQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="216373944" Received: from b04f130c83f2.jf.intel.com ([10.165.154.98]) by fmviesa004.fm.intel.com with ESMTP; 10 Feb 2026 14:13:20 -0800 From: Tim Chen To: Peter Zijlstra , Ingo Molnar , K Prateek Nayak , "Gautham R . Shenoy" , Vincent Guittot Cc: Tim Chen , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Madadi Vineeth Reddy , Hillf Danton , Shrikanth Hegde , Jianyong Wu , Yangyu Chen , Tingyin Duan , Vern Hao , Vern Hao , Len Brown , Aubrey Li , Zhao Liu , Chen Yu , Chen Yu , Adam Li , Aaron Lu , Tim Chen , Josh Don , Gavin Guo , Qais Yousef , Libo Chen , linux-kernel@vger.kernel.org Subject: [PATCH v3 09/21] sched/cache: Count tasks prefering destination LLC in a sched group Date: Tue, 10 Feb 2026 14:18:49 -0800 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: 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 Content-Type: text/plain; charset="utf-8" During LLC load balancing, tabulate the number of tasks on each runqueue that prefer the LLC contains the env->dst_cpu in a sched group. For example, consider a system with 4 LLC sched groups (LLC0 to LLC3) balancing towards LLC3. LLC0 has 3 tasks preferring LLC3, LLC1 has 2, and LLC2 has 1. LLC0, having the most tasks preferring LLC3, is selected as the busiest source to pick tasks from. Within a source LLC, the total number of tasks preferring a destination LLC is computed by summing counts across all CPUs in that LLC. For instance, if LLC0 has CPU0 with 2 tasks and CPU1 with 1 task preferring LLC3, the total for LLC0 is 3. These statistics allow the load balancer to choose tasks from source sched groups that best match their preferred LLCs. Co-developed-by: Chen Yu Signed-off-by: Chen Yu Signed-off-by: Tim Chen --- Notes: v2->v3: Rename nr_pref_llc to nr_pref_dst_llc for clarification. kernel/sched/fair.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 4a98aa866d65..bb93cc046d73 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -10566,6 +10566,9 @@ struct sg_lb_stats { unsigned int nr_numa_running; unsigned int nr_preferred_running; #endif +#ifdef CONFIG_SCHED_CACHE + unsigned int nr_pref_dst_llc; +#endif }; =20 /* @@ -11034,6 +11037,9 @@ static inline void update_sg_lb_stats(struct lb_env= *env, { int i, nr_running, local_group, sd_flags =3D env->sd->flags; bool balancing_at_rd =3D !env->sd->parent; +#ifdef CONFIG_SCHED_CACHE + int dst_llc =3D llc_id(env->dst_cpu); +#endif =20 memset(sgs, 0, sizeof(*sgs)); =20 @@ -11054,6 +11060,15 @@ static inline void update_sg_lb_stats(struct lb_en= v *env, if (cpu_overutilized(i)) *sg_overutilized =3D 1; =20 +#ifdef CONFIG_SCHED_CACHE + if (sched_cache_enabled() && llc_id(i) !=3D dst_llc) { + struct sched_domain *sd_tmp =3D rcu_dereference(rq->sd); + + if (valid_llc_buf(sd_tmp, dst_llc)) + sgs->nr_pref_dst_llc +=3D sd_tmp->pf[dst_llc]; + } +#endif + /* * No need to call idle_cpu() if nr_running is not 0 */ --=20 2.32.0