From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBFBA299927 for ; Tue, 3 Feb 2026 16:34:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770136496; cv=none; b=nlAyHLHbeGQO+F14Xl+Q9IKx2ISuZkshGABKHF5IRJBJuv0UMreJ0wWvSVHK98TxwVWNIOE8cK79qPIZx9+l+ow/gW0GT+OG7A2lFyazc3atboz6RKpa/rJxD4ioJtBA+ojSx3dZ1Hsr79CHtpXbEfTrbWcJQ1uyOQdsVo4W+fw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770136496; c=relaxed/simple; bh=s9qlp/GSWMoIPlZLdeNc8BstwYSunM6qCwxCynpWrJI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hLiWoUA4/3fTxmjpcViiB2is5K2NE0y1Ys05xbKV3kjqiOtFlbhHupFXkANkd6qWHXfvPUnSNFxDBmvjmlAYxKKr3F8m4REYLie2KSz6iyQp2xEyk+JEV2LMu5UlwuY0OlyzuXl+Ce/mLs0RRzpAl0Ru9I3xJT1XNbh41eVdHpk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=KMpnYFNF; arc=none smtp.client-ip=209.85.222.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="KMpnYFNF" Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-8c5386f1c9fso792910285a.1 for ; Tue, 03 Feb 2026 08:34:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1770136492; x=1770741292; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=n6wyUALUbSFUGitc4pynfi5rai9gREvnrAAmq9/soss=; b=KMpnYFNF9hyf+YEAcP/1umOo49Q0Q1+tF8scezZfVlyPboPs2nbxIG780ROwnqNtxK Qvc8/Wp7WstuoDxR7Fj111qDwwtZKVOiTniytmP6MC27oZU3Ue367W4UJBKi5n3k0/xk uh51Eubb4rr1onnLrXXeK9qxvLflFZoYYQfvNtzIFEzevxhg7rRwNzfSiLIFlWUexjL0 i/VsecoLVrcdX4U7oy81wyb3d3yC0Bug0JqLqVoWQQQhFjYf9Lvcj/jVYmDP8RbUdK5k MQK9qdBFUVUrSkZmHnvUQWe3p46THNd5fU34PoA7fOY36BPGcMhTswkVkZMIDvXSQcYR deow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770136492; x=1770741292; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n6wyUALUbSFUGitc4pynfi5rai9gREvnrAAmq9/soss=; b=xDPKeTegSdcuADUIw+mcw6ycA9LxAWWITSw4mlnOJicSD7AIZEVqnptjdDWUzqL9wF So2g51Mm9YothLvEelL0UPKyIYhhJrfDddqmLn3n3OACdSgYZWSjIFJ1qLDUPYq/32AQ NuYh9OSHwWuNgKJtGreAMdS8eDMnfxXX2fDsKQvWr54ZrTrRAH/RZWEIXEOJTrDdD0Dm wEw9KhIW25esSfniKkTBWpmwEiYlR/pzw1xPfB3talJP/fmSnEmU+PtHSaj9cQKZTatO vG1lLqarqgkItft8HTm5Fe6+qth3yi8oCFq0gUx7Up+pMWTE/RS/7Fl1c8I/Fd+vHP4f 3Psw== X-Forwarded-Encrypted: i=1; AJvYcCVJCn/bdrft6pKSgFgxv8pZbHCRKxgYRb0ocnvi/BKHhqFSxZnC1kQFAOybfgyPrViHPpOi5vkZA8kQGfI=@vger.kernel.org X-Gm-Message-State: AOJu0YxBx77C/nVpoIm/1EC7JvsZ00juMrhVyKBDddTTwOva8+FHTmqY zeiKs1XghNfSb10jzmpxAGp67n9/lmkTicGGG/g6eMGfDcTvm01CEpkOnwJw50NybgU= X-Gm-Gg: AZuq6aKG10LMJ2kLLEMneiAYnjTlgU0fmNvQff44SKbWfiPEiD3khOIMiRT1yeHic1g kHZeoIGmOeBPCeOukOQLI55cIaKzZH6dMsvD5S8e1sezb32+zSkcvQiTZdhkYTy2UFIHGxdsBYn 1vSEeJMySpTfoDsbWvDmE2IF5qza68Y/YKSryWNYCF4WMzA+1wWgxsjxXRIMgXGUoyyjEgtxkka 7GVlh7RIeqIZkvBRl7wnREKJmZgY2UUiLDNjf+EOQwJ0tqJKYddWoSWinq22A6nbAmfgUmnA0+V PgOvglSLiyNtL2tY0pVRe54AxW1SD/I6KYVqCjNKUqQC11CW+vBd5F7CdMJQzy0ssxksLDvXZoa 1leP1L8x93oEhrTAW4O53VwPL3kLvqjPwj+zNIxNG+18WiIGbi6l96ZxpggBApwX4MEGIJrOKoC jcDg2rxO0T+J8feq2dzxVO X-Received: by 2002:a05:620a:2a16:b0:8ca:2e37:ad08 with SMTP id af79cd13be357-8ca2f83e747mr19073185a.34.1770136492445; Tue, 03 Feb 2026 08:34:52 -0800 (PST) Received: from localhost ([2603:7000:c00:1d00:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8ca2fa81908sm4958985a.19.2026.02.03.08.34.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Feb 2026 08:34:51 -0800 (PST) Date: Tue, 3 Feb 2026 11:34:47 -0500 From: Johannes Weiner To: Peter Zijlstra Cc: Suren Baghdasaryan , Ingo Molnar , Chengming Zhou , Dietmar Eggemann , John Stultz , linux-kernel@vger.kernel.org Subject: Re: [PATCH resend 2/2] sched: psi: use rq_clock() during task state changes Message-ID: References: <20260114154317.1815429-1-hannes@cmpxchg.org> <20260114154317.1815429-2-hannes@cmpxchg.org> <20260202204137.GK1395266@noisy.programming.kicks-ass.net> 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: <20260202204137.GK1395266@noisy.programming.kicks-ass.net> On Mon, Feb 02, 2026 at 09:41:37PM +0100, Peter Zijlstra wrote: > On Wed, Jan 14, 2026 at 10:43:17AM -0500, Johannes Weiner wrote: > > In the hottest psi paths, the scheduler already caches the cpu_clock() > > call for the event in rq->clock. Now that the clocks between state > > changes and pressure aggregation don't need to be synchronized inside > > the seqcount section anymore, use the cheaper rq_clock(). > > > > Add update_rq_clock() calls to the few places where psi is entered > > without the rq already locked. > > Just to be clear, rq->clock is not a cache of cpu_clock(). rq->clock > discards all backwards motion (which obviously should never happen, but > if it does, the clocks go out of sync). > > So if you use rq->clock, you must use it for all and not mix with > cpu_clock(). > > I *think* the patch does that, but I've not double checked. Ah no, it does mix them :( Yeah I'm using rq_clock() consistently on the scheduler side to accumulate the times of concluded states. state_start = rq_clock() ... state_time = rq_clock() - state_start However, the aggregator side still uses state_time += cpu_clock() - state_start to incorporate currently active state. If they don't have the same base, this won't work. Doing the full lock and update_rq_clock() from the aggregator sounds quite heavy handed. How about using sched_clock_cpu() directly and doing the backwards motion check by hand? local_irq_save() now = sched_clock_cpu(cpu) local_irq_restore() ... if (state_mask & (1 << s) && now > state_start) times[s] += now - state_start