Книга: Embedded Linux Primer: A Practical, Real-World Approach

17.3.1.3. Preemptable Softirqs

17.3.1.3. Preemptable Softirqs

CONFIG_PREEMPT_SOFTIRQ reduces latency by running softirqs within the context of the kernel's softirq daemon (ksoftirqd). ksoftirqd is a proper Linux task (process). As such, it can be prioritized and scheduled along with other tasks. If your kernel is configured for real time, and CONFIG_PREEMPT_SOFTIRQ is enabled, the ksoftirqd kernel task is elevated to real-time priority to handle the softirq processing.[119] Listing 17-3 shows the code responsible for this from a recent Linux kernel, found in .../kernel/softirq.c.

Listing 17-3. Promoting ksoftirq to Real-Time Status

static int ksoftirqd(void * __bind_cpu) {
 struct sched_param param = { .sched_priority = 24 };
 printk("ksoftirqd started up.n");
#ifdef CONFIG_PREEMPT_SOFTIRQS
 printk("softirq RT prio: %d.n", param.sched_priority);
 sys_sched_setscheduler(current->pid, SCHED_FIFO, &param);
#else
 set_user_nice(current, -10);
#endif
...

Here we see that if CONFIG_PREEMPT_SOFTIRQS is enabled in the kernel configuration, the ksoftirqd kernel task is promoted to a real-time task (SCHED_FIFO) at a real-time priority of 24 using the sys_sched_setscheduler() kernel function.

SoftIRQ threading can be disabled at runtime through the /proc file system, as well as through the kernel command line at boot time. When enabled in the configuration, unless you specify otherwise, SoftIRQ threading is enabled by default. To disable SoftIRQ threading at runtime, issue the following command as root:

# echo '0' >/proc/sys/kernel/softirq_preemption

To verify the setting, display it as follows:

# cat /proc/sys/kernel/softirq_preemption
1

To disable SoftIRQ threading at boot time, add the following parameter to the kernel command line:

softirq-preempt=0

Оглавление книги


Генерация: 2.088. Запросов К БД/Cache: 3 / 1
поделиться
Вверх Вниз