Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kselftest/arm64: Size sycall-abi buffers for the actual maximum VL

Our ABI opts to provide future proofing by defining a much larger
SVE_VQ_MAX than the architecture actually supports. Since we use
this define to control the size of our vector data buffers this results
in a lot of overhead when we initialise which can be a very noticable
problem in emulation, we fill buffers that are orders of magnitude
larger than we will ever actually use even with virtual platforms that
provide the full range of architecturally supported vector lengths.

Define and use the actual architecture maximum to mitigate this.

Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230810-arm64-syscall-abi-perf-v1-1-6a0d7656359c@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Mark Brown and committed by
Will Deacon
358b763e 82e7882b

+23 -15
+23 -15
tools/testing/selftests/arm64/abi/syscall-abi.c
··· 20 20 21 21 #include "syscall-abi.h" 22 22 23 + /* 24 + * The kernel defines a much larger SVE_VQ_MAX than is expressable in 25 + * the architecture, this creates a *lot* of overhead filling the 26 + * buffers (especially ZA) on emulated platforms so use the actual 27 + * architectural maximum instead. 28 + */ 29 + #define ARCH_SVE_VQ_MAX 16 30 + 23 31 static int default_sme_vl; 24 32 25 33 static int sve_vl_count; 26 - static unsigned int sve_vls[SVE_VQ_MAX]; 34 + static unsigned int sve_vls[ARCH_SVE_VQ_MAX]; 27 35 static int sme_vl_count; 28 - static unsigned int sme_vls[SVE_VQ_MAX]; 36 + static unsigned int sme_vls[ARCH_SVE_VQ_MAX]; 29 37 30 38 extern void do_syscall(int sve_vl, int sme_vl); 31 39 ··· 138 130 139 131 #define SVE_Z_SHARED_BYTES (128 / 8) 140 132 141 - static uint8_t z_zero[__SVE_ZREG_SIZE(SVE_VQ_MAX)]; 142 - uint8_t z_in[SVE_NUM_ZREGS * __SVE_ZREG_SIZE(SVE_VQ_MAX)]; 143 - uint8_t z_out[SVE_NUM_ZREGS * __SVE_ZREG_SIZE(SVE_VQ_MAX)]; 133 + static uint8_t z_zero[__SVE_ZREG_SIZE(ARCH_SVE_VQ_MAX)]; 134 + uint8_t z_in[SVE_NUM_ZREGS * __SVE_ZREG_SIZE(ARCH_SVE_VQ_MAX)]; 135 + uint8_t z_out[SVE_NUM_ZREGS * __SVE_ZREG_SIZE(ARCH_SVE_VQ_MAX)]; 144 136 145 137 static void setup_z(struct syscall_cfg *cfg, int sve_vl, int sme_vl, 146 138 uint64_t svcr) ··· 198 190 return errors; 199 191 } 200 192 201 - uint8_t p_in[SVE_NUM_PREGS * __SVE_PREG_SIZE(SVE_VQ_MAX)]; 202 - uint8_t p_out[SVE_NUM_PREGS * __SVE_PREG_SIZE(SVE_VQ_MAX)]; 193 + uint8_t p_in[SVE_NUM_PREGS * __SVE_PREG_SIZE(ARCH_SVE_VQ_MAX)]; 194 + uint8_t p_out[SVE_NUM_PREGS * __SVE_PREG_SIZE(ARCH_SVE_VQ_MAX)]; 203 195 204 196 static void setup_p(struct syscall_cfg *cfg, int sve_vl, int sme_vl, 205 197 uint64_t svcr) ··· 230 222 return errors; 231 223 } 232 224 233 - uint8_t ffr_in[__SVE_PREG_SIZE(SVE_VQ_MAX)]; 234 - uint8_t ffr_out[__SVE_PREG_SIZE(SVE_VQ_MAX)]; 225 + uint8_t ffr_in[__SVE_PREG_SIZE(ARCH_SVE_VQ_MAX)]; 226 + uint8_t ffr_out[__SVE_PREG_SIZE(ARCH_SVE_VQ_MAX)]; 235 227 236 228 static void setup_ffr(struct syscall_cfg *cfg, int sve_vl, int sme_vl, 237 229 uint64_t svcr) ··· 308 300 return errors; 309 301 } 310 302 311 - uint8_t za_in[ZA_SIG_REGS_SIZE(SVE_VQ_MAX)]; 312 - uint8_t za_out[ZA_SIG_REGS_SIZE(SVE_VQ_MAX)]; 303 + uint8_t za_in[ZA_SIG_REGS_SIZE(ARCH_SVE_VQ_MAX)]; 304 + uint8_t za_out[ZA_SIG_REGS_SIZE(ARCH_SVE_VQ_MAX)]; 313 305 314 306 static void setup_za(struct syscall_cfg *cfg, int sve_vl, int sme_vl, 315 307 uint64_t svcr) ··· 478 470 return; 479 471 480 472 /* 481 - * Enumerate up to SVE_VQ_MAX vector lengths 473 + * Enumerate up to ARCH_SVE_VQ_MAX vector lengths 482 474 */ 483 - for (vq = SVE_VQ_MAX; vq > 0; vq /= 2) { 475 + for (vq = ARCH_SVE_VQ_MAX; vq > 0; vq /= 2) { 484 476 vl = prctl(PR_SVE_SET_VL, vq * 16); 485 477 if (vl == -1) 486 478 ksft_exit_fail_msg("PR_SVE_SET_VL failed: %s (%d)\n", ··· 504 496 return; 505 497 506 498 /* 507 - * Enumerate up to SVE_VQ_MAX vector lengths 499 + * Enumerate up to ARCH_SVE_VQ_MAX vector lengths 508 500 */ 509 - for (vq = SVE_VQ_MAX; vq > 0; vq /= 2) { 501 + for (vq = ARCH_SVE_VQ_MAX; vq > 0; vq /= 2) { 510 502 vl = prctl(PR_SME_SET_VL, vq * 16); 511 503 if (vl == -1) 512 504 ksft_exit_fail_msg("PR_SME_SET_VL failed: %s (%d)\n",