~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/bench.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #pragma once
  3 #include <stdlib.h>
  4 #include <stdbool.h>
  5 #include <linux/err.h>
  6 #include <errno.h>
  7 #include <unistd.h>
  8 #include <bpf/bpf.h>
  9 #include <bpf/libbpf.h>
 10 #include <math.h>
 11 #include <time.h>
 12 #include <sys/syscall.h>
 13 #include <limits.h>
 14 
 15 struct cpu_set {
 16         bool *cpus;
 17         int cpus_len;
 18         int next_cpu;
 19 };
 20 
 21 struct env {
 22         char *bench_name;
 23         int duration_sec;
 24         int warmup_sec;
 25         bool verbose;
 26         bool list;
 27         bool affinity;
 28         bool quiet;
 29         int consumer_cnt;
 30         int producer_cnt;
 31         int nr_cpus;
 32         struct cpu_set prod_cpus;
 33         struct cpu_set cons_cpus;
 34 };
 35 
 36 struct basic_stats {
 37         double mean;
 38         double stddev;
 39 };
 40 
 41 struct bench_res {
 42         long hits;
 43         long drops;
 44         long false_hits;
 45         long important_hits;
 46         unsigned long gp_ns;
 47         unsigned long gp_ct;
 48         unsigned int stime;
 49 };
 50 
 51 struct bench {
 52         const char *name;
 53         const struct argp *argp;
 54         void (*validate)(void);
 55         void (*setup)(void);
 56         void *(*producer_thread)(void *ctx);
 57         void *(*consumer_thread)(void *ctx);
 58         void (*measure)(struct bench_res* res);
 59         void (*report_progress)(int iter, struct bench_res* res, long delta_ns);
 60         void (*report_final)(struct bench_res res[], int res_cnt);
 61 };
 62 
 63 struct counter {
 64         long value;
 65 } __attribute__((aligned(128)));
 66 
 67 extern struct env env;
 68 extern const struct bench *bench;
 69 
 70 void setup_libbpf(void);
 71 void hits_drops_report_progress(int iter, struct bench_res *res, long delta_ns);
 72 void hits_drops_report_final(struct bench_res res[], int res_cnt);
 73 void false_hits_report_progress(int iter, struct bench_res *res, long delta_ns);
 74 void false_hits_report_final(struct bench_res res[], int res_cnt);
 75 void ops_report_progress(int iter, struct bench_res *res, long delta_ns);
 76 void ops_report_final(struct bench_res res[], int res_cnt);
 77 void local_storage_report_progress(int iter, struct bench_res *res,
 78                                    long delta_ns);
 79 void local_storage_report_final(struct bench_res res[], int res_cnt);
 80 void grace_period_latency_basic_stats(struct bench_res res[], int res_cnt,
 81                                       struct basic_stats *gp_stat);
 82 void grace_period_ticks_basic_stats(struct bench_res res[], int res_cnt,
 83                                     struct basic_stats *gp_stat);
 84 
 85 static inline void atomic_inc(long *value)
 86 {
 87         (void)__atomic_add_fetch(value, 1, __ATOMIC_RELAXED);
 88 }
 89 
 90 static inline void atomic_add(long *value, long n)
 91 {
 92         (void)__atomic_add_fetch(value, n, __ATOMIC_RELAXED);
 93 }
 94 
 95 static inline long atomic_swap(long *value, long n)
 96 {
 97         return __atomic_exchange_n(value, n, __ATOMIC_RELAXED);
 98 }
 99 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php