• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// SPDX-License-Identifier: GPL-2.0-only
2// Copyright (C) 2021 ARM Limited.
3// Original author: Mark Brown <broonie@kernel.org>
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
191:
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
33function _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
521:
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
68out:
69	mov	x0, #0
70	mov	x8, #__NR_exit
71	svc	#0
72