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 3D348486B84 for ; Thu, 8 Jan 2026 11:16:46 +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=1767871011; cv=none; b=pMJUYnbmJ1b14+JWfRIo5OqjeFxhaiSYsk0WTkZYi1UjDY1wn2e8dwWIBVh8F3+tihkT/LmNLP/tF6ZKwEKzxQj7+q91E6GGYjgHY4ea84rdlTUzj4xePMRQwuFym+BjHOHUdHFySi6tTdnySHvTY7FV47tqxKIrjUQOwbXgF4w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767871011; c=relaxed/simple; bh=e1x1FodEbQLHfJDnr9yCuQy+srWE2hIpLtL9aL/6syI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MTPbZcURUmduHjkVgNCXIFDKOrJer0HAP55qWfpqP7EEsqEZ0RkGqobNm06JIKQV+5d50J6kZbAEeA8uN8NhhfaWq/dxGGtSAzZ9xrGGyYborQWcjSTwdktAiSV+H52bg37PJMHjreR8yWg8o9NURuX2qThW+0gLiZHRGIHTGpE= 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=kH0SR/WT; 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="kH0SR/WT" 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=/K/ajdPdRqkH9IPbmwsANGlkSAgoS8eVOxuBsPn+o14=; b=kH0SR/WT5ODrg0ZXozLLI40kYr 0Kc6eG3ON2n+nWoNhNZTVrmpCz3IpVJbASQa2Ps0/t4Pcf4/GeXj7t1EPH61YE7GnUy1UU1GVqpub Sh8WdSDAnGJ0zdN8E1E2j7WgIUQY8KqniF7kdV0DJyJT52xrQkM7ru4dkHlpz3wR3qQSyulY5gbjW VdIyEwpxX4tr8+RnExi3K3NT+ctrMcNydGHLnW0yyajCD1BZybKcm5ERjmp+sGbzVu8fINxPOoPKy K3c5Z2hRKjhyIVts6iHKYbMPJ/OpRYpbbKrFniQy9AQ1IgAZKChUsH54ccVk1LoKDlVwMXAvUkTB/ eCmrfV0w==; 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 1vdo0I-0000000EqjO-0lKf; Thu, 08 Jan 2026 11:16:34 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 0820B300E8E; Thu, 08 Jan 2026 12:16:33 +0100 (CET) Date: Thu, 8 Jan 2026 12:16:32 +0100 From: Peter Zijlstra To: Dengjun Su Cc: linux-kernel@vger.kernel.org, mike.zhang@mediatek.com, haiqiang.gong@mediatek.com, peijun.huang@mediatek.com, Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Matthias Brugger , AngeloGioacchino Del Regno , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH] sched/rt: fix incorrect schedstats for rt thread Message-ID: <20260108111632.GH272712@noisy.programming.kicks-ass.net> References: <20260108031309.2754003-1-dengjun.su@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=us-ascii Content-Disposition: inline In-Reply-To: <20260108031309.2754003-1-dengjun.su@mediatek.com> On Thu, Jan 08, 2026 at 11:13:07AM +0800, Dengjun Su wrote: > For RT thread, only 'set_next_task_rt' will call > 'update_stats_wait_end_rt' to update schedstats information. > However, during the RT migration process, > 'update_stats_wait_start_rt' will be called twice, which > will cause the values of wait_max and wait_sum to be incorrect. Right, that looses time. Also note that I think dl has the same issue. > The specific output as follows: > $ cat /proc/6046/task/6046/sched | grep wait > wait_start : 0.000000 > wait_max : 496717.080029 > wait_sum : 7921540.776553 > > Add 'update_stats_wait_end_rt' in 'update_stats_dequeue_rt' to > update schedstats information when dequeue_task. This needs a few more words on why this is correct -- notably it took me a little time to find the 'task_on_rq_migrating()' case in __update_stats_wait_end() which makes this not actually 'end'. But then the corresponding clause in __update_stats_wait_start() gives me a headache: 'wait_start > prev_wait_start' I mean, wtf. Should that not equally be using task_on_rq_migrating() ? Can you please take a hard look at all that and fix up things all-round?