Re: [PATCH -tip] sched/rt: Fix locality of threaded interrupthandlers

From: Thomas Gleixner
Date: Mon Jan 14 2013 - 06:19:42 EST


On Fri, 11 Jan 2013, Alexander Gordeev wrote:

> When a interrupt affinity mask targets multiple CPUs, the
> RT scheduler selects a runqueue for RT task corresponding
> to a threaded interrupt handler without consideration of
> where the interrupt is actually gets delivered. It leads
> to a suboptimal condition when a hardware interrupt handler
> executes on one CPU while the threaded interrupt handler
> executes on another CPU.
>
> This fix alters the behaviour of threaded handler wake-ups
> by getting priority to a CPU where the hardware interrupt
> handler is executing. As result, most of the time both
> halves of interrupt handling are kept local.

Nice one.

> Signed-off-by: Alexander Gordeev <agordeev@xxxxxxxxxx>
> ---
> include/linux/sched.h | 2 ++
> kernel/irq/handle.c | 2 +-
> kernel/sched/core.c | 5 +++++
> kernel/sched/rt.c | 27 +++++++++++++++++++--------
> 4 files changed, 27 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 206bb08..cd9cb42 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1061,6 +1061,7 @@ struct sched_domain;
> #define WF_SYNC 0x01 /* waker goes to sleep after wakup */
> #define WF_FORK 0x02 /* child wakeup after fork */
> #define WF_MIGRATED 0x04 /* internal use, task got migrated */
> +#define WF_INTR 0x08 /* threaded handler wakeup from intr */

Please make this WF_LOCAL or something like that. There is no point to
tie this functionality to interrupt threads. The scheduler does not
care at all.

> #define ENQUEUE_WAKEUP 1
> #define ENQUEUE_HEAD 2
> @@ -2207,6 +2208,7 @@ extern void xtime_update(unsigned long ticks);
>
> extern int wake_up_state(struct task_struct *tsk, unsigned int state);
> extern int wake_up_process(struct task_struct *tsk);
> +extern int wake_up_handler(struct task_struct *tsk);
> extern void wake_up_new_task(struct task_struct *tsk);
> #ifdef CONFIG_SMP
> extern void kick_process(struct task_struct *tsk);
> diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
> index 131ca17..79456b1 100644
> --- a/kernel/irq/handle.c
> +++ b/kernel/irq/handle.c
> @@ -126,7 +126,7 @@ static void irq_wake_thread(struct irq_desc *desc, struct irqaction *action)
> */
> atomic_inc(&desc->threads_active);
>
> - wake_up_process(action->thread);
> + wake_up_handler(action->thread);

wake_up_local() or something more generic than wake_up_handler().

Otherwise looks good.

Thanks,

tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/