/* * Test null syscall performance * * Copyright (C) 2009-2015 Anton Blanchard, IBM * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #define NR_LOOPS 10000000 #include #include #include #include #include #include #include #include static volatile int soak_done; unsigned long long clock_frequency; unsigned long long timebase_frequency; double timebase_multiplier; static inline unsigned long long mftb(void) { unsigned long low; asm volatile("mftb %0" : "=r" (low)); return low; } static void sigalrm_handler(int unused) { soak_done = 1; } /* * Use a timer instead of busy looping on clock_gettime() so we don't * pollute profiles with glibc and VDSO hits. */ static void cpu_soak_usecs(unsigned long usecs) { struct itimerval val; memset(&val, 0, sizeof(val)); val.it_value.tv_usec = usecs; signal(SIGALRM, sigalrm_handler); setitimer(ITIMER_REAL, &val, NULL); while (1) { if (soak_done) break; } signal(SIGALRM, SIG_DFL); } /* * This only works with recent kernels where cpufreq modifies * /proc/cpuinfo dynamically. */ static void get_proc_frequency(void) { FILE *f; char line[128]; char *p, *end; unsigned long v; double d; char *override; /* Try to get out of low power/low frequency mode */ cpu_soak_usecs(0.25 * 1000000); f = fopen("/proc/cpuinfo", "r"); if (f == NULL) return; timebase_frequency = 0; while (fgets(line, sizeof(line), f) != NULL) { if (strncmp(line, "timebase", 8) == 0) { p = strchr(line, ':'); if (p != NULL) { v = strtoull(p + 1, &end, 0); if (end != p + 1) timebase_frequency = v; } } if (((strncmp(line, "clock", 5) == 0) || (strncmp(line, "cpu MHz", 7) == 0))) { p = strchr(line, ':'); if (p != NULL) { d = strtod(p + 1, &end); if (end != p + 1) { /* Find fastest clock frequency */ if ((d * 1000000ULL) > clock_frequency) clock_frequency = d * 1000000ULL; } } } } fclose(f); override = getenv("FREQUENCY"); if (override) clock_frequency = strtoull(override, NULL, 10); if (timebase_frequency) timebase_multiplier = (double)clock_frequency / timebase_frequency; else timebase_multiplier = 1; } static void do_null_syscall(unsigned long nr) { unsigned long i; for (i = 0; i < nr; i++) getppid(); } #define TIME(A, STR) \ int main(void) { unsigned long tb_start, tb_now; struct timespec tv_start, tv_now; unsigned long long elapsed_ns, elapsed_tb; get_proc_frequency(); clock_gettime(CLOCK_MONOTONIC, &tv_start); tb_start = mftb(); do_null_syscall(NR_LOOPS); clock_gettime(CLOCK_MONOTONIC, &tv_now); tb_now = mftb(); elapsed_ns = (tv_now.tv_sec - tv_start.tv_sec) * 1000000000ULL + (tv_now.tv_nsec - tv_start.tv_nsec); elapsed_tb = tb_now - tb_start; printf("%10.2f ns %10.2f cycles\n", (float)elapsed_ns / NR_LOOPS, (float)elapsed_tb * timebase_multiplier / NR_LOOPS); return 0; } .cgi/linux/net-next.git/tree/tools/perf/util?h=nds-private-remove&id=e4178c75049c581114998a850ecdfa5a2811cde6'>util
ModeNameSize
-rw-r--r--Build5870logplain
-rwxr-xr-xPERF-VERSION-GEN1010logplain
-rw-r--r--alias.c1471logplain
-rw-r--r--annotate.c44411logplain
-rw-r--r--annotate.h5583logplain
-rw-r--r--auxtrace.c47774logplain
-rw-r--r--auxtrace.h22142logplain
-rw-r--r--block-range.c6948logplain
-rw-r--r--block-range.h1607logplain
-rw-r--r--bpf-loader.c40787logplain
-rw-r--r--bpf-loader.h6215logplain
-rw-r--r--bpf-prologue.c11226logplain
-rw-r--r--bpf-prologue.h847logplain
-rw-r--r--build-id.c19054logplain
-rw-r--r--build-id.h1859logplain
d---------c++184logplain
-rw-r--r--cache.h733logplain
-rw-r--r--call-path.c2893logplain
-rw-r--r--call-path.h2203logplain
-rw-r--r--callchain.c29332logplain
-rw-r--r--callchain.h7881logplain
-rw-r--r--cgroup.c3195logplain
-rw-r--r--cgroup.h359logplain
-rw-r--r--cloexec.c1950logplain
-rw-r--r--cloexec.h251logplain
-rw-r--r--color.c4787logplain
-rw-r--r--color.h1647logplain
-rw-r--r--comm.c2239logplain
-rw-r--r--comm.h561logplain
-rw-r--r--config.c16262logplain
-rw-r--r--config.h2113logplain
-rw-r--r--counts.c1026logplain
-rw-r--r--counts.h790logplain
-rw-r--r--cpumap.c12627logplain
-rw-r--r--cpumap.h1954logplain
-rw-r--r--cs-etm.h2061logplain
-rw-r--r--ctype.c2018logplain
-rw-r--r--data-convert-bt.c36671logplain
-rw-r--r--data-convert-bt.h302logplain
-rw-r--r--data-convert.h141logplain
-rw-r--r--data.c3459logplain
-rw-r--r--data.h1369logplain
-rw-r--r--db-export.c11434logplain
-rw-r--r--db-export.h3816logplain
-rw-r--r--debug.c4417logplain
-rw-r--r--debug.h2023logplain
-rw-r--r--demangle-java.c4219logplain
-rw-r--r--demangle-java.h249logplain
-rw-r--r--demangle-rust.c6602logplain
-rw-r--r--demangle-rust.h170logplain
-rw-r--r--drv_configs.c1834logplain
-rw-r--r--drv_configs.h844logplain
-rw-r--r--dso.c31994logplain
-rw-r--r--dso.h10399logplain
-rw-r--r--dwarf-aux.c33828logplain
-rw-r--r--dwarf-aux.h5101logplain
-rw-r--r--dwarf-regs.c1816logplain
-rw-r--r--env.c1884logplain
-rw-r--r--env.h1268logplain
-rw-r--r--event.c36670logplain
-rw-r--r--event.h15997logplain
-rw-r--r--evlist.c47104logplain
-rw-r--r--evlist.h12584logplain
-rw-r--r--evsel.c63917logplain
-rw-r--r--evsel.h13041logplain
-rw-r--r--evsel_fprintf.c5831logplain
-rw-r--r--find-vdso-map.c581logplain
-rw-r--r--genelf.c11653logplain
-rw-r--r--genelf.h1814logplain
-rw-r--r--genelf_debug.c14374logplain
-rwxr-xr-xgenerate-cmdlist.sh1141logplain
-rw-r--r--group.h122logplain
-rw-r--r--header.c73410logplain
-rw-r--r--header.h4365logplain
-rw-r--r--help-unknown-cmd.c3221logplain