From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 3397E21ABBB for ; Wed, 10 Dec 2025 19:00:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765393257; cv=none; b=p3BK9NjJ2ivvatK8rV00RcH5cJ5uPgnlH/JzWz48mMkIyXfO2bPD3T5Y2thtTesMoPj37M1qB7HZvEhDlKPDFVmfb0NfeofZoBKRENJ/Ch8afAFKLN6lnRhVcM7neWOyIkyw3k5EdvTpcjBuBLLcrXeFDQY8JMIs9tiL2VSFqLw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765393257; c=relaxed/simple; bh=jzskzpmyBdWO2IWOv/UimmwZ/dFw0LY4SuxAQeV1Krk=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=bRsxIlmXvJK+0J6z4wwwmS1+XEI+A0sycdA0nCYVDGzc5+yMHdi5eV4GeeTGA1+oaDCHBq5Iy6vbk+9l03rtuKj648gBA5ayIv28VgJoV28OQ9mrucwHK2CrGzvrr0K5bvFMHlDenoaK+4aStXZF/9u8fTaFU26iFmWaLpLjjbQ= 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=jR8wYcWj; arc=none smtp.client-ip=192.198.163.13 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="jR8wYcWj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1765393255; x=1796929255; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=jzskzpmyBdWO2IWOv/UimmwZ/dFw0LY4SuxAQeV1Krk=; b=jR8wYcWjhDe/e3iRKAcjkQ+Rbpsppavm9oV9MZ/Q/YAf8AF6+PMiPFUy DuqbtT+LdwUFVizOQpi57ElIEXp5yYnGVhF6dZdp3C9QNKktJgecqD0ky 8vknCcYRrYI4OOs8gQNOFs7lF73jZiJuuxN8lpx2zY9EPVtOKsVnc9Tyj nZdYkS8TSyDKHDcbzMYDUP3zYfeDyJmfyv4GSp/oI/gFNFfj1g694atB8 GN3BFkKCmvGZNSdsBArxoSxJZhR9tgbV9lO+x5SBoqArhaamGE4uFU+5u gh3It43/aaTISXQ1jBJ5PGBvUbZ3QD02NaO6tuG1AD4F3Q731LXb6LLCW A==; X-CSE-ConnectionGUID: Zi9zb/jmR2aitdyMSwM/IA== X-CSE-MsgGUID: EAzUBKrhTguQb08S3NK2xA== X-IronPort-AV: E=McAfee;i="6800,10657,11638"; a="69958087" X-IronPort-AV: E=Sophos;i="6.20,264,1758610800"; d="scan'208";a="69958087" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2025 11:00:54 -0800 X-CSE-ConnectionGUID: AzV9prJjRkeuCPAvuyEuWg== X-CSE-MsgGUID: OyIJ8BsOQJ+mxC7qbha9Uw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,264,1758610800"; d="scan'208";a="201513243" Received: from unknown (HELO [10.241.243.18]) ([10.241.243.18]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2025 11:00:54 -0800 Message-ID: Subject: Re: [PATCH v2 09/23] sched/cache: Count tasks prefering destination LLC in a sched group From: Tim Chen To: Peter Zijlstra , "Chen, Yu C" Cc: Ingo Molnar , K Prateek Nayak , "Gautham R . Shenoy" , Vincent Guittot , 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 , Adam Li , Aaron Lu , Tim Chen , linux-kernel@vger.kernel.org Date: Wed, 10 Dec 2025 11:00:53 -0800 In-Reply-To: <20251210151621.GM3707837@noisy.programming.kicks-ass.net> References: <1eb6a231ec82b37483208983f0cf10eec823ec9d.1764801860.git.tim.c.chen@linux.intel.com> <20251210125233.GT3707891@noisy.programming.kicks-ass.net> <5613f6eb-7319-464e-9723-2d82ddaca0c9@intel.com> <20251210151621.GM3707837@noisy.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.1 (3.58.1-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Wed, 2025-12-10 at 16:16 +0100, Peter Zijlstra wrote: > On Wed, Dec 10, 2025 at 11:05:33PM +0900, Chen, Yu C wrote: > > On 12/10/2025 9:52 PM, Peter Zijlstra wrote: > > > On Wed, Dec 03, 2025 at 03:07:28PM -0800, Tim Chen wrote: > > > > During LLC load balancing, tabulate the number of tasks on each run= queue > > > > that prefer the LLC contains the env->dst_cpu in a sched group. > > > >=20 > > > > For example, consider a system with 4 LLC sched groups (LLC0 to LLC= 3) > > > > 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. > > > >=20 > > > > Within a source LLC, the total number of tasks preferring a destina= tion > > > > 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 prefer= ring > > > > LLC3, the total for LLC0 is 3. > > > >=20 > > > > These statistics allow the load balancer to choose tasks from sourc= e > > > > sched groups that best match their preferred LLCs. > > > >=20 > > > > Signed-off-by: Tim Chen > > > > --- > > > >=20 > > > > Notes: > > > > v1->v2: > > > > Convert nr_pref_llc array in sg_lb_stats to a single > > > > variable as only the dst LLC stat is needed. > > > > (K Prateek Nayak) > > > >=20 > > > > kernel/sched/fair.c | 12 ++++++++++++ > > > > 1 file changed, 12 insertions(+) > > > >=20 > > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > > > index b0e87616e377..4d7803f69a74 100644 > > > > --- a/kernel/sched/fair.c > > > > +++ b/kernel/sched/fair.c > > > > @@ -10445,6 +10445,9 @@ struct sg_lb_stats { > > > > unsigned int nr_numa_running; > > > > unsigned int nr_preferred_running; > > > > #endif > > > > +#ifdef CONFIG_SCHED_CACHE > > > > + unsigned int nr_pref_llc; > > > > +#endif > > >=20 > > > At this point I have to note that rq->nr_pref_llc seems like a horrib= le > > > misnomer, for it being an array, and not an actual number like the > > > naming suggests. > >=20 > > In the v2 it seems that rq->nr_pref_llc is not an array anymore, it >=20 > From two patches ago: >=20 > + unsigned int *nr_pref_llc; >=20 > Its a pointer of some sort. Perhaps I should used a different name here when I update this patch for v2. =20 rq->nr_pref_llc[] is an array as it records the number of tasks preferrin= g each LLC. However sgs->nr_pref_llc is a single number representing the number of tasks preferring the current domain preferring the destination LLC. Sorry for using the same name that may have created this confusion. >=20 >=20 > > indicates > > the number of tasks that want to be migrated to the env->dst_cpu (dst_l= lc), > > because > > these tasks' preferred LLC are env->dst_cpu(dst_llc). Maybe renaming it= to > > rq->nr_pref_dst_llc? >=20 > Like I said in: >=20 > https://lkml.kernel.org/r/20251210125114.GS3707891@noisy.programming.ki= cks-ass.net >=20 > it might make sense to put it in struct sched_domain instead of struct > rq, since then you can allocate and swap it right along with the rest of > the domain tree. Sent a separate reply to that comment to clarify why I think we need nr_pre= f_llc[] per run queue. Tim