Received: by 2002:a05:7412:a9a3:b0:f9:327e:43ab with SMTP id o35csp157826rdh; Mon, 18 Dec 2023 07:07:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjQZ474AlG6S6mOWvd7Pr3sOgHqYX5s/VH6Bo/gCMMY3WT2q39KeWNcFsstfTDV3PLVaVp X-Received: by 2002:a50:aad1:0:b0:552:dbb7:a1d7 with SMTP id r17-20020a50aad1000000b00552dbb7a1d7mr2376711edc.59.1702912058806; Mon, 18 Dec 2023 07:07:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702912058; cv=none; d=google.com; s=arc-20160816; b=KTS7+DxFsRhXDhln66m+aP5FvbK9Eb1pkHjO8yMBZUozYT4qYuPzfn0MwVvrFa90tD PTtQs6nAdmR74c3KaeDQkOQEqw/kzmbU1NRZVRl8SmRWCOYnP/cVE4N8CbgOZyjhnbLl 9MQagvQk4VYoB9X/1BLp7Xg6P3X4EAYv2g3xlxtJ153ZWB76wlvIhyaFt4EQdwwcWcJD xPndY9CxWechEdMKH2LkIPnuI+OwRC5HMB131dIcVswqyqC1YWPKDqQzMoMInS7x/aVT yur6kcFzgI/+DrQOjmIeQUHuUtf+n3bDh52ZoD/APLUnOUb+CI0vXPytuEz/Lbrr7LOt jHjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=yVVj0ms6yYbBhgiPzB8MS/3H+dwi2Xyw+iNQAT3pKkI=; fh=SliXmL/KGCnuSZGj6lctpIsqzkLaX1tINUOB6TMal4o=; b=Mh/o6QsFiWZdXd7+nRxK5Mp8Uqa7uLC4rlUYaGdCON3ANjjUhJUDrrFFXn9k/rpROw KlOUUGQMnMueZZEOZepydUQVWgLL2Mdo2XYEyjB6QmmXjacIWWJlhPQlkJ8eqnTwCUvs nfmrSAqMqT1/Me9Sr/TdiKKQpO5talhMWT2S5QIMMChJ7cXAUbS/zZdj4ei51HxyifQo GC3hOjo60Oowlp5AtcmzmGCmh3oK0sGCGl04oRgcfoaTjEQSw1UzPMPqEzfY9jcc59VE kUtO+LY++mzxOE5CBhaA0wSmrVX+DYqCiMsm31rguaTd+u+pitjMyvvOp+62BlnBaZcN 1tdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=b3rdgRR0; spf=pass (google.com: domain of linux-kernel+bounces-3886-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3886-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s19-20020a50d493000000b00553495e1322si962542edi.375.2023.12.18.07.07.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 07:07:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3886-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=b3rdgRR0; spf=pass (google.com: domain of linux-kernel+bounces-3886-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3886-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1D1DB1F251CB for ; Mon, 18 Dec 2023 15:05:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 865553A1C0; Mon, 18 Dec 2023 15:05:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="b3rdgRR0" X-Original-To: linux-kernel@vger.kernel.org Received: from m15.mail.163.com (m15.mail.163.com [45.254.50.220]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E21AC3A1C4 for ; Mon, 18 Dec 2023 15:04:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=yVVj0 ms6yYbBhgiPzB8MS/3H+dwi2Xyw+iNQAT3pKkI=; b=b3rdgRR0bvzFTd8qK2rJh RiGeEqpkCqWTJacVdEP7814JwrchIJCdniarIbPOrEVqg8Zau9hGawmV8PWdbr76 90mKi1wzGXsQtt/W3nbrSIOoyAZ021dITxh0ye3Cwq27bD1a08OFoRAMikRXAWkL lugsQ4kliFAidmKxueJu7c= Received: from localhost.localdomain (unknown [120.229.19.179]) by zwqz-smtp-mta-g1-4 (Coremail) with SMTP id _____wDXX6I8X4Bl7UDSFw--.52364S2; Mon, 18 Dec 2023 23:03:25 +0800 (CST) From: Junwen Wu To: mingo@redhat.com, laoar.shao@gmail.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com Cc: mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org, Junwen Wu Subject: [PATCH v1] sched/rt: Fix rt task's sched latency statistics in sched_stat_wait trace_point Date: Mon, 18 Dec 2023 15:03:22 +0000 Message-Id: <20231218150322.788382-1-wudaemon@163.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wDXX6I8X4Bl7UDSFw--.52364S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrZF17Zw1UtF4kurWxtr1UWrg_yoWDuFgEq3 sa9w4qkwn09Fn8tF43Gw4fXryrtayjqFn5Za18tFWDCrykJrZ8tas8KFs5Gws3Xws7AFWq krs2ga4vkrs7ujkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRKVyxJUUUUU== X-CM-SenderInfo: 5zxgtvxprqqiywtou0bp/1tbisR5KbWVOAiFeyAAAsW When enable sched_stat_wait trace_point, some rt tasks sched latency so long, like this: sched_stat_wait: comm=rcu_preempt pid=14 delay=4936139545261 [ns] Rt task has low latency, it must have a bug. I found the reason is When rt task balance off source cpu, dequeue operation not update the sched_statistics, so follow update_stats_wait_end_fair update method. Signed-off-by: Junwen Wu --- kernel/sched/rt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 6aaf0a3d6081..c75215947c20 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1360,12 +1360,15 @@ update_stats_dequeue_rt(struct rt_rq *rt_rq, struct sched_rt_entity *rt_se, int flags) { struct task_struct *p = NULL; + struct rq *rq = rq_of_rt_se(rt_se); if (!schedstat_enabled()) return; if (rt_entity_is_task(rt_se)) p = rt_task_of(rt_se); + if (p != rq->curr) + update_stats_wait_end_rt(rt_rq, rt_se); if ((flags & DEQUEUE_SLEEP) && p) { unsigned int state; -- 2.34.1