2022-05-22 22:04:53

by andrey.konovalov

[permalink] [raw]
Subject: [PATCH 2/2] arm64: stacktrace: use non-atomic __set_bit

From: Andrey Konovalov <[email protected]>

Use the non-atomic version of set_bit() in arch/arm64/kernel/stacktrace.c,
as there is no concurrent accesses to frame->prev_type.

This speeds up stack trace collection and improves the boot time of
Generic KASAN by 2-5%.

Suggested-by: Mark Rutland <[email protected]>
Signed-off-by: Andrey Konovalov <[email protected]>
---
arch/arm64/kernel/stacktrace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c
index 33e96ae4b15f..03593d451b0a 100644
--- a/arch/arm64/kernel/stacktrace.c
+++ b/arch/arm64/kernel/stacktrace.c
@@ -103,7 +103,7 @@ static int notrace unwind_frame(struct task_struct *tsk,
if (fp <= frame->prev_fp)
return -EINVAL;
} else {
- set_bit(frame->prev_type, frame->stacks_done);
+ __set_bit(frame->prev_type, frame->stacks_done);
}

/*
--
2.25.1



2022-05-23 11:35:50

by Mark Rutland

[permalink] [raw]
Subject: Re: [PATCH 2/2] arm64: stacktrace: use non-atomic __set_bit

On Sun, May 22, 2022 at 01:50:59AM +0200, [email protected] wrote:
> From: Andrey Konovalov <[email protected]>
>
> Use the non-atomic version of set_bit() in arch/arm64/kernel/stacktrace.c,
> as there is no concurrent accesses to frame->prev_type.
>
> This speeds up stack trace collection and improves the boot time of
> Generic KASAN by 2-5%.
>
> Suggested-by: Mark Rutland <[email protected]>
> Signed-off-by: Andrey Konovalov <[email protected]>

Acked-by: Mark Rutland <[email protected]>

Mark.

> ---
> arch/arm64/kernel/stacktrace.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c
> index 33e96ae4b15f..03593d451b0a 100644
> --- a/arch/arm64/kernel/stacktrace.c
> +++ b/arch/arm64/kernel/stacktrace.c
> @@ -103,7 +103,7 @@ static int notrace unwind_frame(struct task_struct *tsk,
> if (fp <= frame->prev_fp)
> return -EINVAL;
> } else {
> - set_bit(frame->prev_type, frame->stacks_done);
> + __set_bit(frame->prev_type, frame->stacks_done);
> }
>
> /*
> --
> 2.25.1
>