Message ID | 20220802065325.39740-1-zhengqi.arch@bytedance.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] arm64: run softirqs on the per-CPU IRQ stack | expand |
On 2022/8/2 14:53, Qi Zheng wrote: > Currently arm64 supports per-CPU IRQ stack, but softirqs > are still handled in the task context. > > Since any call to local_bh_enable() at any level in the task's > call stack may trigger a softirq processing run, which could > potentially cause a task stack overflow if the combined stack > footprints exceed the stack's size, let's run these softirqs > on the IRQ stack as well. > > Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> > Reviewed-by: Arnd Bergmann <arnd@arndb.de> > Acked-by: Will Deacon <will@kernel.org> Hi Will, Are we good to merge it into 6.0-rc1? Thanks, Qi > --- > v1: https://lore.kernel.org/lkml/20220708094950.41944-1-zhengqi.arch@bytedance.com/ > RFC: https://lore.kernel.org/lkml/20220707110511.52129-1-zhengqi.arch@bytedance.com/ > > Changelog in v1 -> v2: > - temporarily discard [PATCH v1 2/2] to allow this patch to be merged first > - rebase onto the v5.19 > - collect Reviewed-by and Acked-by > > Changelog in RFC -> v1: > - fix conflicts with commit f2c5092190f2 ("arch/*: Disable softirq stacks on PREEMPT_RT.") > > arch/arm64/Kconfig | 1 + > arch/arm64/kernel/irq.c | 13 +++++++++++++ > 2 files changed, 14 insertions(+) > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index 1652a9800ebe..90f1ab403724 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -226,6 +226,7 @@ config ARM64 > select THREAD_INFO_IN_TASK > select HAVE_ARCH_USERFAULTFD_MINOR if USERFAULTFD > select TRACE_IRQFLAGS_SUPPORT > + select HAVE_SOFTIRQ_ON_OWN_STACK > help > ARM 64-bit (AArch64) Linux support. > > diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c > index bda49430c9ea..c36ad20a52f3 100644 > --- a/arch/arm64/kernel/irq.c > +++ b/arch/arm64/kernel/irq.c > @@ -22,6 +22,7 @@ > #include <linux/vmalloc.h> > #include <asm/daifflags.h> > #include <asm/vmap_stack.h> > +#include <asm/exception.h> > > /* Only access this in an NMI enter/exit */ > DEFINE_PER_CPU(struct nmi_ctx, nmi_contexts); > @@ -71,6 +72,18 @@ static void init_irq_stacks(void) > } > #endif > > +#ifndef CONFIG_PREEMPT_RT > +static void ____do_softirq(struct pt_regs *regs) > +{ > + __do_softirq(); > +} > + > +void do_softirq_own_stack(void) > +{ > + call_on_irq_stack(NULL, ____do_softirq); > +} > +#endif > + > static void default_handle_irq(struct pt_regs *regs) > { > panic("IRQ taken without a root IRQ handler\n");
On Fri, Aug 5, 2022 at 9:10 AM Qi Zheng <zhengqi.arch@bytedance.com> wrote: > On 2022/8/2 14:53, Qi Zheng wrote: > > Currently arm64 supports per-CPU IRQ stack, but softirqs > > are still handled in the task context. > > > > Since any call to local_bh_enable() at any level in the task's > > call stack may trigger a softirq processing run, which could > > potentially cause a task stack overflow if the combined stack > > footprints exceed the stack's size, let's run these softirqs > > on the IRQ stack as well. > > > > Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> > > Reviewed-by: Arnd Bergmann <arnd@arndb.de> > > Acked-by: Will Deacon <will@kernel.org> > > Are we good to merge it into 6.0-rc1? I think you misunderstood the timing that Will proposed in https://lore.kernel.org/linux-arm-kernel/d540aaff-ec6a-3f25-dd79-b27b4ad81b36@bytedance.com/ You should send your patch after 6.0-rc1 has been released, to be merged into the linux-next tree and sent as part of the 6.1 merge window. The two ways patches get merged are: - bugfixes can get merged into maintainer trees at any time and sent upstream regardless of the merge window, these never need to wait - non-bugfix patches can get merged into maintainer trees based on an -rc release and then sent upstream during the following merge window. Arnd
On 2022/8/5 15:50, Arnd Bergmann wrote: > On Fri, Aug 5, 2022 at 9:10 AM Qi Zheng <zhengqi.arch@bytedance.com> wrote: >> On 2022/8/2 14:53, Qi Zheng wrote: >>> Currently arm64 supports per-CPU IRQ stack, but softirqs >>> are still handled in the task context. >>> >>> Since any call to local_bh_enable() at any level in the task's >>> call stack may trigger a softirq processing run, which could >>> potentially cause a task stack overflow if the combined stack >>> footprints exceed the stack's size, let's run these softirqs >>> on the IRQ stack as well. >>> >>> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> >>> Reviewed-by: Arnd Bergmann <arnd@arndb.de> >>> Acked-by: Will Deacon <will@kernel.org> >> >> Are we good to merge it into 6.0-rc1? > > I think you misunderstood the timing that Will proposed in > > https://lore.kernel.org/linux-arm-kernel/d540aaff-ec6a-3f25-dd79-b27b4ad81b36@bytedance.com/ > > You should send your patch after 6.0-rc1 has been released, to be merged > into the linux-next tree and sent as part of the 6.1 merge window. Oh, got it. I will repost it after 6.0-rc1. > > The two ways patches get merged are: > > - bugfixes can get merged into maintainer trees at any time and sent > upstream regardless of the merge window, these never need to wait > > - non-bugfix patches can get merged into maintainer trees based on an > -rc release and then sent upstream during the following merge window. Thanks for such detailed information. :) > > Arnd Thanks, Qi
Hi Qi, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on soc/for-next] [also build test WARNING on v5.19] [cannot apply to arm64/for-next/core linus/master next-20220805] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Qi-Zheng/arm64-run-softirqs-on-the-per-CPU-IRQ-stack/20220802-145547 base: https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next config: arm64-randconfig-r032-20220801 (https://download.01.org/0day-ci/archive/20220807/202208072125.pTMPctXF-lkp@intel.com/config) compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 52cd00cabf479aa7eb6dbb063b7ba41ea57bce9e) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install arm64 cross compiling tool for clang build # apt-get install binutils-aarch64-linux-gnu # https://github.com/intel-lab-lkp/linux/commit/34ac9375ce5e75127084159f724fcb2208c022a3 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Qi-Zheng/arm64-run-softirqs-on-the-per-CPU-IRQ-stack/20220802-145547 git checkout 34ac9375ce5e75127084159f724fcb2208c022a3 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash arch/arm64/kernel/ If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> arch/arm64/kernel/irq.c:81:6: warning: no previous prototype for function 'do_softirq_own_stack' [-Wmissing-prototypes] void do_softirq_own_stack(void) ^ arch/arm64/kernel/irq.c:81:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void do_softirq_own_stack(void) ^ static arch/arm64/kernel/irq.c:120:13: warning: no previous prototype for function 'init_IRQ' [-Wmissing-prototypes] void __init init_IRQ(void) ^ arch/arm64/kernel/irq.c:120:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void __init init_IRQ(void) ^ static 2 warnings generated. vim +/do_softirq_own_stack +81 arch/arm64/kernel/irq.c 80 > 81 void do_softirq_own_stack(void) 82 { 83 call_on_irq_stack(NULL, ____do_softirq); 84 } 85 #endif 86
Hi Qi, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on soc/for-next] [also build test WARNING on v5.19] [cannot apply to arm64/for-next/core linus/master next-20220805] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Qi-Zheng/arm64-run-softirqs-on-the-per-CPU-IRQ-stack/20220802-145547 base: https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next config: arm64-randconfig-r024-20220801 (https://download.01.org/0day-ci/archive/20220807/202208072123.sWU13g72-lkp@intel.com/config) compiler: aarch64-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/34ac9375ce5e75127084159f724fcb2208c022a3 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Qi-Zheng/arm64-run-softirqs-on-the-per-CPU-IRQ-stack/20220802-145547 git checkout 34ac9375ce5e75127084159f724fcb2208c022a3 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash arch/arm64/kernel/ If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> arch/arm64/kernel/irq.c:81:6: warning: no previous prototype for 'do_softirq_own_stack' [-Wmissing-prototypes] 81 | void do_softirq_own_stack(void) | ^~~~~~~~~~~~~~~~~~~~ arch/arm64/kernel/irq.c:120:13: warning: no previous prototype for 'init_IRQ' [-Wmissing-prototypes] 120 | void __init init_IRQ(void) | ^~~~~~~~ vim +/do_softirq_own_stack +81 arch/arm64/kernel/irq.c 80 > 81 void do_softirq_own_stack(void) 82 { 83 call_on_irq_stack(NULL, ____do_softirq); 84 } 85 #endif 86
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 1652a9800ebe..90f1ab403724 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -226,6 +226,7 @@ config ARM64 select THREAD_INFO_IN_TASK select HAVE_ARCH_USERFAULTFD_MINOR if USERFAULTFD select TRACE_IRQFLAGS_SUPPORT + select HAVE_SOFTIRQ_ON_OWN_STACK help ARM 64-bit (AArch64) Linux support. diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c index bda49430c9ea..c36ad20a52f3 100644 --- a/arch/arm64/kernel/irq.c +++ b/arch/arm64/kernel/irq.c @@ -22,6 +22,7 @@ #include <linux/vmalloc.h> #include <asm/daifflags.h> #include <asm/vmap_stack.h> +#include <asm/exception.h> /* Only access this in an NMI enter/exit */ DEFINE_PER_CPU(struct nmi_ctx, nmi_contexts); @@ -71,6 +72,18 @@ static void init_irq_stacks(void) } #endif +#ifndef CONFIG_PREEMPT_RT +static void ____do_softirq(struct pt_regs *regs) +{ + __do_softirq(); +} + +void do_softirq_own_stack(void) +{ + call_on_irq_stack(NULL, ____do_softirq); +} +#endif + static void default_handle_irq(struct pt_regs *regs) { panic("IRQ taken without a root IRQ handler\n");