RFC: genirq: allow userspace to set default priority of irq threads
PATCH 1/1 RFC: genirq: allow userspace to set default priority of irq threads
On -rt kernels, it is sometimes desirable to be able to prioritize some hardware interrupts over others, i.e. being able to set the priorities of the irq threads different from the default of 50. While chrt(1) can be used after the threads are created, there are at least two problems with that: (1) threads are created and destroyed as devices are brought up and down, making it necessary to continuously monitor /proc for new irq threads, leading to (2) a device may run for a while with its irq thread(s) at the wrong priority.
This is just a quick POC to start some discussion. Probably the locking is all wrong. But this at least gives userspace a way of assigning a priority to a specific hardware interrupt by matching on the chip_name and hwirq - unfortunately, chip_name is not necessarily unique, so it doesn't work for all cases.
This would probably be a better fit in /proc alongside the affinity settings, but the problem with that is that the /proc entries don't exist until __setup_irq() is called the first time. [Btw, why are the sysfs files dependent on CONFIG_SPARSE_IRQ?]
--- include/linux/irqdesc.h | 2 ++ kernel/irq/irqdesc.c | 57 +++++++++++++++++++++++++++++++++++++++++ kernel/irq/manage.c | 11 ++++---- 3 files changed, 64 insertions(+), 6 deletions(-)
include/linux/irqdesc.h +2 -0
@@ -5,6 +5,7 @@#include <linux/rcupdate.h> #include <linux/kobject.h> #include <linux/mutex.h> +#include <uapi/linux/sched/types.h> /* * Core internal functions to deal with irq descriptors
@@ -106,6 +107,7 @@ struct irq_desc {int parent_irq;struct module *owner;const char *name; +struct sched_param sched_param; }____cacheline_internodealigned_in_smp ;#ifdef CONFIG_SPARSE_IRQ
kernel/irq/irqdesc.c +57 -0
81 lines not on this page · raw message
kernel/irq/manage.c +5 -6
@@ -1203,12 +1203,11 @@ static void irq_nmi_teardown(struct irq_desc *desc) }static int -setup_irq_thread (struct irqaction *new,unsigned int irq,bool secondary) +setup_irq_thread (struct irqaction *new,struct irq_desc *desc,bool secondary) { +struct sched_param param = desc->sched_param; +unsigned int irq =irq_desc_get_irq (desc);struct task_struct *t; -struct sched_param param = { - .sched_priority =MAX_USER_RT_PRIO /2 , - };if (!secondary) { t = kthread_create(irq_thread, new, "irq/%d-%s", irq,
@@ -1312,11 +1311,11 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)* thread. */ if (new->thread_fn && !nested) { - ret =setup_irq_thread (new, irq, false); + ret =setup_irq_thread (new, desc, false);if (ret) goto out_mput;if (new->secondary) { - ret =setup_irq_thread (new->secondary, irq, true); + ret =setup_irq_thread (new->secondary, desc, true);if (ret) goto out_thread; }
Signature · 1 line
2.20.1