From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753205AbbIPLZX (ORCPT ); Wed, 16 Sep 2015 07:25:23 -0400 Received: from foss.arm.com ([217.140.101.70]:55033 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752196AbbIPLZT (ORCPT ); Wed, 16 Sep 2015 07:25:19 -0400 Date: Wed, 16 Sep 2015 12:25:21 +0100 From: Will Deacon To: Jungseok Lee Cc: Catalin Marinas , "linux-arm-kernel@lists.infradead.org" , "takahiro.akashi@linaro.org" , Mark Rutland , "linux-kernel@vger.kernel.org" , James Morse Subject: Re: [PATCH v2] arm64: Introduce IRQ stack Message-ID: <20150916112520.GH28771@arm.com> References: <1442155337-7020-1-git-send-email-jungseoklee85@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442155337-7020-1-git-send-email-jungseoklee85@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 13, 2015 at 03:42:17PM +0100, Jungseok Lee wrote: > Currently, kernel context and interrupts are handled using a single > kernel stack navigated by sp_el1. This forces many systems to use > 16KB stack, not 8KB one. Low memory platforms naturally suffer from > memory pressure accompanied by performance degradation. > > This patch addresses the issue as introducing a separate percpu IRQ > stack to handle both hard and soft interrupts with two ground rules: > > - Utilize sp_el0 in EL1 context, which is not used currently > - Do not complicate current_thread_info calculation > > It is a core concept to trace struct thread_info using sp_el0 instead > of sp_el1. This approach helps arm64 align with other architectures > regarding object_is_on_stack() without additional complexity. > > Cc: James Morse > Signed-off-by: Jungseok Lee > --- > Changes since v1: > - Rebased on top of v4.3-rc1 > - Removed Kconfig about IRQ stack, per James > - Used PERCPU for IRQ stack, per James > - Tried to allocate IRQ stack when CPU is about to start up, per James > - Moved sp_el0 update into kernel_entry macro, per James > - Dropped S_SP removal patch, per Mark and James > > arch/arm64/include/asm/irq.h | 8 +++ > arch/arm64/include/asm/thread_info.h | 7 +- > arch/arm64/kernel/asm-offsets.c | 5 ++ > arch/arm64/kernel/entry.S | 54 ++++++++++++++-- > arch/arm64/kernel/head.S | 3 + > arch/arm64/kernel/irq.c | 21 ++++++ > arch/arm64/kernel/smp.c | 6 ++ > 7 files changed, 95 insertions(+), 9 deletions(-) > > diff --git a/arch/arm64/include/asm/irq.h b/arch/arm64/include/asm/irq.h > index bbb251b..67975a2 100644 > --- a/arch/arm64/include/asm/irq.h > +++ b/arch/arm64/include/asm/irq.h > @@ -5,11 +5,19 @@ > > #include > > +struct irq_stack { > + void *stack; > + unsigned long thread_sp; > + unsigned int count; > +}; > + > struct pt_regs; > > extern void migrate_irqs(void); > extern void set_handle_irq(void (*handle_irq)(struct pt_regs *)); > > +extern int alloc_irq_stack(unsigned int cpu); > + > static inline void acpi_irq_init(void) > { > /* > diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h > index dcd06d1..44839c0 100644 > --- a/arch/arm64/include/asm/thread_info.h > +++ b/arch/arm64/include/asm/thread_info.h > @@ -73,8 +73,11 @@ static inline struct thread_info *current_thread_info(void) __attribute_const__; > > static inline struct thread_info *current_thread_info(void) > { > - return (struct thread_info *) > - (current_stack_pointer & ~(THREAD_SIZE - 1)); > + unsigned long sp_el0; > + > + asm volatile("mrs %0, sp_el0" : "=r" (sp_el0)); > + > + return (struct thread_info *)(sp_el0 & ~(THREAD_SIZE - 1)); This looks like it will generate worse code than our current implementation, thanks to the asm volatile. Maybe just add something like a global current_stack_pointer_el0? Will