arm64: fpsimd: avoid restoring fpcr if the contents haven't changed
PATCH 1/1 arm64: fpsimd: avoid restoring fpcr if the contents haven't changed
Writing to the FPCR is commonly implemented as a self-synchronising operation in the CPU, so avoid writing to the register when the saved value matches that in the hardware already.
--- arch/arm64/include/asm/fpsimdmacros.h | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm64/include/asm/fpsimdmacros.h +9 -0
@@ -40,6 +40,7 @@ str w\tmpnr, [\state, #16 * 2 + 4] .endm +/* Clobbers \state */ .macro fpsimd_restore state, tmpnr ldp q0, q1, [\state, #16 * 0] ldp q2, q3, [\state, #16 * 2]
@@ -60,7 +61,15 @@ ldr w\tmpnr, [\state, #16 * 2] msr fpsr, x\tmpnr ldr w\tmpnr, [\state, #16 * 2 + 4] +/* +* Writes to fpcr may be self-synchronising, so avoid restoring +* the register if it hasn't changed. +*/ + mrs \state, fpcr + cmp x\tmpnr, \state + b.eq 9999f msr fpcr, x\tmpnr +9999: .endm .altmacro
Signature · 1 line
2.0.0
PATCH 1/1 arm64: fpsimd: avoid restoring fpcr if the contents haven't changed
Hey Will,
Quoted 27 lines · Will Deacon
Writing to the FPCR is commonly implemented as a self-synchronising operation in the CPU, so avoid writing to the register when the saved value matches that in the hardware already.
Reviewed-by Lorenzo Pieralisi <[email protected]>Signed-off-by Will Deacon <[email protected]>--- arch/arm64/include/asm/fpsimdmacros.h | 9 +++++++++ 1 file changed, 9 insertions(+)arch/arm64/include/asm/fpsimdmacros.h +2
-0@@ -40,6 +40,7 @@ str w\tmpnr, [\state, #16 * 2 + 4] .endm +/* Clobbers \state */ .macro fpsimd_restore state, tmpnr ldp q0, q1, [\state, #16 * 0] ldp q2, q3, [\state, #16 * 2]@@ -60,7 +61,15 @@ ldr w\tmpnr, [\state, #16 * 2] msr fpsr, x\tmpnr ldr w\tmpnr, [\state, #16 * 2 + 4] +/*
arch/arm64/include/asm/fpsimdmacros.h line 74
Quoted 10 lines
arch/arm64/include/asm/fpsimdmacros.h +7
-0+* Writes to fpcr may be self-synchronising, so avoid restoring +* the register if it hasn't changed. +*/ + mrs \state, fpcr + cmp x\tmpnr, \state + b.eq 9999f msr fpcr, x\tmpnr +9999: .endm
I would assume the same would apply to the partial restore that was merged during the last window?
Signature · 1 line
Ard.
PATCH 1/1 arm64: fpsimd: avoid restoring fpcr if the contents haven't changed
Quoted 1 line · Ard Biesheuvel
Hey Will,
Hi Ard,
Quoted 33 lines · Will Deacon
Quoted 32 lines
Writing to the FPCR is commonly implemented as a self-synchronising operation in the CPU, so avoid writing to the register when the saved value matches that in the hardware already.
Reviewed-by Lorenzo Pieralisi <[email protected]>Signed-off-by Will Deacon <[email protected]>--- arch/arm64/include/asm/fpsimdmacros.h | 9 +++++++++ 1 file changed, 9 insertions(+)arch/arm64/include/asm/fpsimdmacros.h +7
-0@@ -40,6 +40,7 @@ str w\tmpnr, [\state, #16 * 2 + 4] .endm +/* Clobbers \state */ .macro fpsimd_restore state, tmpnr ldp q0, q1, [\state, #16 * 0] ldp q2, q3, [\state, #16 * 2]@@ -60,7 +61,15 @@ ldr w\tmpnr, [\state, #16 * 2] msr fpsr, x\tmpnr ldr w\tmpnr, [\state, #16 * 2 + 4] +/* +* Writes to fpcr may be self-synchronising, so avoid restoring +* the register if it hasn't changed. +*/ + mrs \state, fpcr + cmp x\tmpnr, \state
Quoted 8 lines
arch/arm64/include/asm/fpsimdmacros.h line 74
Quoted 5 lines
arch/arm64/include/asm/fpsimdmacros.h +2
-0+ b.eq 9999f msr fpcr, x\tmpnr +9999: .endmI would assume the same would apply to the partial restore that was merged during the last window?
Good point; I'll take a look.
Cheers,
Will