Re: [patch V6 08/37] x86/entry/64: Move do_softirq_own_stack() to C

From: Andy Lutomirski
Date: Mon May 18 2020 - 19:49:11 EST


On Fri, May 15, 2020 at 5:10 PM Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
>
>
> The first step to get rid of the ENTER/LEAVE_IRQ_STACK ASM macro maze. Use
> the new C code helpers to move do_softirq_own_stack() out of ASM code.
>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
>
> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> index 3b8da9f09297..bdf8391b2f95 100644
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -1145,19 +1145,6 @@ SYM_FUNC_START(asm_call_on_stack)
> ret
> SYM_FUNC_END(asm_call_on_stack)
>
> -/* Call softirq on interrupt stack. Interrupts are off. */
> -.pushsection .text, "ax"
> -SYM_FUNC_START(do_softirq_own_stack)
> - pushq %rbp
> - mov %rsp, %rbp
> - ENTER_IRQ_STACK regs=0 old_rsp=%r11
> - call __do_softirq
> - LEAVE_IRQ_STACK regs=0
> - leaveq
> - ret
> -SYM_FUNC_END(do_softirq_own_stack)
> -.popsection
> -
> #ifdef CONFIG_XEN_PV
> /*
> * A note on the "critical region" in our callback handler.
> diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
> index 12df3a4abfdd..62cff52e03c5 100644
> --- a/arch/x86/kernel/irq_64.c
> +++ b/arch/x86/kernel/irq_64.c
> @@ -20,6 +20,7 @@
> #include <linux/sched/task_stack.h>
>
> #include <asm/cpu_entry_area.h>
> +#include <asm/irq_stack.h>
> #include <asm/io_apic.h>
> #include <asm/apic.h>
>
> @@ -70,3 +71,11 @@ int irq_init_percpu_irqstack(unsigned int cpu)
> return 0;
> return map_irq_stack(cpu);
> }
> +
> +void do_softirq_own_stack(void)
> +{
> + if (irqstack_active())
> + __do_softirq();
> + else
> + run_on_irqstack(__do_softirq, NULL);
> +}

See my comment in patch 8. I see no great reason that this should
open-code the conditional, except maybe that we don't have pt_regs
here so the condition needs to be a bit different.