lkml.org 
[lkml]   [2018]   [Apr]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: What's the priority of the idle task?
On Tue, 03 Apr 2018, Ferenc Wágner wrote:
> As explained by several (if somewhat old) articles [2,3,4], the Linux
> idle task (PID=0, one per CPU) is run when there are no other tasks to
> run. To get the scheduler do this, the idle task must have the lowest
> priority reserved for it. That old Documentation/ftrace.txt in the
> linked LWN article explicitly says that
>
> > The prio "140" is reserved for the idle task which is the lowest
> > priority thread (pid 0).
>
> This makes sense, but under Linux 4.9
>
> # perf record -e sched:sched_switch sleep 1
> # perf script
> sleep 6526 [000] 362661.310842: sched:sched_switch: sleep:6526 [120] S ==> swapper/0:0 [120]
>
> reports a priority of 120 for swapper/0 (in the closing bracket),
> contradicting the above.
>
> How does the Linux scheduler handle the idle task nowadays? The commits
> removing the quoted text from ftrace.txt (87d80de28, 294ae4011) didn't
> help.

The idle task has its own scheduling class that only handles the idle threads per CPU
core. This scheduling class has the lowest priority of the scheduling classes
available in the kernel. This means that it is the last one in the list of scheduling
classes that are asked at a task switch whether they have a task to schedule on the
CPU. Hence, the idle task is not managed by CFS and accordingly doesn't have any nice
value or priority (or at least it is not important nowadays). Interesting files in
the kernel source that might contain more information are kernel/sched/idle_task.c,
kernel/sched/sched.h and kernel/sched/core.c.

Regards
Till

\
 
 \ /
  Last update: 2018-04-04 16:38    [W:0.046 / U:9.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site