Re: [PATCH v2 05/11] arm64: sve: Provide a conditional update accessor for ZCR_ELx
From: Marc Zyngier <maz@kernel.org>
Date: 2021-03-19 16:53:17
Also in:
kvm, kvmarm
On 2021-03-19 16:42, Mark Brown wrote:
On Thu, Mar 18, 2021 at 12:25:26PM +0000, Marc Zyngier wrote:quoted
A common pattern is to conditionally update ZCR_ELx in order to avoid the "self-synchronizing" effect that writing to this register has. Let's provide an accessor that does exactly this.Reviewed-by: Mark Brown <broonie@kernel.org>quoted
+#define sve_cond_update_zcr_vq(val, reg) \ + do { \ + u64 __zcr = read_sysreg_s((reg)); \ + u64 __new = __zcr & ~ZCR_ELx_LEN_MASK; \ + __new |= (val) & ZCR_ELx_LEN_MASK; \ + if (__zcr != __new) \ + write_sysreg_s(__new, (reg)); \ + } while (0) +Do compilers actually do much better with this than with a static inline like the other functions in this header? Seems like something they should be figuring out.
It's not about performance or anything of the sort: in most cases
where we end-up using this, it is on the back of an exception.
So performance is the least of our worries.
However, the "reg" parameter to read/write_sysreg_s() cannot
be a variable, because it is directly fed to the assembler.
If you want to use functions, you need to specialise them per
register. At this point, I'm pretty happy with a #define.
M.
--
Jazz is not dead. It just smells funny...
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel