From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 C6A283B8D59 for ; Tue, 9 Dec 2025 12:11:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765282306; cv=none; b=rY7Zt8syjQ9wH1L/lzYjlwdrETmGp+uFdTLeb8WSFRLG4rTdgrVCpv5AAr0ctKNUYxx2/88RukYjldhmtWfOHvf56tbsmnOumgctst+nDM60jnJBZaQJRTBTryRj2v/jFNX5ppFp+Nzl4I3o4pKec07SBcaeFk/8adtDUaKu/Mk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765282306; c=relaxed/simple; bh=5QkfxkjdVakO4B0ZbY8Lo+LzQpL9nAY92lU1NUBeOOA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rxr7sp0puapBwM4Svi/HBIkuBe1rpA0Anfe5MNr8aqf1BA2C4ZJT0MQ5hNPhFKWZVg2IyVPHb8srqBCp3VTt6Qa7khYwxr4sCvQyusBMV9OMXMa67ozgGOeB/4eHAWtrnnbPDMS7aQT/di/hvgxtrtgpCnydy7qGOznTKQUzz/0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=phGxfDts; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="phGxfDts" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=tl4V0/3Sf4W0XqP6RKb7uOFcqTRxNuOV/Z8nQk8WjT8=; b=phGxfDtsQFFfNRoWQahktxKrzz QmoCLL4xpN7mHc2DqIQIuLAjxBWv88vPpMjoaw3jJCmEXlv98zQa0pOJWU4u3+vFZ5ys2ShkZnVF3 azuprrKdRlPGQHheawVsyvRGE5cYHMMlNdUvWHTuylp6TaQgxEWJPARrsS4Ivabupvtn4BugZ2Qrj pgEV5oMgF06G1Ib63dYLZYx3FZfYuXKX7XRnfXxGZ3PCD0YqWk8SS19QpBtGHvZY37pn4fy87SqJ+ Y+iheuOYrpyEsPCJQ6CanWSbDI5zHVJcAxHh1H+EyfX7VtWb3ao/QrmbCfnrwHCktYfuE5VfbIGHD Xpce3qLg==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vSwYa-0000000BEFa-1dVK; Tue, 09 Dec 2025 12:11:04 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 7B73D30045C; Tue, 09 Dec 2025 13:11:03 +0100 (CET) Date: Tue, 9 Dec 2025 13:11:03 +0100 From: Peter Zijlstra To: Tim Chen 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 Subject: Re: [PATCH v2 05/23] sched/cache: Assign preferred LLC ID to processes Message-ID: <20251209121103.GM3707891@noisy.programming.kicks-ass.net> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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. > 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 = p->mm; > struct mm_sched *pcpu_sched; > unsigned long epoch; > + int mm_sched_llc = -1; > > 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 != -1) > mm->mm_sched_cpu = -1; > } > + > + if (mm->mm_sched_cpu != -1) { > + mm_sched_llc = 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 >= 0 && > + cpu_to_node(mm->mm_sched_cpu) != p->numa_preferred_nid) > + mm_sched_llc = -1; > +#endif > + } > + > + if (p->preferred_llc != mm_sched_llc) > + p->preferred_llc = mm_sched_llc; > } 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? If so, that would make for a good comment. 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.