* [PATCH v4] sched/stats: Fix rt/dl task's sched latency statistics error in sched_stat_wait trace_point
@ 2024-01-10 13:19 Junwen Wu
0 siblings, 0 replies; 5+ messages in thread
From: Junwen Wu @ 2024-01-10 13:19 UTC (permalink / raw)
To: bristot, mingo, laoar.shao, peterz, juri.lelli, vincent.guittot,
dietmar.eggemann, rostedt, bsegall
Cc: mgorman, vschneid, linux-kernel, Junwen Wu
The sched_stat_wait tracepoint is showing unreasonably long
latencies for real-time tasks. For example:
sched_stat_wait: comm=rcu_preempt pid=14 delay=4936139545261 [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.
Signed-off-by: Junwen Wu <wudaemon@163.com>
---
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, struct sched_dl_entity *dl_se,
int flags)
{
struct task_struct *p = dl_task_of(dl_se);
+ struct rq *rq = 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 != 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, 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);
+ /* Mark the end of the wait period if dequeueing a waiting task. */
+ if (p && (p != rq->curr))
+ update_stats_wait_end_rt(rt_rq, rt_se);
if ((flags & DEQUEUE_SLEEP) && p) {
unsigned int state;
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] sched/stats: Fix rt/dl task's sched latency statistics error in sched_stat_wait trace_point
2024-01-10 13:30 Junwen Wu
2024-01-11 11:52 ` Yafang Shao
@ 2024-01-11 15:09 ` Junwen Wu
1 sibling, 0 replies; 5+ messages in thread
From: Junwen Wu @ 2024-01-11 15:09 UTC (permalink / raw)
To: wudaemon
Cc: bristot, bsegall, dietmar.eggemann, juri.lelli, laoar.shao,
linux-kernel, mgorman, mingo, peterz, rostedt, vincent.guittot,
vschneid
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] sched/stats: Fix rt/dl task's sched latency statistics error in sched_stat_wait trace_point
2024-01-11 11:52 ` Yafang Shao
@ 2024-01-11 15:03 ` Junwen Wu
0 siblings, 0 replies; 5+ messages in thread
From: Junwen Wu @ 2024-01-11 15:03 UTC (permalink / raw)
To: laoar.shao
Cc: bristot, bsegall, dietmar.eggemann, juri.lelli, linux-kernel,
mgorman, mingo, peterz, rostedt, vincent.guittot, vschneid,
wudaemon
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] sched/stats: Fix rt/dl task's sched latency statistics error in sched_stat_wait trace_point
2024-01-10 13:30 Junwen Wu
@ 2024-01-11 11:52 ` Yafang Shao
2024-01-11 15:03 ` Junwen Wu
2024-01-11 15:09 ` Junwen Wu
1 sibling, 1 reply; 5+ messages in thread
From: Yafang Shao @ 2024-01-11 11:52 UTC (permalink / raw)
To: Junwen Wu
Cc: bristot, mingo, peterz, juri.lelli, vincent.guittot,
dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
linux-kernel
On Wed, Jan 10, 2024 at 9:32 PM Junwen Wu <wudaemon@163.com> wrote:
>
> The sched_stat_wait tracepoint is showing unreasonably long
> latencies for real-time tasks. For example:
>
> sched_stat_wait: comm=rcu_preempt pid=14 delay=4936139545261 [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 class")
> Signed-off-by: Junwen Wu <wudaemon@163.com>
Acked-by: Yafang Shao <laoar.shao@gmail.com>
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, struct sched_dl_entity *dl_se,
> int flags)
> {
> struct task_struct *p = dl_task_of(dl_se);
> + struct rq *rq = 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 != 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, 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);
> + /* Mark the end of the wait period if dequeueing a waiting task. */
> + if (p && (p != rq->curr))
> + update_stats_wait_end_rt(rt_rq, rt_se);
>
> if ((flags & DEQUEUE_SLEEP) && p) {
> unsigned int state;
> --
> 2.34.1
>
--
Regards
Yafang
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4] sched/stats: Fix rt/dl task's sched latency statistics error in sched_stat_wait trace_point
@ 2024-01-10 13:30 Junwen Wu
2024-01-11 11:52 ` Yafang Shao
2024-01-11 15:09 ` Junwen Wu
0 siblings, 2 replies; 5+ messages in thread
From: Junwen Wu @ 2024-01-10 13:30 UTC (permalink / raw)
To: bristot, mingo, laoar.shao, peterz, juri.lelli, vincent.guittot,
dietmar.eggemann, rostedt, bsegall
Cc: mgorman, vschneid, linux-kernel, Junwen Wu
The sched_stat_wait tracepoint is showing unreasonably long
latencies for real-time tasks. For example:
sched_stat_wait: comm=rcu_preempt pid=14 delay=4936139545261 [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 class")
Signed-off-by: Junwen Wu <wudaemon@163.com>
---
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, struct sched_dl_entity *dl_se,
int flags)
{
struct task_struct *p = dl_task_of(dl_se);
+ struct rq *rq = 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 != 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, 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);
+ /* Mark the end of the wait period if dequeueing a waiting task. */
+ if (p && (p != rq->curr))
+ update_stats_wait_end_rt(rt_rq, rt_se);
if ((flags & DEQUEUE_SLEEP) && p) {
unsigned int state;
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-11 15:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-10 13:19 [PATCH v4] sched/stats: Fix rt/dl task's sched latency statistics error in sched_stat_wait trace_point Junwen Wu
2024-01-10 13:30 Junwen Wu
2024-01-11 11:52 ` Yafang Shao
2024-01-11 15:03 ` Junwen Wu
2024-01-11 15:09 ` Junwen Wu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®