From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 D1B852BD11 for ; Tue, 9 Dec 2025 22:34:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765319698; cv=none; b=pSDZGK7TWIGtSiZBgJtvb8M6IMsKPlmxljmPJXF3geqAgV2rStLPCBIuLlH/Nd/f+xT1ddJCmzEryIHu76PVxi/0by3vst/nLCSEOjNTrNbyyeQe+k7fCLzCO0xAbdPOlns6rT4U0RLJVdj3P0GlbwlkFOrarpWetJiTIaSriGY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765319698; c=relaxed/simple; bh=HclQiHqKg0BrbjOTMXszH9bXurh7GWtsE3P99bG6z5o=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=kjZ8uWvqR/J8nYcMCih7GASapk3fNdyXio44845QyurF971uehqPj/e/xFbm9x1iXVPKt1slJdUTXu20LGLtghmEbaugeNj0EsLXvm1ziQhzMNjPxxt0HShvgD2930iRopXxPN6A5lKiJIR/yGNWupWJX4b7+LozM5X9cIvJgq0= 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=DrVBmIUn; arc=none smtp.client-ip=192.198.163.8 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="DrVBmIUn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1765319696; x=1796855696; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=HclQiHqKg0BrbjOTMXszH9bXurh7GWtsE3P99bG6z5o=; b=DrVBmIUn63vRehcLl6OEqVXPkqUdbYQWgsVmMtmaQLXUlE54XZfKU5uu ergpxC1uIPkmgwzL5iXr8m3tqiT+CO9pCtqzliS0pXdoXssEdQLAvB5QQ x36Uv2XguGJqoM4Pb29Xn98bkOxCwa2545JydaRDvZ0iAHe94izJofELW BTZnT5msHiYt3m3HC17mcVTy0HVALqCWpnkP8lMD/86tQjvbAu8EObSJx nVIwmf9Yu+cRVePSWW0tNGhxKngIFrQZRAmn+KTG6AE9fFgGCtxMuqPib GyoxHXbn/zf2AgdMLs+B2+k1NzvJisd2Sk2X4FImjj62dPMmhkFF5lrM1 g==; X-CSE-ConnectionGUID: 54g0VOtTR8OERAvZBYZF3A== X-CSE-MsgGUID: lCkpdkxzRAmZaz2UGl9OPQ== X-IronPort-AV: E=McAfee;i="6800,10657,11637"; a="84893099" X-IronPort-AV: E=Sophos;i="6.20,262,1758610800"; d="scan'208";a="84893099" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2025 14:34:55 -0800 X-CSE-ConnectionGUID: Oq7M/7rmT4+NMcy/kFdRJg== X-CSE-MsgGUID: oV5zv4TYRQSyqI12aG8JAg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,262,1758610800"; d="scan'208";a="195419415" Received: from unknown (HELO [10.241.243.18]) ([10.241.243.18]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2025 14:34:55 -0800 Message-ID: <09181fa5e5f54524ab4ba6d50801b6082ecc220e.camel@linux.intel.com> Subject: Re: [PATCH v2 05/23] sched/cache: Assign preferred LLC ID to processes From: Tim Chen To: Peter Zijlstra 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 , Chen Yu , Adam Li , Aaron Lu , Tim Chen , linux-kernel@vger.kernel.org Date: Tue, 09 Dec 2025 14:34:54 -0800 In-Reply-To: <20251209121103.GM3707891@noisy.programming.kicks-ass.net> References: <20251209121103.GM3707891@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 Tue, 2025-12-09 at 13:11 +0100, Peter Zijlstra wrote: > On Wed, Dec 03, 2025 at 03:07:24PM -0800, Tim Chen wrote: > > With cache-aware scheduling enabled, each task is assigned a > > preferred LLC ID. This allows quick identification of the LLC domain > > where the task prefers to run, similar to numa_preferred_nid in > > NUMA balancing. >=20 > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index 0a3918269906..10cec83f65d5 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -1300,6 +1300,7 @@ void account_mm_sched(struct rq *rq, struct task_= struct *p, s64 delta_exec) > > struct mm_struct *mm =3D p->mm; > > struct mm_sched *pcpu_sched; > > unsigned long epoch; > > + int mm_sched_llc =3D -1; > > =20 > > if (!sched_cache_enabled()) > > return; > > @@ -1330,6 +1331,23 @@ void account_mm_sched(struct rq *rq, struct task= _struct *p, s64 delta_exec) > > if (mm->mm_sched_cpu !=3D -1) > > mm->mm_sched_cpu =3D -1; > > } > > + > > + if (mm->mm_sched_cpu !=3D -1) { > > + mm_sched_llc =3D llc_id(mm->mm_sched_cpu); > > + > > +#ifdef CONFIG_NUMA_BALANCING > > + /* > > + * Don't assign preferred LLC if it > > + * conflicts with NUMA balancing. > > + */ > > + if (p->numa_preferred_nid >=3D 0 && > > + cpu_to_node(mm->mm_sched_cpu) !=3D p->numa_preferred_nid) > > + mm_sched_llc =3D -1; > > +#endif > > + } > > + > > + if (p->preferred_llc !=3D mm_sched_llc) > > + p->preferred_llc =3D mm_sched_llc; > > } >=20 > This can of course still happen when sched_setnuma() gets called. I'm > thinking it is not much of an issue because we expect this thing to get > called fairly regularly -- at a higher rate than sched_setnuma() at > least -- and thus the conflict only exists for a short period of time? >=20 > If so, that would make for a good comment. Sure. Will do. >=20 > Additionally, we could of course search for the busiest LLC inside the > node, instead of setting -1. Again, that could live as a comment for > future work. A potential issue with scanning only the preferred node of a single task=C2= =A0 is that tasks within the same process may have different preferred nodes. For example, task 1 may prefer one node, while tasks 2=E2=80=A6n prefer ano= ther.=C2=A0 If we base the busiest-LLC scan solely on task 1=E2=80=99s preference, we m= ay=C2=A0 ignore the preferences of tasks 2=E2=80=A6n. Consequently, constraining=C2= =A0 the preferred LLC according to task 1=E2=80=99s node can interfere with=C2= =A0 NUMA balancing for the rest of the process. This problem does not=C2=A0 arise when all tasks being aggregated belong to the same numa_group,=C2=A0 since they will share the same preferred node. Tim