When a new thread handler is created, an irqaction is passed to it as data. Not only that irqaction is stored in task_struct by the handler for later use, but also a structure associated with the kernel thread keeps this value as long as the thread exists. This fix kicks irqaction out off task_struct. Yes, I introduce new bit field. But it allows not only to eliminate the duplicate, but also shortens size of task_struct.
Showing the changes to kernel (1 of 2 files). Show all
Unified · Split
| @@ -780,7 +780,7 @@ static int irq_thread(void *data) · 779 unmodified lines | ||
| 780 | 780 | handler_fn = irq_thread_fn; |
| 781 | 781 | |
| 782 | 782 | sched_setscheduler(current, SCHED_FIFO, ¶m); |
| 783 | − current->irqaction = action; | |
| 783 | + current->irq_thread = 1; | |
| 784 | 784 | |
| 785 | 785 | while (!irq_wait_for_interrupt(action)) { |
| 786 | 786 | |
| @@ -818,10 +818,10 @@ static int irq_thread(void *data) · 31 unmodified lines | ||
| 818 | 818 | irq_finalize_oneshot(desc, action, true); |
| 819 | 819 | |
| 820 | 820 | /* |
| 821 | − * Clear irqaction. Otherwise exit_irq_thread() would make | |
| 821 | + * Clear irq_thread. Otherwise exit_irq_thread() would make | |
| 822 | 822 | * fuzz about an active irq thread going into nirvana. |
| 823 | 823 | */ |
| 824 | − current->irqaction = NULL; | |
| 824 | + current->irq_thread = 0; | |
| 825 | 825 | return 0; |
| 826 | 826 | } |
| 827 | 827 | |
| @@ -832,27 +832,30 @@ void exit_irq_thread(void) · 4 unmodified lines | ||
| 832 | 832 | { |
| 833 | 833 | struct task_struct *tsk = current; |
| 834 | 834 | struct irq_desc *desc; |
| 835 | + struct irqaction *action; | |
| 835 | 836 | |
| 836 | − if (!tsk->irqaction) | |
| 837 | + if (!tsk->irq_thread) | |
| 837 | 838 | return; |
| 838 | 839 | |
| 840 | + action = kthread_data(tsk); | |
| 841 | + | |
| 839 | 842 | printk(KERN_ERR |
| 840 | 843 | "exiting task \"%s\" (%d) is an active IRQ thread (irq %d)\n", |
| 841 | − tsk->comm ? tsk->comm : "", tsk->pid, tsk->irqaction->irq); | |
| 844 | + tsk->comm ? tsk->comm : "", tsk->pid, action->irq); | |
| 842 | 845 | |
| 843 | − desc = irq_to_desc(tsk->irqaction->irq); | |
| 846 | + desc = irq_to_desc(action->irq); | |
| 844 | 847 | |
| 845 | 848 | /* |
| 846 | 849 | * Prevent a stale desc->threads_oneshot. Must be called |
| 847 | 850 | * before setting the IRQTF_DIED flag. |
| 848 | 851 | */ |
| 849 | − irq_finalize_oneshot(desc, tsk->irqaction, true); | |
| 852 | + irq_finalize_oneshot(desc, action, true); | |
| 850 | 853 | |
| 851 | 854 | /* |
| 852 | 855 | * Set the THREAD DIED flag to prevent further wakeups of the |
| 853 | 856 | * soon to be gone threaded handler. |
| 854 | 857 | */ |
| 855 | − set_bit(IRQTF_DIED, &tsk->irqaction->flags); | |
| 858 | + set_bit(IRQTF_DIED, &action->flags); | |
| 856 | 859 | } |
| 857 | 860 | |
| 858 | 861 | static void irq_setup_forced_threading(struct irqaction *new) |