* [PATCH v1] sched/rt: Fix rt task's sched latency statistics in sched_stat_wait trace_point
@ 2023-12-18 15:03 Junwen Wu
2023-12-19 12:35 ` Yafang Shao
0 siblings, 1 reply; 8+ messages in thread
From: Junwen Wu @ 2023-12-18 15:03 UTC (permalink / raw)
To: mingo, laoar.shao, peterz, juri.lelli, vincent.guittot,
dietmar.eggemann, rostedt, bsegall
Cc: mgorman, bristot, vschneid, linux-kernel, Junwen Wu
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 <wudaemon@163.com>
---
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
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v1] sched/rt: Fix rt task's sched latency statistics in sched_stat_wait trace_point
2023-12-18 15:03 [PATCH v1] sched/rt: Fix rt task's sched latency statistics in sched_stat_wait trace_point Junwen Wu
@ 2023-12-19 12:35 ` Yafang Shao
2023-12-19 14:53 ` Junwen Wu
2023-12-20 14:01 ` Junwen Wu
0 siblings, 2 replies; 8+ messages in thread
From: Yafang Shao @ 2023-12-19 12:35 UTC (permalink / raw)
To: Junwen Wu
Cc: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, bristot, vschneid, linux-kernel
On Mon, Dec 18, 2023 at 11:05 PM Junwen Wu <wudaemon@163.com> wrote:
>
> 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.
Thanks for your report!
>
> Signed-off-by: Junwen Wu <wudaemon@163.com>
> ---
> 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)
This seems wrong, the rt_se might not be a task.
I think we'd better use if (!on_rt_rq(rt_se))
> + 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] 8+ messages in thread* Re: [PATCH v1] sched/rt: Fix rt task's sched latency statistics in sched_stat_wait trace_point
2023-12-19 12:35 ` Yafang Shao
@ 2023-12-19 14:53 ` Junwen Wu
2023-12-20 14:01 ` Junwen Wu
1 sibling, 0 replies; 8+ messages in thread
From: Junwen Wu @ 2023-12-19 14:53 UTC (permalink / raw)
To: laoar.shao
Cc: bristot, bsegall, dietmar.eggemann, juri.lelli, linux-kernel,
mgorman, mingo, peterz, rostedt, vincent.guittot, vschneid,
wudaemon
ok, I will take your advise, and test my platform.
--
Regards
Junwen
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] sched/rt: Fix rt task's sched latency statistics in sched_stat_wait trace_point
2023-12-19 12:35 ` Yafang Shao
2023-12-19 14:53 ` Junwen Wu
@ 2023-12-20 14:01 ` Junwen Wu
2023-12-20 14:32 ` [PATCH v1] sched/rt: Fix rt task's sched latency statistics error " Junwen Wu
1 sibling, 1 reply; 8+ messages in thread
From: Junwen Wu @ 2023-12-20 14:01 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] 8+ messages in thread
* Re: [PATCH v1] sched/rt: Fix rt task's sched latency statistics error in sched_stat_wait trace_point
2023-12-20 14:01 ` Junwen Wu
@ 2023-12-20 14:32 ` Junwen Wu
2023-12-20 14:40 ` Junwen Wu
2023-12-20 15:18 ` Yafang Shao
0 siblings, 2 replies; 8+ messages in thread
From: Junwen Wu @ 2023-12-20 14:32 UTC (permalink / raw)
To: laoar.shao
Cc: bristot, bsegall, dietmar.eggemann, juri.lelli, linux-kernel,
mgorman, mingo, peterz, rostedt, vincent.guittot, vschneid,
wudaemon
>>I think we'd better use if (!on_rt_rq(rt_se))
>>
>> + update_stats_wait_end_rt(rt_rq, rt_se);
>>
hi, Yafang.when execute update_stats_dequeue_rt, rt_se->on_rq is still 0, util dequeue_rt_stack,
the method is not effect.
I this we can use if (p && p != rq->curr) /*Mark the end of the wait period if dequeueing task*/
because schedstats is not supported for rt group,we only need to update rt_se that is realy task.
--
Best regards
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] sched/rt: Fix rt task's sched latency statistics error in sched_stat_wait trace_point
2023-12-20 14:32 ` [PATCH v1] sched/rt: Fix rt task's sched latency statistics error " Junwen Wu
@ 2023-12-20 14:40 ` Junwen Wu
2023-12-20 15:18 ` Yafang Shao
1 sibling, 0 replies; 8+ messages in thread
From: Junwen Wu @ 2023-12-20 14:40 UTC (permalink / raw)
To: laoar.shao
Cc: bristot, bsegall, dietmar.eggemann, juri.lelli, linux-kernel,
mgorman, mingo, peterz, rostedt, vincent.guittot, vschneid,
wudaemon
sorry, type error. rt_se->on_rq is still 1
--
Best regards
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] sched/rt: Fix rt task's sched latency statistics error in sched_stat_wait trace_point
2023-12-20 14:32 ` [PATCH v1] sched/rt: Fix rt task's sched latency statistics error " Junwen Wu
2023-12-20 14:40 ` Junwen Wu
@ 2023-12-20 15:18 ` Yafang Shao
2023-12-21 14:50 ` Junwen Wu
1 sibling, 1 reply; 8+ messages in thread
From: Yafang Shao @ 2023-12-20 15:18 UTC (permalink / raw)
To: Junwen Wu
Cc: bristot, bsegall, dietmar.eggemann, juri.lelli, linux-kernel,
mgorman, mingo, peterz, rostedt, vincent.guittot, vschneid
On Wed, Dec 20, 2023 at 10:33 PM Junwen Wu <wudaemon@163.com> wrote:
>
> >>I think we'd better use if (!on_rt_rq(rt_se))
> >>
> >> + update_stats_wait_end_rt(rt_rq, rt_se);
> >>
> hi, Yafang.when execute update_stats_dequeue_rt, rt_se->on_rq is still 0, util dequeue_rt_stack,
> the method is not effect.
Ah, you are right.
> I this we can use if (p && p != rq->curr) /*Mark the end of the wait period if dequeueing task*/
Agreed.
> because schedstats is not supported for rt group,we only need to update rt_se that is realy task.
> --
> Best regards
>
--
Regards
Yafang
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] sched/rt: Fix rt task's sched latency statistics error in sched_stat_wait trace_point
2023-12-20 15:18 ` Yafang Shao
@ 2023-12-21 14:50 ` Junwen Wu
0 siblings, 0 replies; 8+ messages in thread
From: Junwen Wu @ 2023-12-21 14:50 UTC (permalink / raw)
To: laoar.shao
Cc: bristot, bsegall, dietmar.eggemann, juri.lelli, linux-kernel,
mgorman, mingo, peterz, rostedt, vincent.guittot, vschneid,
wudaemon
>Ah, you are right.
>
>> I this we can use if (p && p != rq->curr) /*Mark the end of the wait period if dequeueing task*/
>
>Agreed.
>
>> because schedstats is not supported for rt group,we only need to update rt_se that is realy task.
>> --
>> Best regards
>>
ok, I send PATCH v2 later
--
Best regards
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-12-21 14:52 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-18 15:03 [PATCH v1] sched/rt: Fix rt task's sched latency statistics in sched_stat_wait trace_point Junwen Wu
2023-12-19 12:35 ` Yafang Shao
2023-12-19 14:53 ` Junwen Wu
2023-12-20 14:01 ` Junwen Wu
2023-12-20 14:32 ` [PATCH v1] sched/rt: Fix rt task's sched latency statistics error " Junwen Wu
2023-12-20 14:40 ` Junwen Wu
2023-12-20 15:18 ` Yafang Shao
2023-12-21 14:50 ` 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®