From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 9C9B03BED6A for ; Thu, 9 Apr 2026 12:41:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775738508; cv=none; b=lrmwZWgZW6MA/ZgEWoFTcxzWi6bGqFRGz1Rkq2R0SgiOKPk1FbZcnvPgIuMIw9yKhXwLM6mDyjMgypmBogwIwwD0UKa5YOby3/6+25fkxg2S+ujlmKMwiaVYfE6nlBwYocjf5Bt1GoNqwKLfCkKBqWPLRZRJZuJL3DwjJ2K9lto= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775738508; c=relaxed/simple; bh=xcw22zAxKoA9FGaJrjIJLmfWcFNM23dPhGu3e7jQcdo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Fr4QN8B9ccfiJjIzScpyyoyZ65bGKxZyZ2GCeVP6UM/03SXANzpz1G5VIp8G17m6ay1lt9LngTuXtQ2gCoG7c3Noe4Kr4kqOsOlVyprIQWAq+6Frixuh2wdqXHfh5oELk4WXsUqi83Y/duRXruCgs5bLnVhvp2/nxxyOWgvRq1o= 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=Cokud08F; arc=none smtp.client-ip=90.155.92.199 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="Cokud08F" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=Sn4OdqKVQ5106PwQ7kFvbdQsI9YPDRHhYk2BqhfWqtg=; b=Cokud08FctTWDnd98/0rViztzz gAaF18NZ5Nr0eu68pvF67S4uvttU4NM8GaJ4wtSH5gE4luJVI46XMdF5iipZY905rIMr1fP5JW0G+ JqOrKjdgPcgyuupMiT6QXYRQ73ooKlZVLBeB+q5Y66cmSkk0iqzjNemWF9mBOSU4YZYR0x13rmxkT j0x4xaE0bCQd+DWK1/fQVcL4c3+Ki9MHZSaDUZ6MttqC4Xh6Pqd1UAok38JKB1r2jqIghVNPH7OSr KKLygNjguTwYnrmpJRpnnxq0ZC5r++Y6xAikjmPARvMRNiSS0tZb6PgTRkI6kDxu3bNS4g3X5scp1 2ivx2XTQ==; Received: from 2001-1c00-8d85-4b00-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:4b00:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1wAoh7-0000000BhKU-0A4W; Thu, 09 Apr 2026 12:41:13 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id F3EF4300583; Thu, 09 Apr 2026 14:41:10 +0200 (CEST) Date: Thu, 9 Apr 2026 14:41:10 +0200 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 , Josh Don , Gavin Guo , Qais Yousef , Libo Chen , linux-kernel@vger.kernel.org Subject: Re: [Patch v4 01/22] sched/cache: Introduce infrastructure for cache-aware load balancing Message-ID: <20260409124110.GA3126523@noisy.programming.kicks-ass.net> References: <6269a53221b9439b9ca00d18a9d1946fb64d8cff.1775065312.git.tim.c.chen@linux.intel.com> 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: <6269a53221b9439b9ca00d18a9d1946fb64d8cff.1775065312.git.tim.c.chen@linux.intel.com> On Wed, Apr 01, 2026 at 02:52:13PM -0700, Tim Chen wrote: > +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 = p->mm; > + unsigned long epoch; > + > + if (!sched_cache_enabled()) > + return; > + > + if (p->sched_class != &fair_sched_class) > + return; > + /* > + * init_task, kthreads and user thread created > + * by user_mode_thread() don't have mm. > + */ > + if (!mm || !mm->sc_stat.pcpu_sched) > + return; > + > + pcpu_sched = per_cpu_ptr(p->mm->sc_stat.pcpu_sched, cpu_of(rq)); > + > + scoped_guard (raw_spinlock, &rq->cpu_epoch_lock) { > + __update_mm_sched(rq, pcpu_sched); > + pcpu_sched->runtime += delta_exec; > + rq->cpu_runtime += delta_exec; > + epoch = rq->cpu_epoch; > + } > + > + /* > + * If this process hasn't hit task_cache_work() for a while, or it > + * has only 1 thread, invalidate its preferred state. > + */ > + if (time_after(epoch, > + READ_ONCE(mm->sc_stat.epoch) + EPOCH_LLC_AFFINITY_TIMEOUT) || I really think that: if (epoch - READ_ONCE(mm->sc_stat.epoch) > EPOCH_LLC_AFFINITY_TIMEOUT) is simpler to read. > + get_nr_threads(p) <= 1) { And this, I just noticed this, why are we excluding tasks with one thread? The comment just states we are (doh), but utterly fails to explain why. > + if (mm->sc_stat.cpu != -1) > + mm->sc_stat.cpu = -1; > + } > +}