update vruntime incorrectly When use rt_mutex
Quoted 3 lines · Kathleen Chang
hi,
We found the vruntime might update incorrectly when use
rt_mutex.
That's nice, on what kernel?
Also, your email is very hard to make sense of.
Quoted 24 lines
<<abnormal case>>
When the Task is waking, update vruntime incorrectly.
1. When there is a CFS task (A) holdrt_mutex_lockand the state isTASK_WAKING(on_rq=0), a RT task (B) want to hold thisrt_mutex_lock. Update vruntime incorrectly.RT task (B)
rt_mutex_setprio (cfs->RT) -> Task is waking , and updatevruntime
queued = task_on_rq_queued(p); // task is waking, queued=0 running = task_current(rq, p); if (queued) /* don't update vruntime here! */ dequeue_task(rq, p, queue_flag); if (running) put_prev_task(rq, p); check_class_changed(rq, p, prev_class, oldprio); -> switched_from_fair -> detach_task_cfs_rq ( due to task is waking, and bypassvruntime-=cfs_rq.min_vruntime)
static void
detach_task_cfs_rq(struct task_struct *p)
Quoted 13 lines
{
struct sched_entity *se = &p->se;
struct cfs_rq *cfs_rq = cfs_rq_of(se);
if (!vruntime_normalized(p)) { // return 1, then p->state is
TASK_WAKING
/*
* Fix up our vruntime so that the current sleep doesn't
* cause 'unlimited' sleep bonus.
*/
place_entity(cfs_rq, se, 0);
check_vruntime(8, se, cfs_rq->min_vruntime);
se->vruntime -= cfs_rq->min_vruntime;So here we subtract min_vruntime,
Quoted 1 line
se->normalized = true;
this doesn't exist.. which makes me wonder what you're looking at,
Quoted 14 lines
} detach_entity_cfs_rq(se); }// when
p->stateisTASK_WAKING, the task's vruntime is normalized static inline boolvruntime_normalized(struct task_struct *p){
.....if (!se->sum_exec_runtime || p->state == TASK_WAKING) return true;}
Quoted 8 lines
2. When the task (A) which holds the
rt_muex_lockunlock thert_mutex_lock.Task (A) must be on_rq=1 rt_mutex_setprio (RT->CFS) if (queued) enqueue_task(rq, p, queue_flag); ); /* vruntime += cfs_rq.min_vruntime */
And here we're adding min_vruntime.
Quoted 4 lines
if (running)
set_curr_task(rq, p);that result in vruntime accumulates
So what exactly is the problem?
hi,
Thanks for your feedback.
Quoted 47 lines · Peter Zijlstra
Quoted 3 lines · Kathleen Chang
hi,
We found the vruntime might update incorrectly when use
rt_mutex.That's nice, on what kernel?
Also, your email is very hard to make sense of.
Quoted 24 lines
<<abnormal case>>
When the Task is waking, update vruntime incorrectly.
1. When there is a CFS task (A) holdrt_mutex_lockand the state isTASK_WAKING(on_rq=0), a RT task (B) want to hold thisrt_mutex_lock. Update vruntime incorrectly.RT task (B)
rt_mutex_setprio (cfs->RT) -> Task is waking , and updatevruntime
queued = task_on_rq_queued(p); // task is waking, queued=0 running = task_current(rq, p); if (queued) /* don't update vruntime here! */ dequeue_task(rq, p, queue_flag); if (running) put_prev_task(rq, p); check_class_changed(rq, p, prev_class, oldprio); -> switched_from_fair -> detach_task_cfs_rq ( due to task is waking, and bypassvruntime-=cfs_rq.min_vruntime)
static void
detach_task_cfs_rq(struct task_struct *p)Quoted 13 lines
{ struct sched_entity *se = &p->se; struct cfs_rq *cfs_rq = cfs_rq_of(se); if (!vruntime_normalized(p)) { // return 1, then p->state is TASK_WAKING /* * Fix up our vruntime so that the current sleep doesn't * cause 'unlimited' sleep bonus. */ place_entity(cfs_rq, se, 0); check_vruntime(8, se, cfs_rq->min_vruntime); se->vruntime -= cfs_rq->min_vruntime;
Quoted 1 line
So here we subtract
min_vruntime,
When the p->state is TASK_WAKING, vruntime_normlized will return 1 and if(!vruntime_normalized(p)) will be 0
in this case, don't subtract min_vruntime.
Quoted 38 lines
Quoted 2 lines
se->normalized = true;this doesn't exist.. which makes me wonder what you're looking at,
Quoted 14 lines
} detach_entity_cfs_rq(se); }// when
p->stateisTASK_WAKING, the task's vruntime is normalized static inline boolvruntime_normalized(struct task_struct *p){
.....if (!se->sum_exec_runtime || p->state == TASK_WAKING) return true;}
Quoted 8 lines
2. When the task (A) which holds the
rt_muex_lockunlock thert_mutex_lock.Task (A) must be on_rq=1 rt_mutex_setprio (RT->CFS) if (queued) enqueue_task(rq, p, queue_flag); ); /* vruntime += cfs_rq.min_vruntime */And here we're adding
min_vruntime.Quoted 4 lines
if (running)
set_curr_task(rq, p);that result in vruntime accumulates
So what exactly is the problem?
Quoted 9 lines · Kathleen Chang
Quoted 6 lines · Peter Zijlstra
Quoted 3 lines · Kathleen Chang
hi,
We found the vruntime might update incorrectly when use
rt_mutex.That's nice, on what kernel?
kernel-4.9
Quoted 41 lines
Quoted 41 lines
Also, your email is very hard to make sense of.
Quoted 37 lines
<<abnormal case>>
When the Task is waking, update vruntime incorrectly.
1. When there is a CFS task (A) holdrt_mutex_lockand the state isTASK_WAKING(on_rq=0), a RT task (B) want to hold thisrt_mutex_lock. Update vruntime incorrectly.RT task (B)
rt_mutex_setprio (cfs->RT) -> Task is waking , and updatevruntime
queued = task_on_rq_queued(p); // task is waking, queued=0 running = task_current(rq, p); if (queued) /* don't update vruntime here! */ dequeue_task(rq, p, queue_flag); if (running) put_prev_task(rq, p); check_class_changed(rq, p, prev_class, oldprio); -> switched_from_fair -> detach_task_cfs_rq ( due to task is waking, and bypassvruntime-=cfs_rq.min_vruntime)
static void
detach_task_cfs_rq(struct task_struct *p){ struct sched_entity *se = &p->se; struct cfs_rq *cfs_rq = cfs_rq_of(se); if (!vruntime_normalized(p)) { // return 1, then p->state is TASK_WAKING /* * Fix up our vruntime so that the current sleep doesn't * cause 'unlimited' sleep bonus. */ place_entity(cfs_rq, se, 0); check_vruntime(8, se, cfs_rq->min_vruntime); se->vruntime -= cfs_rq->min_vruntime;
Quoted 2 lines
Quoted 1 line
So here we subtract
min_vruntime,
When the p->state is TASK_WAKING, vruntime_normlized will return 1 and if(!vruntime_normalized(p)) will be 0
in this case, doesn't subtract min_vruntime.
Quoted 32 lines
Quoted 32 lines
Quoted 4 lines
se->normalized = true;this doesn't exist.. which makes me wonder what you're looking at,
Quoted 14 lines
} detach_entity_cfs_rq(se); }// when
p->stateisTASK_WAKING, the task's vruntime is normalized static inline boolvruntime_normalized(struct task_struct *p){
.....if (!se->sum_exec_runtime || p->state == TASK_WAKING) return true;}
Quoted 8 lines
2. When the task (A) which holds the
rt_muex_lockunlock thert_mutex_lock.Task (A) must be on_rq=1 rt_mutex_setprio (RT->CFS) if (queued) enqueue_task(rq, p, queue_flag); ); /* vruntime += cfs_rq.min_vruntime */And here we're adding
min_vruntime.
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
if (running)
set_curr_task(rq, p);that result in vruntime accumulates
So what exactly is the problem?
When the p->state is TASK_WAKING, detach_task_cfs_rq doesn't subtract min_vruntime and adding min_vruntime in enqueue_task,
That result in vruntime accumulates to a extreme large number.