Commit 121dd9ea authored by Davidlohr Bueso's avatar Davidlohr Bueso Committed by Arnaldo Carvalho de Melo

perf bench: Add epoll parallel epoll_wait benchmark

This program benchmarks concurrent epoll_wait(2) for file descriptors
that are monitored with with EPOLLIN along various semantics, by a
single epoll instance. Such conditions can be found when using
single/combined or multiple queuing when load balancing.

Each thread has a number of private, nonblocking file descriptors,
referred to as fdmap. A writer thread will constantly be writing to the
fdmaps of all threads, minimizing each threads's chances of epoll_wait
not finding any ready read events and blocking as this is not what we
want to stress. Full details in the start of the C file.

Committer testing:

  # perf bench
  Usage:
	perf bench [<common options>] <collection> <benchmark> [<options>]

        # List of all available benchmark collections:

         sched: Scheduler and IPC benchmarks
           mem: Memory access benchmarks
          numa: NUMA scheduling and MM benchmarks
         futex: Futex stressing benchmarks
         epoll: Epoll stressing benchmarks
           all: All benchmarks

  # perf bench epoll

        # List of available benchmarks for collection 'epoll':

          wait: Benchmark epoll concurrent epoll_waits
           all: Run all futex benchmarks

  # perf bench epoll wait
  # Running 'epoll/wait' benchmark:
  Run summary [PID 19295]: 3 threads monitoring on 64 file-descriptors for 8 secs.

  [thread  0] fdmap: 0xdaa650 ... 0xdaa74c [ 328241 ops/sec ]
  [thread  1] fdmap: 0xdaa900 ... 0xdaa9fc [ 351695 ops/sec ]
  [thread  2] fdmap: 0xdaabb0 ... 0xdaacac [ 381423 ops/sec ]

  Averaged 353786 operations/sec (+- 4.35%), total secs = 8
  #

Committer notes:

Fix the build on debian:experimental-x-mips, debian:experimental-x-mipsel
and others:

    CC       /tmp/build/perf/bench/epoll-wait.o
  bench/epoll-wait.c: In function 'writerfn':
  bench/epoll-wait.c:399:12: error: format '%ld' expects argument of type 'long int', but argument 2 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
    printinfo("exiting writer-thread (total full-loops: %ld)\n", iter);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~
  bench/epoll-wait.c:86:31: note: in definition of macro 'printinfo'
    do { if (__verbose) { printf(fmt, ## arg); fflush(stdout); } } while (0)
                                 ^~~
  cc1: all warnings being treated as errors
Signed-off-by: default avatarDavidlohr Bueso <dbueso@suse.de>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Jason Baron <jbaron@akamai.com> <jbaron@akamai.com>
Link: http://lkml.kernel.org/r/20181106152226.20883-2-dave@stgolabs.net
Link: http://lkml.kernel.org/r/20181106182349.thdkpvshkna5vd7o@linux-r8p5>
[ Applied above fixup as per Davidlohr's request ]
[ Use inttypes.h to print rlim_t fields, fixing the build on Alpine Linux / musl libc ]
[ Check if eventfd() is available, i.e. if HAVE_EVENTFD is defined ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 11c6cbe7
...@@ -58,6 +58,9 @@ SUBSYSTEM ...@@ -58,6 +58,9 @@ SUBSYSTEM
'futex':: 'futex'::
Futex stressing benchmarks. Futex stressing benchmarks.
'epoll'::
Eventpoll (epoll) stressing benchmarks.
'all':: 'all'::
All benchmark subsystems. All benchmark subsystems.
...@@ -203,6 +206,10 @@ Suite for evaluating requeue calls. ...@@ -203,6 +206,10 @@ Suite for evaluating requeue calls.
*lock-pi*:: *lock-pi*::
Suite for evaluating futex lock_pi calls. Suite for evaluating futex lock_pi calls.
SUITES FOR 'epoll'
~~~~~~~~~~~~~~~~~~
*wait*::
Suite for evaluating concurrent epoll_wait calls.
SEE ALSO SEE ALSO
-------- --------
......
...@@ -7,6 +7,8 @@ perf-y += futex-wake-parallel.o ...@@ -7,6 +7,8 @@ perf-y += futex-wake-parallel.o
perf-y += futex-requeue.o perf-y += futex-requeue.o
perf-y += futex-lock-pi.o perf-y += futex-lock-pi.o
perf-y += epoll-wait.o
perf-$(CONFIG_X86_64) += mem-memcpy-x86-64-lib.o perf-$(CONFIG_X86_64) += mem-memcpy-x86-64-lib.o
perf-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o perf-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o
perf-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o perf-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o
......
...@@ -38,6 +38,8 @@ int bench_futex_requeue(int argc, const char **argv); ...@@ -38,6 +38,8 @@ int bench_futex_requeue(int argc, const char **argv);
/* pi futexes */ /* pi futexes */
int bench_futex_lock_pi(int argc, const char **argv); int bench_futex_lock_pi(int argc, const char **argv);
int bench_epoll_wait(int argc, const char **argv);
#define BENCH_FORMAT_DEFAULT_STR "default" #define BENCH_FORMAT_DEFAULT_STR "default"
#define BENCH_FORMAT_DEFAULT 0 #define BENCH_FORMAT_DEFAULT 0
#define BENCH_FORMAT_SIMPLE_STR "simple" #define BENCH_FORMAT_SIMPLE_STR "simple"
......
This diff is collapsed.
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
* mem ... memory access performance * mem ... memory access performance
* numa ... NUMA scheduling and MM performance * numa ... NUMA scheduling and MM performance
* futex ... Futex performance * futex ... Futex performance
* epoll ... Event poll performance
*/ */
#include "perf.h" #include "perf.h"
#include "util/util.h" #include "util/util.h"
...@@ -67,6 +68,14 @@ static struct bench futex_benchmarks[] = { ...@@ -67,6 +68,14 @@ static struct bench futex_benchmarks[] = {
{ NULL, NULL, NULL } { NULL, NULL, NULL }
}; };
#ifdef HAVE_EVENTFD
static struct bench epoll_benchmarks[] = {
{ "wait", "Benchmark epoll concurrent epoll_waits", bench_epoll_wait },
{ "all", "Run all futex benchmarks", NULL },
{ NULL, NULL, NULL }
};
#endif // HAVE_EVENTFD
struct collection { struct collection {
const char *name; const char *name;
const char *summary; const char *summary;
...@@ -80,6 +89,9 @@ static struct collection collections[] = { ...@@ -80,6 +89,9 @@ static struct collection collections[] = {
{ "numa", "NUMA scheduling and MM benchmarks", numa_benchmarks }, { "numa", "NUMA scheduling and MM benchmarks", numa_benchmarks },
#endif #endif
{"futex", "Futex stressing benchmarks", futex_benchmarks }, {"futex", "Futex stressing benchmarks", futex_benchmarks },
#ifdef HAVE_EVENTFD
{"epoll", "Epoll stressing benchmarks", epoll_benchmarks },
#endif
{ "all", "All benchmarks", NULL }, { "all", "All benchmarks", NULL },
{ NULL, NULL, NULL } { NULL, NULL, NULL }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment