From nobody Sun Apr 12 21:01:32 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 2A13838B7D6 for ; Wed, 1 Apr 2026 21:46:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775080028; cv=none; b=FCrxQxjITff14wI2HRGL3hVrAWYPDmPyDOgMruYC3l9fH53x0nE5/J+/taVx5vIR5kM9RevQs17dQ7Zh7k+NW5o92MVg0r36xCR4sWVWmH3VlGEj7b+AFKev6dxDEcbseA5ttBvYAIIJ4GwKmSSxtMuEoJmZ5Rne/iOjHk3Ob8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775080028; c=relaxed/simple; bh=O1yyrwE/gDmv3daYfha9ZbKLXioa40c9usZVKdRKX1o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Tve5xXU/XF/8yJbi5LG7Z73CRtqvCbwZq8HPwkUkd+O7nKp1tUEgePujX3Rx3zMh3gx2pRG9BiGSQUJmNH9X3VQRr2W9wjjUonUbvR/pYJWcI24qM5bor/KhoQpr38C70/C9D3vU+OAplUcE1w75vDhOi5n887bcFabb8z0lJS0= 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=jdyKjZxh; arc=none smtp.client-ip=198.175.65.15 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="jdyKjZxh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775080018; x=1806616018; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=O1yyrwE/gDmv3daYfha9ZbKLXioa40c9usZVKdRKX1o=; b=jdyKjZxhVJBEPrD0vre27yGeDIwO70QfPmjSlaVHm5CndsD4rc4odgXk s3Yu2FN/xvd630TaP/u77v8x5JIcQl/uKLCH++CXTFfNaD5fIUHi+JJtx oqg9os3ZlFSzhXIoU1dN8qnlzm7uMv08KqlxcR7lLWm5AE0zyLlDfMr48 PSrzogzUZbDGmupbtzu3oZ/bc1cSqlam0yWPNoUy1LUgm4RxWKbw7p5nJ Nb3erOPRXYB/+lgbf0FBgP6scDt2djMDPVQMboF58BzbTIZpqAc+a1qq5 c7WPVG0VisHA5/H6BCnCAIAw8Q/nLVZqB7ER+Bn1OSmRF8jZKHBGQxx4w w==; X-CSE-ConnectionGUID: 0K5s0X1DQcykxtBMDqOPdA== X-CSE-MsgGUID: Q/Y3V3KfSriZ+8OjvzuzjA== X-IronPort-AV: E=McAfee;i="6800,10657,11746"; a="79739902" X-IronPort-AV: E=Sophos;i="6.23,153,1770624000"; d="scan'208";a="79739902" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2026 14:46:58 -0700 X-CSE-ConnectionGUID: +QmcXZedQiGXWCMxnDt44w== X-CSE-MsgGUID: MLnmTaDLREWSuRboWDqGfA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,153,1770624000"; d="scan'208";a="249842442" Received: from b04f130c83f2.jf.intel.com ([10.165.154.98]) by fmviesa002.fm.intel.com with ESMTP; 01 Apr 2026 14:46:57 -0700 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 v4 10/22] sched/cache: Count tasks prefering destination LLC in a sched group Date: Wed, 1 Apr 2026 14:52:22 -0700 Message-Id: <3d8502a33a753c4384b368f97f64ee70b1cea0db.1775065312.git.tim.c.chen@linux.intel.com> 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: v3->v4: Use rcu_dereference_all() for protection(Peter Zijlstra) Move the declaration of dst_llc variable under sched_cache_enabled(= ), and remove the corresponding ifdeffery(Peter Zijlstra) kernel/sched/fair.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e6474e61f4aa..62a628a1594c 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -10681,6 +10681,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 /* @@ -11170,6 +11173,21 @@ 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()) { + struct sched_domain *sd_tmp; + int dst_llc; + + dst_llc =3D llc_id(env->dst_cpu); + if (llc_id(i) !=3D dst_llc) { + sd_tmp =3D rcu_dereference_all(rq->sd); + if (valid_llc_buf(sd_tmp, dst_llc)) + sgs->nr_pref_dst_llc +=3D + sd_tmp->llc_counts[dst_llc]; + } + } +#endif + /* * No need to call idle_cpu() if nr_running is not 0 */ --=20 2.32.0