From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 77AF11F0E34 for ; Tue, 17 Feb 2026 19:02:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771354929; cv=none; b=aAIS5F9aNYWYctq/U4JXnpW+uRRghMxRyAgRJ1AZ1FzimELDPcu9/uXN/m/o9dhWaPsCTn39WqD6bPv+mpo6eVsAjpH19eMXAgSLzRuKEv3Ph85G2n2n11PjTnKMhijcmrqV4c9JDjx/wKyQp6hVY7btPC2uFeHQliHy7znj2ac= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771354929; c=relaxed/simple; bh=5P8OtOn8FIefCnUokRxcZ7C7WjLkepUWPyrCsz9efSo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Ty6hhU7V1PudtyPcex4rglrgn6trbqslqHXyEj+efuDE3bdyk234Nr+6opUy6qxVvWRy8rA1qIbdDvNcTd57uoYqo2ygt23AbxfIfrHtROGUGIpn0xwMxGFImvySdebqhjq773mrsK2a++obwKDS40+TcCyPXNOXiylvSlbxgiM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Q+T5PRkE; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Q+T5PRkE" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 61HI7Opl3664605; Tue, 17 Feb 2026 19:01:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=HBgCX+ tXrsl8ezkyMELSHbB4HBjbMomNktLFY3xO8TI=; b=Q+T5PRkE5P2CpBTphaYoSG 2UzcpMj1AsJuHi1CsekLtIghUiJMOZmWFFbf+EHSmM16l0JcfUM45UNVHnnUPiv4 alVALEjeL9JC8Z7ml/vWzCqIy9ueaShB7beyh07rL6WxTbyLVai15BjNZuXUUvsS HXVendONicoVrHGxJDmye8Tk6AvGQoV3RtYP/oEIvLiuGSCBiOZXQF3Cqkd+fJap OIsZ5zblSx9bp2WRDio68/8apFGwvVWl3SKipaW5VNG/zKxby/AvtKTYdFmE4CyX Rbm44Hgz5yzNc8+hxQo0XmaddhW4V+QExnojup4ZaYIIm42lcxzHJm0Gv7debH2g == Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4cajcjcyek-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Feb 2026 19:01:17 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 61HG1Voj023899; Tue, 17 Feb 2026 19:01:16 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ccb454d1p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Feb 2026 19:01:16 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 61HJ1E3J33555140 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Feb 2026 19:01:15 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A7EDD58043; Tue, 17 Feb 2026 19:01:14 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B999858055; Tue, 17 Feb 2026 19:00:59 +0000 (GMT) Received: from [9.67.177.101] (unknown [9.67.177.101]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 17 Feb 2026 19:00:59 +0000 (GMT) Message-ID: <6797dfae-5ff6-4035-a0d0-ca8eeccbed05@linux.ibm.com> Date: Wed, 18 Feb 2026 00:30:57 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 13/21] sched/cache: Handle moving single tasks to/from their preferred LLC To: Tim Chen Cc: Peter Zijlstra , Ingo Molnar , K Prateek Nayak , "Gautham R . Shenoy" , Vincent Guittot , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , 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, Madadi Vineeth Reddy References: <92fa33fc26f069d8044bac3b0efc3598f53131de.1770760558.git.tim.c.chen@linux.intel.com> Content-Language: en-US From: Madadi Vineeth Reddy In-Reply-To: <92fa33fc26f069d8044bac3b0efc3598f53131de.1770760558.git.tim.c.chen@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-ORIG-GUID: ncNq8g6ZVt_7zxs072DGo8HwNlqBlfby X-Authority-Analysis: v=2.4 cv=Md9hep/f c=1 sm=1 tr=0 ts=6994bafe cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=IkcTkHD0fZMA:10 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22 a=QyXUC8HyAAAA:8 a=jnc0TIth_L5JUr4ND9oA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjE3MDE1MiBTYWx0ZWRfXwArX2SrRSQ4O PvL4BZ9NMNFbgM1VGlDaoP2pOGpugP+0eiHxceCRYitPMEJ7tBkFgUrxBu7fwffcOtd3oBr2Ns3 P69w2jjTLrphgkDZat5U3qUx5GI9AJUQYsQO/WpcAQDmMqsu5VDC0ddyHeqbmJ/QmSiNeKKHhFD i6/JSWdZ9pBYe548CiE8hYWcE/Gbiw4fgFes7xk9a4hG3YEsAooaIRloJia0GMQuBWF+Il0OWGo Ekm1IsdL80Y21ekdJCpk7cHZzhDz2rBABYBORsFaO0YtBYlC5/IyUFSg31Z40NA0baXi8INfgwC 9HSkY6NZqHZimjxPgRkTSJ0+CN88IgIvgNIVZ0SBa7soNjUhTgp7uLVV/myjpVcAwjuLmjJY53R 1mjjmx09wqetVdqfwLxyAk6hxcb4jeVhLkCUkf1qU3+LREC09+64lEdAjfaZPs1B6lozlTw9vZq 6yIOMXMpc3VqoOhfIyw== X-Proofpoint-GUID: 29nrxKsxT-KsRa2y0VjtjCy4lX-lDXfD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-17_03,2026-02-16_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 spamscore=0 adultscore=0 priorityscore=1501 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602170152 On 11/02/26 03:48, Tim Chen wrote: > In the generic load balance(non-cache-aware-load-balance), > if the busiest runqueue has only one task, active balancing may be > invoked to move it. However, this migration might break LLC locality. > > Before migration, check whether the task is running on its preferred > LLC: Do not move a lone task to another LLC if it would move the task > away from its preferred LLC or cause excessive imbalance between LLCs. > > On the other hand, if the migration type is migrate_llc_task, it means > that there are tasks on the env->src_cpu that want to be migrated to > their preferred LLC, launch the active load balance anyway. Nit: But the check of migrate_llc_task is made after checking alb_break_llc which seems to be contradicting. I understand that this check env->src_rq->nr_pref_llc_running == env->src_rq->cfs.h_nr_runnable prevents alb_break_llc to return true when migrate_llc_task exists. However, checking migrate_llc_task first would make the priority and intent more explicit. Thanks, Vineeth > > Co-developed-by: Chen Yu > Signed-off-by: Chen Yu > Signed-off-by: Tim Chen > --- > > Notes: > v2->v3: > Remove redundant rcu read lock in break_llc_locality(). > > kernel/sched/fair.c | 54 ++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 53 insertions(+), 1 deletion(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 1697791ef11c..03959a701514 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -9999,12 +9999,60 @@ static __maybe_unused enum llc_mig can_migrate_llc_task(int src_cpu, int dst_cpu > task_util(p), to_pref); > } > > +/* > + * Check if active load balance breaks LLC locality in > + * terms of cache aware load balance. > + */ > +static inline bool > +alb_break_llc(struct lb_env *env) > +{ > + if (!sched_cache_enabled()) > + return false; > + > + if (cpus_share_cache(env->src_cpu, env->dst_cpu)) > + return false; > + /* > + * All tasks prefer to stay on their current CPU. > + * Do not pull a task from its preferred CPU if: > + * 1. It is the only task running there; OR > + * 2. Migrating it away from its preferred LLC would violate > + * the cache-aware scheduling policy. > + */ > + if (env->src_rq->nr_pref_llc_running && > + env->src_rq->nr_pref_llc_running == env->src_rq->cfs.h_nr_runnable) { > + unsigned long util = 0; > + struct task_struct *cur; > + > + if (env->src_rq->nr_running <= 1) > + return true; > + > + /* > + * Reach here in load balance with > + * rcu_read_lock() protected. > + */ > + cur = rcu_dereference(env->src_rq->curr); > + if (cur) > + util = task_util(cur); > + > + if (can_migrate_llc(env->src_cpu, env->dst_cpu, > + util, false) == mig_forbid) > + return true; > + } > + > + return false; > +} > #else > static inline bool get_llc_stats(int cpu, unsigned long *util, > unsigned long *cap) > { > return false; > } > + > +static inline bool > +alb_break_llc(struct lb_env *env) > +{ > + return false; > +} > #endif > /* > * can_migrate_task - may task p from runqueue rq be migrated to this_cpu? > @@ -12421,6 +12469,9 @@ static int need_active_balance(struct lb_env *env) > { > struct sched_domain *sd = env->sd; > > + if (alb_break_llc(env)) > + return 0; > + > if (asym_active_balance(env)) > return 1; > > @@ -12440,7 +12491,8 @@ static int need_active_balance(struct lb_env *env) > return 1; > } > > - if (env->migration_type == migrate_misfit) > + if (env->migration_type == migrate_misfit || > + env->migration_type == migrate_llc_task) > return 1; > > return 0;