Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched/fair: Do not special case tasks in throttled hierarchy

With the introduction of task based throttle model, task in a throttled
hierarchy is allowed to continue to run till it gets throttled on its
ret2user path.

For this reason, remove those throttled_hierarchy() checks in the
following functions so that those tasks can get their turn as normal
tasks: dequeue_entities(), check_preempt_wakeup_fair() and
yield_to_task_fair().

The benefit of doing it this way is: if those tasks gets the chance to
run earlier and if they hold any kernel resources, they can release
those resources earlier. The downside is, if they don't hold any kernel
resouces, all they can do is to throttle themselves on their way back to
user space so the favor to let them run seems not that useful and for
check_preempt_wakeup_fair(), that favor may be bad for curr.

K Prateek Nayak pointed out prio_changed_fair() can send a throttled
task to check_preempt_wakeup_fair(), further tests showed the affinity
change path from move_queued_task() can also send a throttled task to
check_preempt_wakeup_fair(), that's why the check of task_is_throttled()
in that function.

Signed-off-by: Aaron Lu <ziqianlu@bytedance.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>

authored by

Aaron Lu and committed by
Peter Zijlstra
253b3f58 fcd39486

+4 -4
+4 -4
kernel/sched/fair.c
··· 7081 7081 * Bias pick_next to pick a task from this cfs_rq, as 7082 7082 * p is sleeping when it is within its sched_slice. 7083 7083 */ 7084 - if (task_sleep && se && !throttled_hierarchy(cfs_rq)) 7084 + if (task_sleep && se) 7085 7085 set_next_buddy(se); 7086 7086 break; 7087 7087 } ··· 8735 8735 * lead to a throttle). This both saves work and prevents false 8736 8736 * next-buddy nomination below. 8737 8737 */ 8738 - if (unlikely(throttled_hierarchy(cfs_rq_of(pse)))) 8738 + if (task_is_throttled(p)) 8739 8739 return; 8740 8740 8741 8741 if (sched_feat(NEXT_BUDDY) && !(wake_flags & WF_FORK) && !pse->sched_delayed) { ··· 9009 9009 { 9010 9010 struct sched_entity *se = &p->se; 9011 9011 9012 - /* throttled hierarchies are not runnable */ 9013 - if (!se->on_rq || throttled_hierarchy(cfs_rq_of(se))) 9012 + /* !se->on_rq also covers throttled task */ 9013 + if (!se->on_rq) 9014 9014 return false; 9015 9015 9016 9016 /* Tell the scheduler that we'd really like se to run next. */