Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 // Copyright (C) 2021 ARM Limited.
0003 // Original author: Mark Brown <broonie@kernel.org>
0004 //
0005 // Trivial syscall overhead benchmark.
0006 //
0007 // This is implemented in asm to ensure that we don't have any issues with
0008 // system libraries using instructions that disrupt the test.
0009 
0010 #include <asm/unistd.h>
0011 #include "assembler.h"
0012 
0013 .arch_extension sve
0014 
0015 .macro test_loop per_loop
0016     mov x10, x20
0017     mov x8, #__NR_getpid
0018     mrs x11, CNTVCT_EL0
0019 1:
0020     \per_loop
0021     svc #0
0022     sub x10, x10, #1
0023     cbnz    x10, 1b
0024 
0025     mrs x12, CNTVCT_EL0
0026     sub x0, x12, x11
0027     bl  putdec
0028     puts    "\n"
0029 .endm
0030 
0031 // Main program entry point
0032 .globl _start
0033 function _start
0034 _start:
0035     puts    "Iterations per test: "
0036     mov x20, #10000
0037     lsl x20, x20, #8
0038     mov x0, x20
0039     bl  putdec
0040     puts    "\n"
0041 
0042     // Test having never used SVE
0043     puts    "No SVE: "
0044     test_loop
0045 
0046     // Check for SVE support - should use hwcap but that's hard in asm
0047     mrs x0, ID_AA64PFR0_EL1
0048     ubfx    x0, x0, #32, #4
0049     cbnz    x0, 1f
0050     puts    "System does not support SVE\n"
0051     b   out
0052 1:
0053 
0054     // Execute a SVE instruction
0055     puts    "SVE VL: "
0056     rdvl    x0, #8
0057     bl  putdec
0058     puts    "\n"
0059 
0060     puts    "SVE used once: "
0061     test_loop
0062 
0063     // Use SVE per syscall
0064     puts    "SVE used per syscall: "
0065     test_loop "rdvl x0, #8"
0066 
0067     //  And we're done
0068 out:
0069     mov x0, #0
0070     mov x8, #__NR_exit
0071     svc #0