Linsched
Linsched
John M. Calandrino Dan P. Baumberger, Tong Li, Jessica C. Young, and Scott Hahn
Department of Computer Science Systems Technology Lab
The University of North Carolina Intel Corporation
Chapel Hill, NC 27599 Hillsboro, OR 97124
scheduler tick() function at every (periodic) timer API that can be used
Environment
that uses the simulation engine API to run a LinSched sim- /* Create 3 normal tasks with nice value 0. */
ulation, and Sec. 3.2 presents experimental results. 5 linsched_create_normal_task(&ls_annc_cb, 0);
6 linsched_create_normal_task(&ls_annc_cb, 0);
7 linsched_create_normal_task(&ls_annc_cb, 0);
3.1 Running a LinSched Simulation /* Create one normal task (nice value -5), batch task, and FIFO task. */
8 linsched_create_normal_task(&ls_annc_cb, -5);
Fig. 2 shows a sample C program that uses the simulation 9 linsched_create_batch_task(&ls_annc_cb, 1);
engine API to create a workload and run a LinSched sim- 10 linsched_create_RTfifo_task(&ls_annc_cb, 90);
ulation. The workload consists of seven tasks: three “nor- /* Run simulation for LINSCHED TICKS ticks (in linsched.h). */
mal” tasks with a nice value of zero, one normal task with 11 linsched_run_sim(LINSCHED_TICKS);
a nice value of -5, one batch task with a nice value of 1, /* Create round-robin task. */
one real-time FIFO task with priority 90, and one round- 12 linsched_create_RTrr_task(&ls_annc_cb, 80);
robin real-time task with priority 80.∗ Each task is cre- /* Run simulation for LINSCHED TICKS additional ticks. */
ated by a function with two arguments: a pointer to a call- 13 linsched_run_sim(LINSCHED_TICKS);
back function and the task nice value or priority. The func- 14 return 0;
tion ls annc cb() is a callback that displays a message 15 }
whenever the task is scheduled on a CPU. This callback Figure 2: A sample LinSched simulation program.
allows us to generate a trace of scheduling behavior that
can be parsed and analyzed—in experiments discussed in representing the following task sets, each of which was run
Sec. 3.2, we do exactly that when determining how well for one minute (simulated in LinSched).
LinSched behavior correlates with the Linux scheduler. (a) All normal tasks with a nice value of zero.
After task creation, we run the simulation for 2 ∗ (b) All normal tasks—tasks 1 through 40 have nice val-
LINSCHED TICKS ticks. Note that it is easy to create ues from -20 to 19, respectively. (Lower nice values
new tasks that begin execution at some time after the sim- indicate higher priority.)
ulation has begun. In this program, the round-robin task is (c) Half batch tasks and half normal tasks. Tasks 1-10 and
not introduced into the system until the simulation is 50% 11-20 are batch tasks with nice values of 0 and 10,
complete, since we run the simulation for equal numbers of respectively. Tasks 21-30 and 31-40 are normal tasks
ticks before and after the task is created. (We could also in- with nice values of 0 and 10, respectively.
troduce new tasks by modifying linsched run sim() (d) Three real-time tasks, and 37 normal tasks: one FIFO
directly.) Note that actual scheduling behavior is deter- real-time task with priority 90, two round-robin real-
mined by the Linux functions scheduler tick() and time tasks with priority 80, and 37 normal tasks with
schedule(), among others—in this case, these func- nice value 0. (Lower values indicate higher priority,
tions implement the normal 2.6.23 scheduling policies. and real-time tasks are prioritized over other tasks.)
All tasks used the ls annc cb() callback described in
3.2 Experimental Results Sec. 3.1, thus a trace of scheduling decisions was gener-
We now present the results of experiments that demonstrate ated. Tasks executed indefinitely (e.g., in an infinite loop).
how well scheduling decisions within LinSched correlate Results. The results of the first set of experiments are
with the behavior of the Linux scheduler, and how well Lin- shown in Fig. 3, where the processor time received by each
Sched models scheduling behavior on larger platforms. task is presented within both the Linux kernel and Lin-
In our first set of experiments, we compared the schedul- Sched. In Fig. 3, insets (a) through (d) correspond to task
ing behavior of Linux 2.6.23 running on an SMP machine sets (a) through (d) above. Tasks were “mapped” to iden-
containing four Intel Xeon 2.7 GHz processors to similarly tical identifiers (1 through 40) so that their behavior within
configured LinSched simulations. The kernel was modi- Linux and LinSched can be directly compared easily.
fied to allow a trace of scheduling activities to be obtained Overall, LinSched produces results that are highly cor-
in a relatively light-weight manner (first used in [2]), and a related with the scheduler behavior of Linux—external in-
user-space program was created to launch tasks. terference within the Linux kernel (e.g., due to interrupts
We considered four different workloads in this first set of or the tracing infrastructure) accounts for the largest differ-
experiments. These workloads consisted of 40 tasks each, ences. Where the behavior of LinSched deviates from the
∗ More information on the types of tasks described here is available Linux scheduler, it tends to achieve results that better ap-
by typing man sched setscheduler at any Linux terminal running proximate intended scheduler behavior. For example, in in-
kernel version 2.6.16 or later. set (a), all tasks have identical priorities, and should achieve
7
9
x 10
Identical Nice Values
LinSched
5
x 10
10 Varying Nice Values
LinSched
4 Conclusion
Linux Linux
6.5
4 Understanding and experimenting with the Linux scheduler
can often be a frustrating or time-consuming process, espe-
Run Time (ns)
4
LinSched models Symposium. IEEE, 2008.
3
scheduler behavior on [3] John M. Calandrino, Dan Baumberger, Tong Li, Scott Hahn,
2