Skip to content

Commit 2c94ebe

Browse files
brooniectmarinas
authored andcommitted
kselftest/arm64: Add pidbench for floating point syscall cases
Since it's likely to be useful for performance work with SVE let's have a pidbench that gives us some numbers for consideration. In order to ensure that we test exactly the scenario we want this is written in assembly - if system libraries use SVE this would stop us exercising the case where the process has never used SVE. We exercise three cases: - Never having used SVE. - Having used SVE once. - Using SVE after each syscall. by spinning running getpid() for a fixed number of iterations with the time measured using CNTVCT_EL0 reported on the console. This is obviously a totally unrealistic benchmark which will show the extremes of any performance variation but equally given the potential gotchas with use of FP instructions by system libraries it's good to have some concrete code shared to make it easier to compare notes on results. Testing over multiple SVE vector lengths will need to be done with vlset currently, the test could be extended to iterate over all of them if desired. Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent b77e995 commit 2c94ebe

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

tools/testing/selftests/arm64/fp/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
fp-pidbench
12
fpsimd-test
23
rdvl-sve
34
sve-probe-vls

tools/testing/selftests/arm64/fp/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
CFLAGS += -I../../../../../usr/include/
44
TEST_GEN_PROGS := sve-ptrace sve-probe-vls vec-syscfg
5-
TEST_PROGS_EXTENDED := fpsimd-test fpsimd-stress \
5+
TEST_PROGS_EXTENDED := fp-pidbench fpsimd-test fpsimd-stress \
66
rdvl-sve \
77
sve-test sve-stress \
88
vlset
99

1010
all: $(TEST_GEN_PROGS) $(TEST_PROGS_EXTENDED)
1111

12+
fp-pidbench: fp-pidbench.S asm-utils.o
13+
$(CC) -nostdlib $^ -o $@
1214
fpsimd-test: fpsimd-test.o asm-utils.o
1315
$(CC) -nostdlib $^ -o $@
1416
rdvl-sve: rdvl-sve.o rdvl.o
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
// Copyright (C) 2021 ARM Limited.
3+
// Original author: Mark Brown <[email protected]>
4+
//
5+
// Trivial syscall overhead benchmark.
6+
//
7+
// This is implemented in asm to ensure that we don't have any issues with
8+
// system libraries using instructions that disrupt the test.
9+
10+
#include <asm/unistd.h>
11+
#include "assembler.h"
12+
13+
.arch_extension sve
14+
15+
.macro test_loop per_loop
16+
mov x10, x20
17+
mov x8, #__NR_getpid
18+
mrs x11, CNTVCT_EL0
19+
1:
20+
\per_loop
21+
svc #0
22+
sub x10, x10, #1
23+
cbnz x10, 1b
24+
25+
mrs x12, CNTVCT_EL0
26+
sub x0, x12, x11
27+
bl putdec
28+
puts "\n"
29+
.endm
30+
31+
// Main program entry point
32+
.globl _start
33+
function _start
34+
_start:
35+
puts "Iterations per test: "
36+
mov x20, #10000
37+
lsl x20, x20, #8
38+
mov x0, x20
39+
bl putdec
40+
puts "\n"
41+
42+
// Test having never used SVE
43+
puts "No SVE: "
44+
test_loop
45+
46+
// Check for SVE support - should use hwcap but that's hard in asm
47+
mrs x0, ID_AA64PFR0_EL1
48+
ubfx x0, x0, #32, #4
49+
cbnz x0, 1f
50+
puts "System does not support SVE\n"
51+
b out
52+
1:
53+
54+
// Execute a SVE instruction
55+
puts "SVE VL: "
56+
rdvl x0, #8
57+
bl putdec
58+
puts "\n"
59+
60+
puts "SVE used once: "
61+
test_loop
62+
63+
// Use SVE per syscall
64+
puts "SVE used per syscall: "
65+
test_loop "rdvl x0, #8"
66+
67+
// And we're done
68+
out:
69+
mov x0, #0
70+
mov x8, #__NR_exit
71+
svc #0

0 commit comments

Comments
 (0)