From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 F28BE33CE88 for ; Fri, 16 Jan 2026 16:13:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768580020; cv=none; b=JRriiGJhPWVFo/cwnJoKuZZFtCJfdFrv8QEdKiVzygF+djiVaMucnYzYn6LfGwMGm7d+D56DjUJf2sq4B5aTHnUm7UAxNcZgfK+GrdnQwFeSoPOoyzgExR0R+uPk8cOaInFfkfV3Iyn96FxcFS7AdIZhV+MJj6Jrkf1EPacZKek= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768580020; c=relaxed/simple; bh=YrooEp6UNw4WOIxcaVPX8D74gYOcLzNKgKhe774XxN8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LmBz4Y1WHZPA7mvYHQ7HaDjH1aWKpTJdQRGscDZxUbmCbEvXS85l/1MOj+r1wLyDfZslDcvgzXvvY8h7rVIX9SlJOMzM8oYnX8X2TJSZjCG4Kz9WYLNG4IQ5xCa+lB5qeD7sAjRnipCQS0BmnswY2iDtTr1U3QTb5REV1vxNkhE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Z0fLs2bK; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Z0fLs2bK" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-47ee76e8656so26684835e9.0 for ; Fri, 16 Jan 2026 08:13:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1768580017; x=1769184817; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=nBV7SQ+ztC+iYEcul9UQfSQjxMaTGCWg67tVLwStv6M=; b=Z0fLs2bKDER67nCBun90TfVyJ8LL4s1jJQn7i9ybMTnleNjQ6HUuCLEP7XJxuP3Pqz wni94Xnn0jHuYza+qZI9jxTgsn6tI3sL3Ok51Sp3VEPOhe+N9DoHhAkbaztGOLFyzgI2 UBn66MRmpRCfg3024kkLrV1c6vEqNMcBmROnCpHLqElOnE/srz5DFMcQ5iVio7kD2O+2 uEGSRSf3OA9uI4pcKlITITX2IyLdFcbPjaj+Srfzwh2ux+Ab5+axCdyBzK/PY1/t4BLS 9CJQC/lJ18gBowpnImszXATyLjOtFSHG7seMueUm29F3G+UQ0oVEuHFs1D+juScU2RnH p7mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768580017; x=1769184817; h=in-reply-to:content-transfer-encoding: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=nBV7SQ+ztC+iYEcul9UQfSQjxMaTGCWg67tVLwStv6M=; b=dsuSJmXjQ3aOYxOGMx83zDIE3DMyWRb1qp756l3dfv5IYJMaHruUK0BXqVRDQZtkdl 5QA8lXaLICs3u3ma1pYS8WA1pe1fknJ1fwuI8ZMO9/7AKYY0Z5NKC7b/RK2b6yPfPki2 3L8BA0YfGa/Wt8q4RdyqxzVCWcZJ3sIz9D2AFIBApK/42zN7/xZ9/qUW0LTPwp40+Wsh e6N9PvQjsH0gxFfXnMSR6MyPX0BFtSRVOklAUhmSiKUZtr/q4LYNbL8CCujTEdE+BuAi JCKULfqL/XNVyIHWdyDmJK6bvpFo/D0Y1JDlrlmqVS/awS+Cu79xAAMH8/bqyBYIgjQN RNFg== X-Forwarded-Encrypted: i=1; AJvYcCW6rpkl2YCNKe8KCPJjRvV8IPI/qRPXJY+sOoLpEwYYaJdXVQTCCMY1nCMp4/R6Pd54ys69kZu8KY+F/sE=@vger.kernel.org X-Gm-Message-State: AOJu0Yy1YUffANM/oQXS9A141K/gbSkvF/IM98dM1JDbeew51p54ZYdq pWUjfBw/LbLa069Cm4E0CrmRg5UnI0fH+kFIlgJS3+WaW2VRMNAxy2Aab7cs0ovQt98= X-Gm-Gg: AY/fxX6UK47gHcdIJUQCgHLUZKrBmDqQQEye0FjvsfF6Q62/C/bkZtaPyRgvAOFlXG4 5L+zFerIWohlygyjZCpiYKWI7X2T3hHfe9dXhQ3UrQFT3T+Blj0w61wKs7G/zs/j8hEAIE0hPJp Lf6/gt/WezMkgvo3xCjCe5eodiCNcz6NBgmnt9PpXsQxv/JUkTLaSpkUUBJppPTB2/qQw08/rlu fHBDlTZzUPGcJSWn/yh5ReMAQSB/s8UnafwUfV7MhH3twaqArihtUp1Bqm8JxF7C2bz6VKHTL0q vhc6CJUefAE0Y6GqkxxY/kgv4fox3a6VRN5GL1bYIAZFq1/Uoo55/iYjPzB2kiGzp2tcZ5bppvD eYhUyen4s0LHnOYiMaiMIRJ9Q8AwKVMfSm0vyqStGS3OTrrV+EgLs+ceRCi/vt/U76SjgMvbiET mj7yWHOKW469DXGXAZNnxQSRNBcVM= X-Received: by 2002:a05:600c:3e14:b0:47a:9560:ec28 with SMTP id 5b1f17b1804b1-4801e30b8ffmr45127045e9.13.1768580017209; Fri, 16 Jan 2026 08:13:37 -0800 (PST) Received: from vingu-cube ([2a01:e0a:f:6020:e3bf:c2ff:a156:39e2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4801e86c1b2sm49366135e9.3.2026.01.16.08.13.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jan 2026 08:13:36 -0800 (PST) Date: Fri, 16 Jan 2026 17:13:34 +0100 From: Vincent Guittot To: Alex Hoh =?utf-8?B?KOizgOaMr+WdpCk=?= Cc: "wusamuel@google.com" , "bsegall@google.com" , "vschneid@redhat.com" , "dietmar.eggemann@arm.com" , "peterz@infradead.org" , "rostedt@goodmis.org" , "mingo@redhat.com" , "linux-kernel@vger.kernel.org" , "mgorman@suse.de" , "juri.lelli@redhat.com" , "kernel-team@android.com" Subject: Re: [PATCH] sched/fair: Fix pelt lost idle time detection Message-ID: References: <20251008131214.3759798-1-vincent.guittot@linaro.org> <8cf19bf0e0054dcfed70e9935029201694f1bb5a.camel@mediatek.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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Le vendredi 16 janv. 2026 à 15:21:35 (+0100), Vincent Guittot a écrit : > Hi Alex, > > Le vendredi 16 janv. 2026 à 06:51:03 (+0000), Alex Hoh (賀振坤) a écrit : > > On Sat, 2025-12-13 at 04:54 +0100, Vincent Guittot wrote: > > > Hi Samuel, > > > > > > > > > On Sat, 6 Dec 2025 at 02:20, Samuel Wu wrote: > > > > > > > > On Fri, Dec 5, 2025 at 4:54 PM Samuel Wu > > > > wrote: > > > > > > > > > > On Fri, Dec 5, 2025 at 7:08 AM Vincent Guittot > > > > > wrote: > > > > > > > > > > > > On Tue, 2 Dec 2025 at 01:24, Samuel Wu > > > > > > wrote: > > > > > > > > > > > > > > On Wed, Oct 8, 2025 at 6:12 AM Vincent Guittot > > > > > > > wrote: > > > > > > [...] > > > [..] > > > that > > > were used to decay the util_avg of cfs task before migrating them > > > which would ends up with decaying too much util_avg > > > > > > But I noticed that you put the util_avg_rt which doesn't use the 2 > > > fields above in mainline. Does android kernel make some changes for > > > rt > > > util_avg tracking ? > > > > > > I believe this change can indeed account for the observed increase in > > RT util. > > > > When prev is the last RT task on the rq, the scheduler proceeds through > > the CFS pick-next flow. With this patch, that path advances > > rq_clock_pelt to the current time. However, updating rq_clock_pelt at > > this stage does not seem correct, as RT util has not yet been updated. > > You're right, put prev happens after we updated pelt clock > > Samuel, > > Could you try the fix below ? I have been too quick and the correct fix should be: --- kernel/sched/fair.c | 6 ------ kernel/sched/idle.c | 2 ++ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 108213e94158..bea71564d3da 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8989,12 +8989,6 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf goto again; } - /* - * rq is about to be idle, check if we need to update the - * lost_idle_time of clock_pelt - */ - update_idle_rq_clock_pelt(rq); - return NULL; } diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 65eb8f8c1a5d..9df6654ef84f 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -468,6 +468,8 @@ static void set_next_task_idle(struct rq *rq, struct task_struct *next, bool fir scx_update_idle(rq, true, true); schedstat_inc(rq->sched_goidle); next->se.exec_start = rq_clock_task(rq); + + update_idle_rq_clock_pelt(rq); } struct task_struct *pick_task_idle(struct rq *rq, struct rq_flags *rf) -- 2.43.0 > > > > The RT util update actually occurs later in put_prev_set_next_task(), > > and it relies on the original value of rq_clock_pelt as input. Since > > rq_clock_pelt has already been overwritten by the time the RT util > > update takes place, the original timestamp is lost. > > > > As a result, the intended CPU/frequency capacity scaling behavior is > > disrupted, causing RT util to increase more rapidly than expected. This > > appears to be an unintended consequence introduced by the patch. > > > > > > > > > > > > > - with patch: > > > > https://ui.perfetto.dev/#!/?s=964594d07a5a5ba51a159ba6c90bb7ab48e09326 > > > > - without patch: > > > > https://ui.perfetto.dev/#!/?s=6ff6854c87ea187e4ca488acd2e6501b90ec9f6f