From nobody Mon May 25 00:09:41 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 2FDF73ED113; Wed, 20 May 2026 08:34:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779266100; cv=none; b=Vj+VKsOQGIEtNMSE4FHfe7wUkI8XmHRQVLdwIg2wgSmZeDQVFo8MGIcttMnS9bazp8dORdmf7AH4Xs6wGJDx2BJqeyxvtM7yVeAgZjsuzlWotqxvzpUzCZcQ6MgNFtPjMqUWA4wY35wSwmQhS/SLqPZELbCHwGUE11DOggLen/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779266100; c=relaxed/simple; bh=k3t8RvzroAt2pe48iPnyN2VdzcAkq4QcbLw7UoRgEVE=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=bGUCXJmz+xBLoDzImxUuhMkkG2mqmRH4Vy+vsV2DX/vHtM1IY07ulQU8a9gIoiOObxoc9A+y6gy6gubQv34HSMGQckKrRqTJnpSENQzKQYTIIx6wQpyG6dFhbQX//9JS4qwbnRAzsRVzELjKaXABZgTuwc22yO4dzt8OdyXkuJk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=kCQdjHRc; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=5r8gfi8/; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kCQdjHRc"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="5r8gfi8/" Date: Wed, 20 May 2026 08:34:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779266097; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pm7aqoWlb2qnRuMgxDUdnHcYqE+T8UxWdQv7owRXaZY=; b=kCQdjHRcKbcQ73AxjYSMP3/VpnoqDmb0bqicJLxN4HKGOUIOGxyBcUdfSWRtf95l8XFAGf pYMuuFO9G/l6l6s8lNGB4uWhnEgYFqtTzqT8tuVNsHF9P2nxayoRBcWwmYMvwYTfBYsAl6 hoaBDbbyBgBeJNcHUea1bdi9RTdmXPAQMODym/cKi+UDqj/m2O+xY4BkvCKf/fgmVD6h5z 3aVTLYvH9JbRfnIsexIzWOpxQHclvp6WBVJQ6aahN8o8eXd8UjNOZSUIqhDOuMBHpf3wOI +b6pycwwSWYe9yY9SKRNgKUrbz8naK08CBmeAnx3cTAU1Tc/WhOom/HtxrySMw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779266097; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pm7aqoWlb2qnRuMgxDUdnHcYqE+T8UxWdQv7owRXaZY=; b=5r8gfi8/AI1zyjkfOOAZAp7v9mZkgrRm2AaKQYtdxtXk85Yn1skyyczP/fkCgmcwRcPf0M ynAfFzqKsmVRCeBA== From: "tip-bot2 for Tim Chen" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/cache: Assign preferred LLC ID to processes Cc: Chen Yu , Tim Chen , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: =?utf-8?q?=3Cf2ceecba5858680349ad4ce9303a2121f0bb7272=2E1775065?= =?utf-8?q?312=2Egit=2Etim=2Ec=2Echen=40linux=2Eintel=2Ecom=3E?= References: =?utf-8?q?=3Cf2ceecba5858680349ad4ce9303a2121f0bb7272=2E17750653?= =?utf-8?q?12=2Egit=2Etim=2Ec=2Echen=40linux=2Eintel=2Ecom=3E?= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177926609608.711.14613251585045422907.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the sched/core branch of tip: Commit-ID: 47d8696b95f7397fe7cad2d194d550ffe82efc15 Gitweb: https://git.kernel.org/tip/47d8696b95f7397fe7cad2d194d550ffe= 82efc15 Author: Tim Chen AuthorDate: Wed, 01 Apr 2026 14:52:18 -07:00 Committer: Peter Zijlstra CommitterDate: Thu, 09 Apr 2026 15:49:49 +02:00 sched/cache: Assign preferred LLC ID to processes 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. Co-developed-by: Chen Yu Signed-off-by: Chen Yu Signed-off-by: Tim Chen Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/f2ceecba5858680349ad4ce9303a2121f0bb7272.177= 5065312.git.tim.c.chen@linux.intel.com --- include/linux/sched.h | 1 +- init/init_task.c | 3 +++- kernel/sched/fair.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+) diff --git a/include/linux/sched.h b/include/linux/sched.h index 2bf261b..d201048 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1409,6 +1409,7 @@ struct task_struct { =20 #ifdef CONFIG_SCHED_CACHE struct callback_head cache_work; + int preferred_llc; #endif =20 struct rseq_data rseq; diff --git a/init/init_task.c b/init/init_task.c index b5f48eb..5d90db4 100644 --- a/init/init_task.c +++ b/init/init_task.c @@ -215,6 +215,9 @@ struct task_struct init_task __aligned(L1_CACHE_BYTES) = =3D { .numa_group =3D NULL, .numa_faults =3D NULL, #endif +#ifdef CONFIG_SCHED_CACHE + .preferred_llc =3D -1, +#endif #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) .kasan_depth =3D 1, #endif diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 7860c5b..6e78ecf 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1459,11 +1459,43 @@ static unsigned long fraction_mm_sched(struct rq *r= q, return div64_u64(NICE_0_LOAD * pcpu_sched->runtime, rq->cpu_runtime + 1); } =20 +static int get_pref_llc(struct task_struct *p, struct mm_struct *mm) +{ + int mm_sched_llc =3D -1; + + if (!mm) + return -1; + + if (mm->sc_stat.cpu !=3D -1) { + mm_sched_llc =3D llc_id(mm->sc_stat.cpu); + +#ifdef CONFIG_NUMA_BALANCING + /* + * Don't assign preferred LLC if it + * conflicts with NUMA balancing. + * This can happen when sched_setnuma() gets + * called, however it is not much of an issue + * because we expect account_mm_sched() 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. + */ + if (static_branch_likely(&sched_numa_balancing) && + p->numa_preferred_nid >=3D 0 && + cpu_to_node(mm->sc_stat.cpu) !=3D p->numa_preferred_nid) + mm_sched_llc =3D -1; +#endif + } + + return mm_sched_llc; +} + static inline void account_mm_sched(struct rq *rq, struct task_struct *p, s64 delta_exec) { struct sched_cache_time *pcpu_sched; struct mm_struct *mm =3D p->mm; + int mm_sched_llc =3D -1; unsigned long epoch; =20 if (!sched_cache_enabled()) @@ -1495,6 +1527,11 @@ void account_mm_sched(struct rq *rq, struct task_str= uct *p, s64 delta_exec) if (mm->sc_stat.cpu !=3D -1) mm->sc_stat.cpu =3D -1; } + + mm_sched_llc =3D get_pref_llc(p, mm); + + if (READ_ONCE(p->preferred_llc) !=3D mm_sched_llc) + WRITE_ONCE(p->preferred_llc, mm_sched_llc); } =20 static void task_tick_cache(struct rq *rq, struct task_struct *p) @@ -1671,6 +1708,12 @@ void init_sched_mm(struct task_struct *p) { } =20 static void task_tick_cache(struct rq *rq, struct task_struct *p) { } =20 +static inline int get_pref_llc(struct task_struct *p, + struct mm_struct *mm) +{ + return -1; +} + #endif /* CONFIG_SCHED_CACHE */ =20 /*