diff mbox series

[4/7] arm64: Add fast-path for stack alignment

Message ID 1537970184-44348-5-git-send-email-julien.thierry@arm.com (mailing list archive)
State New, archived
Headers show
Series Ensure stack is aligned for kernel entries | expand

Commit Message

Julien Thierry Sept. 26, 2018, 1:56 p.m. UTC
Avoiding stack alignment for already aligned stack can give a small
performance boost.

Branch out of the aligning code when the stack is known to be aligned.

Signed-off-by: Julien Thierry <julien.thierry@arm.com>
---
 arch/arm64/kernel/entry.S | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Will Deacon Nov. 7, 2018, 9:59 p.m. UTC | #1
On Wed, Sep 26, 2018 at 02:56:21PM +0100, Julien Thierry wrote:
> Avoiding stack alignment for already aligned stack can give a small
> performance boost.
> 
> Branch out of the aligning code when the stack is known to be aligned.
> 
> Signed-off-by: Julien Thierry <julien.thierry@arm.com>
> ---
>  arch/arm64/kernel/entry.S | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
> index 8fb66e4..bd8d52c 100644
> --- a/arch/arm64/kernel/entry.S
> +++ b/arch/arm64/kernel/entry.S
> @@ -61,6 +61,10 @@
>  
>  	.macro force_stack_align
>  	xchg_sp	x0
> +
> +	tst	x0, #0xf
> +	b.eq	0f
> +
>  	str	x1, [x0] // store x1 far away from S_SP
>  
>  	// aligned_sp[S_SP] = old_sp
> @@ -69,6 +73,11 @@
>  
>  	ldr	x1, [x0]
>  	bic	x0, x0, #0xf	// x0 = aligned_sp
> +	b	1f
> +
> +0:
> +	str	x0, [x0, #S_SP]
> +1:

I couldn't figure out a better way to do this, but please remove the empty
lines that you're adding here. With that:

Acked-by: Will Deacon <will.deacon@arm.com>

Will
Julien Thierry Nov. 8, 2018, 12:21 p.m. UTC | #2
On 07/11/18 21:59, Will Deacon wrote:
> On Wed, Sep 26, 2018 at 02:56:21PM +0100, Julien Thierry wrote:
>> Avoiding stack alignment for already aligned stack can give a small
>> performance boost.
>>
>> Branch out of the aligning code when the stack is known to be aligned.
>>
>> Signed-off-by: Julien Thierry <julien.thierry@arm.com>
>> ---
>>   arch/arm64/kernel/entry.S | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
>> index 8fb66e4..bd8d52c 100644
>> --- a/arch/arm64/kernel/entry.S
>> +++ b/arch/arm64/kernel/entry.S
>> @@ -61,6 +61,10 @@
>>   
>>   	.macro force_stack_align
>>   	xchg_sp	x0
>> +
>> +	tst	x0, #0xf
>> +	b.eq	0f
>> +
>>   	str	x1, [x0] // store x1 far away from S_SP
>>   
>>   	// aligned_sp[S_SP] = old_sp
>> @@ -69,6 +73,11 @@
>>   
>>   	ldr	x1, [x0]
>>   	bic	x0, x0, #0xf	// x0 = aligned_sp
>> +	b	1f
>> +
>> +0:
>> +	str	x0, [x0, #S_SP]
>> +1:
> 
> I couldn't figure out a better way to do this, but please remove the empty
> lines that you're adding here. With that:
> 

Sure, I'll do that.

> Acked-by: Will Deacon <will.deacon@arm.com>
> 

Thanks,
diff mbox series

Patch

diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index 8fb66e4..bd8d52c 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -61,6 +61,10 @@ 
 
 	.macro force_stack_align
 	xchg_sp	x0
+
+	tst	x0, #0xf
+	b.eq	0f
+
 	str	x1, [x0] // store x1 far away from S_SP
 
 	// aligned_sp[S_SP] = old_sp
@@ -69,6 +73,11 @@ 
 
 	ldr	x1, [x0]
 	bic	x0, x0, #0xf	// x0 = aligned_sp
+	b	1f
+
+0:
+	str	x0, [x0, #S_SP]
+1:
 	xchg_sp	x0
 	.endm