Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1586759rdd; Thu, 11 Jan 2024 03:53:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyXgDX0t53tbQJtWS2cHIxAQXBbz3aJzmMRqekJh9JTUlBDsKWyoGaYhCDWBLHb2qPixrk X-Received: by 2002:a0d:e651:0:b0:5f6:d80b:674a with SMTP id p78-20020a0de651000000b005f6d80b674amr402165ywe.27.1704973995446; Thu, 11 Jan 2024 03:53:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704973995; cv=none; d=google.com; s=arc-20160816; b=y6Wx8EZIIocPW+8d+3QQWBCV4mej5V/+FzWBvWiAD0krO2w3mfuAW9tj+A3uRtB3D3 zh9VzfG48Kq9R1/+ws/aOgAaEmJS9bf/ALamXco+710bG8KUzGsBfqNeWGqOlmmeW9I3 h23Sm6m5bQ7So9jiaCoZ5ACB2XeuxBTjodFCNhYBZRe/llnXeAj7+CHFPnaztXa1gwFH tBkLcxc1GNj7e7xcPprpFn14n6ZTJ9hIe56LuQ6zSKpo1rKm9WT5o8RukYT91Z4oB4Qv EbzoEKt8W8JbAtEa65Zefm90JVPjZs7HwYXU5/1XJ6Ak6Xa2rNaNYvFEXi9zLPj56FFS dEbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Nqvos4WQY2drz+EfAUjc2DgvS79oVJ3ure5sp0jGew8=; fh=s8456Om8jjY7r9aKZpWc+txIbL9ZKIJuqH16NB1RR5s=; b=bbn07ehhNSHfN3QbJeywLShGT8DbNrz5xJrbYOmE2lhCVlMb9BhBKe2HjcUlJIxncb oQd5zyi4nyEAKOLujmbUIQjpb4gduKIVeyCY42XtJ6lnZJCprP5r9ODBvhnIlPcjRpDw 4CgquzV6byxjfFe1/3jco1ccWcWYlA8oMUBcmoeIrxg7PDkWKYHvlB5FQ+ti7BFiKG+J TFLEFebWzHbXSgzQJERNhkCoNDzvkznoOcDtrG66x2tN8bRo62b1cluB9/phsca6fp41 iVxzywBa9ofFVHi5OGm6OWgtiDSrMqLiydbFC/jJ6+uSc4rFhD58MpaZcOcQ8OxML8Pr 7Bng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kI6zd3Jk; spf=pass (google.com: domain of linux-kernel+bounces-23523-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23523-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i2-20020a0cab42000000b0068124c6d6d1si629530qvb.103.2024.01.11.03.53.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 03:53:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23523-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kI6zd3Jk; spf=pass (google.com: domain of linux-kernel+bounces-23523-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23523-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 367291C220EB for ; Thu, 11 Jan 2024 11:53:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61BE0156C5; Thu, 11 Jan 2024 11:53:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kI6zd3Jk" Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (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 3A63A154AC for ; Thu, 11 Jan 2024 11:53:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-680a13af19bso33567866d6.0 for ; Thu, 11 Jan 2024 03:53:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704973987; x=1705578787; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Nqvos4WQY2drz+EfAUjc2DgvS79oVJ3ure5sp0jGew8=; b=kI6zd3JkC/C94zgbV3PzGzvEQ+W62IEqiX67aOGir4aRwiQAI50qwg3iVq3kUU5IY3 v9LqscU1MRjyJsDHDuOVrBbVb+LMD68Gsr8WeDOPBZbQmCGcpnRepz/vN4KcEnrk3tOM H1RooOr6vU18ialOWDr+iT2od6AVvbFDg1udRHC2ztSIRhnsz64Z2hFf4f6nNy+vVmw0 e6VlKkSNeYimVT6hTIfQPnmVdC9cCzm4hh4YnqvaAIrMI78KpSXMAfhEkJXQnbCp8UHp GogCUDM+xgOO+aZU9CX0fLIgiwbe4C6eY3tom+FhV33pXdquT29KsMtXmiJv4Fx39+xt xIQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704973987; x=1705578787; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Nqvos4WQY2drz+EfAUjc2DgvS79oVJ3ure5sp0jGew8=; b=bNApAE2o5EAyE8KrFIT4C9Cr+cPAz64DhsCK6O3zYHn8mn38sMAU/maQKRC80WLWx0 exTFI5gsuscsRBFzcnVP1ZVDup1mvrHy0E/q01vsGcPkNHw4Wcd33InW7Zr22gr/y7hK gSQZnYF+F2iMO7E6SIz2+uq1k6yXNCNCUBx3NPW6bDPPpfjZ4dMA+PSUDyrWTVuNIbIM Po/JCsTg48BFijwxrt3t5By7gynvaFK7zuwD4b8JHOHP7O3T01QSyb8sI00RELsb4YoS fNjZdfl/VCFWG1Usi109/c63ljPWXhOcth3J91RHxKrH6hH7j1YtoTwK7NFtqT00Wg7m zaTg== X-Gm-Message-State: AOJu0YwSfiEFvgmkeaFICdKSYlewVVx5UTaYTyF3zRn1nrqNCQY8sTxi JJ+gJ3dAu2aHqtg3OcdrmatPbIx0zFOs6zCwsCM= X-Received: by 2002:a05:6214:29c3:b0:67c:1818:7966 with SMTP id gh3-20020a05621429c300b0067c18187966mr1135655qvb.46.1704973987051; Thu, 11 Jan 2024 03:53:07 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240110133038.46903-1-wudaemon@163.com> In-Reply-To: <20240110133038.46903-1-wudaemon@163.com> From: Yafang Shao Date: Thu, 11 Jan 2024 19:52:30 +0800 Message-ID: Subject: Re: [PATCH v4] sched/stats: Fix rt/dl task's sched latency statistics error in sched_stat_wait trace_point To: Junwen Wu Cc: bristot@redhat.com, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jan 10, 2024 at 9:32=E2=80=AFPM Junwen Wu wrote: > > The sched_stat_wait tracepoint is showing unreasonably long > latencies for real-time tasks. For example: > > sched_stat_wait: comm=3Drcu_preempt pid=3D14 delay=3D4936139545261 [ns] > > This error happens when the rt task balances off the source CPU because > the dequeue operation is not updating the sched_statistics. So, follow > update_stats_wait_end_fair() and update the stats. Do the same for > SCHED_DEADLINE. > > Fixes: 57a5c2dafca8 ("sched/rt: Support schedstats for RT sched class") > Fixes: b5eb4a5f6521 ("sched/dl: Support schedstats for deadline sched cla= ss") > Signed-off-by: Junwen Wu Acked-by: Yafang Shao BTW, feel free to include the 'acked-by' in a newer version if your modifications are only minor. > --- > kernel/sched/deadline.c | 5 ++++- > kernel/sched/rt.c | 4 ++++ > 2 files changed, 8 insertions(+), 1 deletion(-) > > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c > index b28114478b82..4a9aad291fb9 100644 > --- a/kernel/sched/deadline.c > +++ b/kernel/sched/deadline.c > @@ -1558,10 +1558,13 @@ update_stats_dequeue_dl(struct dl_rq *dl_rq, stru= ct sched_dl_entity *dl_se, > int flags) > { > struct task_struct *p =3D dl_task_of(dl_se); > + struct rq *rq =3D rq_of_dl_rq(dl_rq); > > if (!schedstat_enabled()) > return; > - > + /* Mark the end of the wait period if dequeueing a waiting task.= */ > + if (p && (p !=3D rq->curr)) > + update_stats_wait_end_dl(dl_rq, dl_se); > if ((flags & DEQUEUE_SLEEP)) { > unsigned int state; > > diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c > index 6aaf0a3d6081..5cb3a54d6b13 100644 > --- a/kernel/sched/rt.c > +++ b/kernel/sched/rt.c > @@ -1360,12 +1360,16 @@ update_stats_dequeue_rt(struct rt_rq *rt_rq, stru= ct sched_rt_entity *rt_se, > int flags) > { > struct task_struct *p =3D NULL; > + struct rq *rq =3D rq_of_rt_se(rt_se); > > if (!schedstat_enabled()) > return; > > if (rt_entity_is_task(rt_se)) > p =3D rt_task_of(rt_se); > + /* Mark the end of the wait period if dequeueing a waiting task. = */ > + if (p && (p !=3D rq->curr)) > + update_stats_wait_end_rt(rt_rq, rt_se); > > if ((flags & DEQUEUE_SLEEP) && p) { > unsigned int state; > -- > 2.34.1 > --=20 Regards Yafang