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 9E8E33C8729 for ; Thu, 9 Apr 2026 12:43:34 +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=1775738617; cv=none; b=iZU5cqkdo7PaBuL1/+CggX1JQUgUkzUUooRaPRBVGALrpUNPHmME/uTMvg5x8cFpww7FtZrXbiH0iR3V2xDAuy3ILCkr0LLZAwyaCrwiR142xeMFbV5HH8GWkZfWTV2Pcohg1SILIrmiup0a/BeKTicDWfAfso67o/LW3hFBUlE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775738617; c=relaxed/simple; bh=xVp/bldlEEu57445Qjux2fYYVIQT1SkYzrnFMhMpKRk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=szEqD+SVoNqzQ1azoYbtfy+euFEqo3LtGPk+9W+wxKlJrPn5VLKSxxcXjnTeOr+hGYTlrXOa29HQSs2gMXXQIBQTAt9hJyiIU1NUq+Tjj+auo1MsAC34Ee4afVlJsG2zmowTGQniIJsXeCtzBo64S+0Maw3wWlmZ39o/2xCOmaw= 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=a8iWdfoS; 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="a8iWdfoS" 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=wt1J/zj1Yko8oWTSj0gNmjrzmFtUHp1JxxswMaSpCGg=; b=a8iWdfoSEeXsS0flE5NgtAZNO/ aUAvfQzk3GPyfR4rCbVbgvh/QU9K/EaW59p09PrS0VtWqibyL0TcUYWB6fhQaiV8CEXmC/pX02miY vZZCBmnluBVLey9hS3PNcVci2gPJcgFg8Ch17eElO1fx9y7eXz7dilnYM1VQocQKcH1VRpaJfhc7W AVMZM63p4d7jIN3fkjSwi7roMj+Ggsd1mc/NdmY2Z6JFOge39vZEFf2MXTP6oHu4Pqg1JunTCrvqK bHhLtyYfcibELXsjLfEXftXC0lAdDMOCSqSKOCFCOxkRJzP4HcJGc2VTkzdoaYOAPbVtDyNu7EWAZ CpUAXdvg==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1wAoj3-0000000BhUo-1hAn; Thu, 09 Apr 2026 12:43:14 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id BBF8D300583; Thu, 09 Apr 2026 14:43:12 +0200 (CEST) Date: Thu, 9 Apr 2026 14:43:12 +0200 From: Peter Zijlstra To: Tim Chen Cc: Ingo Molnar , K Prateek Nayak , "Gautham R . Shenoy" , Vincent Guittot , Chen Yu , 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 , Adam Li , Aaron Lu , Tim Chen , Josh Don , Gavin Guo , Qais Yousef , Libo Chen , linux-kernel@vger.kernel.org Subject: Re: [Patch v4 16/22] sched/cache: Disable cache aware scheduling for processes with high thread counts Message-ID: <20260409124312.GB3126523@noisy.programming.kicks-ass.net> References: <47cc4cffecdac2770a719c84bec3b459a1256def.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: <47cc4cffecdac2770a719c84bec3b459a1256def.1775065312.git.tim.c.chen@linux.intel.com> On Wed, Apr 01, 2026 at 02:52:28PM -0700, Tim Chen wrote: > @@ -1507,7 +1513,8 @@ void account_mm_sched(struct rq *rq, struct task_struct *p, s64 delta_exec) > */ > if (time_after(epoch, > READ_ONCE(mm->sc_stat.epoch) + EPOCH_LLC_AFFINITY_TIMEOUT) || > - get_nr_threads(p) <= 1) { > + get_nr_threads(p) <= 1 || > + exceed_llc_nr(mm, cpu_of(rq))) { > if (mm->sc_stat.cpu != -1) > mm->sc_stat.cpu = -1; > } > @@ -1608,6 +1633,13 @@ static void task_cache_work(struct callback_head *work) > if (p->flags & PF_EXITING) > return; > > + if (get_nr_threads(p) <= 1) { > + if (mm->sc_stat.cpu != -1) > + mm->sc_stat.cpu = -1; > + > + return; > + } > + > if (!zalloc_cpumask_var(&cpus, GFP_KERNEL)) > return; > > @@ -10105,6 +10144,13 @@ static enum llc_mig can_migrate_llc_task(int src_cpu, int dst_cpu, > if (cpu < 0 || cpus_share_cache(src_cpu, dst_cpu)) > return mig_unrestricted; > > + /* skip cache aware load balance for single/too many threads */ > + if (get_nr_threads(p) <= 1 || exceed_llc_nr(mm, dst_cpu)) { > + if (mm->sc_stat.cpu != -1) > + mm->sc_stat.cpu = -1; > + return mig_unrestricted; > + } > + > if (cpus_share_cache(dst_cpu, cpu)) > to_pref = true; > else if (cpus_share_cache(src_cpu, cpu)) This is what that made me notice that weird get_nr_threads() <= 1 thing.