aboutsummaryrefslogtreecommitdiffstats
path: root/arch/riscv/kernel/signal.c
diff options
context:
space:
mode:
authorJisheng Zhang <jszhang@kernel.org>2021-05-12 22:55:45 +0800
committerPalmer Dabbelt <palmerdabbelt@google.com>2021-05-25 22:56:57 -0700
commit37a7a2a10ec525a79d733008bc7fe4ebbca34382 (patch)
treec4d7257ecfe7a54eec0286b274de15ae56eb68a7 /arch/riscv/kernel/signal.c
parentriscv: Optimize switch_mm by passing "cpu" to flush_icache_deferred() (diff)
downloadlinux-dev-37a7a2a10ec525a79d733008bc7fe4ebbca34382.tar.xz
linux-dev-37a7a2a10ec525a79d733008bc7fe4ebbca34382.zip
riscv: Turn has_fpu into a static key if FPU=y
The has_fpu check sits at hot code path: switch_to(). Currently, has_fpu is a bool variable if FPU=y, switch_to() checks it each time, we can optimize out this check by turning the has_fpu into a static key. Signed-off-by: Jisheng Zhang <jszhang@kernel.org> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Diffstat (limited to 'arch/riscv/kernel/signal.c')
-rw-r--r--arch/riscv/kernel/signal.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c
index 65942b3748b4..c2d5ecbe5526 100644
--- a/arch/riscv/kernel/signal.c
+++ b/arch/riscv/kernel/signal.c
@@ -90,7 +90,7 @@ static long restore_sigcontext(struct pt_regs *regs,
/* sc_regs is structured the same as the start of pt_regs */
err = __copy_from_user(regs, &sc->sc_regs, sizeof(sc->sc_regs));
/* Restore the floating-point state. */
- if (has_fpu)
+ if (has_fpu())
err |= restore_fp_state(regs, &sc->sc_fpregs);
return err;
}
@@ -143,7 +143,7 @@ static long setup_sigcontext(struct rt_sigframe __user *frame,
/* sc_regs is structured the same as the start of pt_regs */
err = __copy_to_user(&sc->sc_regs, regs, sizeof(sc->sc_regs));
/* Save the floating-point state. */
- if (has_fpu)
+ if (has_fpu())
err |= save_fp_state(regs, &sc->sc_fpregs);
return err;
}