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 D449D2D23A8 for ; Tue, 9 Dec 2025 11:13:22 +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=1765278807; cv=none; b=gVb+Css69U5UMacvAmgr+FDVDcyU+DCcqCXlrzBtn0Ct90aaXEZvIyn7/4NSUIPxiAw4cylv+0X2bLWmBCuGo6zdd6WjlJNK1VGixrAD4BoJXiXO24gzoVyiMwXdk1FFNfW3/V5a0g0xbhm2yYlnalbAs/MvKwR/C/TtvRGBpms= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765278807; c=relaxed/simple; bh=uy3NGzW6nLNOiPI7Ab+s+dAM/4QMdZylBK3WlC7E3N4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QVJXR1S4hejWrQCmvs98BKZupVE14CHB6kNrqiN2mr99cljohhbO/+0r1lRMh/y1oBOt5IPIe4o9xZ9Leh/uepVsdqxRVEhUBgTtNbQCrVRpwbd9FQ2Y+Ngc0WzUGG8JTbmolZnhqe8Cqkc4anAp4rVwm5BuV8VKF9BlIDsKMUQ= 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=Ntmn/MTT; 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="Ntmn/MTT" 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=6AE+HPJx+FolZ0yUD/eBljDOvpUtzJwnKDRUEbooAlw=; b=Ntmn/MTTQ71UGJgRJ+ytZ5mTSh 55KjalwuDImOmtbNLIyZ3fpJ/0Qfs6X7y6hefDqVqD/FQ9oR1Otm3EEyv8W1EeuiwyIq8NggbR2G3 n+VUtEUhdltrveLoJhWQgTxw7zCkdwW3CYhBMe3yvQqFPYsWQtaDveUhMTaIkXYiEENRola9YxrEN jKWIhLD/q4IesxSN6tZiDXHegbp/xIhHqB+WdLUCf+rM6m/PP7joSaz+vmMEnEEeYDjr781DCcrGu uZrRZvdZl0jnVqZ4xbcUi8uhv4IN4UEP1tC6AevigIs3MjegDx1g22YkRhmueDrua01qgV2OkkSSD ZL3Hc7KA==; 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 1vSve9-0000000B8FE-1OTk; Tue, 09 Dec 2025 11:12:45 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 2203230045C; Tue, 09 Dec 2025 12:12:44 +0100 (CET) Date: Tue, 9 Dec 2025 12:12:44 +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 01/23] sched/cache: Introduce infrastructure for cache-aware load balancing Message-ID: <20251209111244.GJ3707891@noisy.programming.kicks-ass.net> References: <06f0d7edbc3185ec730b50b3b00d87ace44169b3.1764801860.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: <06f0d7edbc3185ec730b50b3b00d87ace44169b3.1764801860.git.tim.c.chen@linux.intel.com> On Wed, Dec 03, 2025 at 03:07:20PM -0800, Tim Chen wrote: > Minor fix in task_tick_cache() to use > if (mm->mm_sched_epoch >= rq->cpu_epoch) > to avoid mm_sched_epoch going backwards. > +static void task_tick_cache(struct rq *rq, struct task_struct *p) > +{ > + struct callback_head *work = &p->cache_work; > + struct mm_struct *mm = p->mm; > + > + if (!sched_cache_enabled()) > + return; > + > + if (!mm || !mm->pcpu_sched) > + return; > + > + /* avoid moving backwards */ > + if (mm->mm_sched_epoch >= rq->cpu_epoch) > + return; IIRC this was supposed to be able to wrap; which then means you should write it like: if ((mm->mm_sched_epoch - rq->cpu_epoch) >= 0) return; or somesuch. > + > + guard(raw_spinlock)(&mm->mm_sched_lock); > + > + if (work->next == work) { > + task_work_add(p, work, TWA_RESUME); > + WRITE_ONCE(mm->mm_sched_epoch, rq->cpu_epoch); > + } > +}