summaryrefslogtreecommitdiffstats
path: root/src/spdk/test/event
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/spdk/test/event
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/spdk/test/event')
-rw-r--r--src/spdk/test/event/Makefile44
-rwxr-xr-xsrc/spdk/test/event/event.sh12
-rw-r--r--src/spdk/test/event/event_perf/.gitignore1
-rw-r--r--src/spdk/test/event/event_perf/Makefile54
-rw-r--r--src/spdk/test/event/event_perf/event_perf.c180
-rw-r--r--src/spdk/test/event/reactor/.gitignore1
-rw-r--r--src/spdk/test/event/reactor/Makefile54
-rw-r--r--src/spdk/test/event/reactor/reactor.c144
-rw-r--r--src/spdk/test/event/reactor_perf/.gitignore1
-rw-r--r--src/spdk/test/event/reactor_perf/Makefile54
-rw-r--r--src/spdk/test/event/reactor_perf/reactor_perf.c144
11 files changed, 689 insertions, 0 deletions
diff --git a/src/spdk/test/event/Makefile b/src/spdk/test/event/Makefile
new file mode 100644
index 00000000..b3e9cf1b
--- /dev/null
+++ b/src/spdk/test/event/Makefile
@@ -0,0 +1,44 @@
+#
+# BSD LICENSE
+#
+# Copyright (c) Intel Corporation.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
+include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
+
+DIRS-y = event_perf reactor reactor_perf
+
+.PHONY: all clean $(DIRS-y)
+
+all: $(DIRS-y)
+clean: $(DIRS-y)
+
+include $(SPDK_ROOT_DIR)/mk/spdk.subdirs.mk
diff --git a/src/spdk/test/event/event.sh b/src/spdk/test/event/event.sh
new file mode 100755
index 00000000..e1d080b1
--- /dev/null
+++ b/src/spdk/test/event/event.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+testdir=$(readlink -f $(dirname $0))
+rootdir=$(readlink -f $testdir/../..)
+source $rootdir/test/common/autotest_common.sh
+
+timing_enter event
+$testdir/event_perf/event_perf -m 0xF -t 1
+$testdir/reactor/reactor -t 1
+$testdir/reactor_perf/reactor_perf -t 1
+report_test_completion "event"
+timing_exit event
diff --git a/src/spdk/test/event/event_perf/.gitignore b/src/spdk/test/event/event_perf/.gitignore
new file mode 100644
index 00000000..2bdb558d
--- /dev/null
+++ b/src/spdk/test/event/event_perf/.gitignore
@@ -0,0 +1 @@
+event_perf
diff --git a/src/spdk/test/event/event_perf/Makefile b/src/spdk/test/event/event_perf/Makefile
new file mode 100644
index 00000000..a3aef2ea
--- /dev/null
+++ b/src/spdk/test/event/event_perf/Makefile
@@ -0,0 +1,54 @@
+#
+# BSD LICENSE
+#
+# Copyright (c) Intel Corporation.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
+include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
+include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
+
+APP = event_perf
+C_SRCS := event_perf.c
+
+SPDK_LIB_LIST = event trace conf thread util log rpc jsonrpc json
+
+LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS)
+
+all : $(APP)
+ @:
+
+$(APP) : $(OBJS) $(SPDK_LIB_FILES) $(ENV_LIBS)
+ $(LINK_C)
+
+clean :
+ $(CLEAN_C) $(APP)
+
+include $(SPDK_ROOT_DIR)/mk/spdk.deps.mk
diff --git a/src/spdk/test/event/event_perf/event_perf.c b/src/spdk/test/event/event_perf/event_perf.c
new file mode 100644
index 00000000..917ea950
--- /dev/null
+++ b/src/spdk/test/event/event_perf/event_perf.c
@@ -0,0 +1,180 @@
+/*-
+ * BSD LICENSE
+ *
+ * Copyright (c) Intel Corporation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "spdk/stdinc.h"
+
+#include "spdk/env.h"
+#include "spdk/event.h"
+#include "spdk_internal/event.h"
+#include "spdk/log.h"
+
+static uint64_t g_tsc_rate;
+static uint64_t g_tsc_us_rate;
+static uint64_t g_tsc_end;
+
+static int g_time_in_sec;
+
+static uint64_t *call_count;
+
+static bool g_app_stopped = false;
+
+static void
+submit_new_event(void *arg1, void *arg2)
+{
+ struct spdk_event *event;
+ static __thread uint32_t next_lcore = UINT32_MAX;
+
+ if (spdk_get_ticks() > g_tsc_end) {
+ if (__sync_bool_compare_and_swap(&g_app_stopped, false, true)) {
+ spdk_app_stop(0);
+ }
+ return;
+ }
+
+ if (next_lcore == UINT32_MAX) {
+ next_lcore = spdk_env_get_next_core(spdk_env_get_current_core());
+ if (next_lcore == UINT32_MAX) {
+ next_lcore = spdk_env_get_first_core();
+ }
+ }
+
+ call_count[next_lcore]++;
+ event = spdk_event_allocate(next_lcore, submit_new_event, NULL, NULL);
+ spdk_event_call(event);
+}
+
+static void
+event_work_fn(void *arg1, void *arg2)
+{
+
+ submit_new_event(NULL, NULL);
+ submit_new_event(NULL, NULL);
+ submit_new_event(NULL, NULL);
+ submit_new_event(NULL, NULL);
+}
+
+static void
+event_perf_start(void *arg1, void *arg2)
+{
+ uint32_t i;
+
+ call_count = calloc(spdk_env_get_last_core() + 1, sizeof(*call_count));
+ if (call_count == NULL) {
+ fprintf(stderr, "call_count allocation failed\n");
+ spdk_app_stop(1);
+ return;
+ }
+
+ g_tsc_rate = spdk_get_ticks_hz();
+ g_tsc_us_rate = g_tsc_rate / (1000 * 1000);
+ g_tsc_end = spdk_get_ticks() + g_time_in_sec * g_tsc_rate;
+
+ printf("Running I/O for %d seconds...", g_time_in_sec);
+ fflush(stdout);
+
+ SPDK_ENV_FOREACH_CORE(i) {
+ spdk_event_call(spdk_event_allocate(i, event_work_fn,
+ NULL, NULL));
+ }
+
+}
+
+static void
+usage(char *program_name)
+{
+ printf("%s options\n", program_name);
+ printf("\t[-m core mask for distributing I/O submission/completion work\n");
+ printf("\t\t(default: 0x1 - use core 0 only)]\n");
+ printf("\t[-t time in seconds]\n");
+}
+
+static void
+performance_dump(int io_time)
+{
+ uint32_t i;
+
+ if (call_count == NULL) {
+ return;
+ }
+
+ printf("\n");
+ SPDK_ENV_FOREACH_CORE(i) {
+ printf("lcore %2d: %8ju\n", i, call_count[i] / g_time_in_sec);
+ }
+
+ fflush(stdout);
+ free(call_count);
+}
+
+int
+main(int argc, char **argv)
+{
+ struct spdk_app_opts opts = {};
+ int op;
+ int rc = 0;
+
+ opts.name = "event_perf";
+ opts.mem_size = 256;
+
+ g_time_in_sec = 0;
+
+ while ((op = getopt(argc, argv, "m:t:")) != -1) {
+ switch (op) {
+ case 'm':
+ opts.reactor_mask = optarg;
+ break;
+ case 't':
+ g_time_in_sec = atoi(optarg);
+ break;
+ default:
+ usage(argv[0]);
+ exit(1);
+ }
+ }
+
+ if (!g_time_in_sec) {
+ usage(argv[0]);
+ exit(1);
+ }
+
+ printf("Running I/O for %d seconds...", g_time_in_sec);
+ fflush(stdout);
+
+ rc = spdk_app_start(&opts, event_perf_start, NULL, NULL);
+
+ spdk_app_fini();
+ performance_dump(g_time_in_sec);
+
+ printf("done.\n");
+ return rc;
+}
diff --git a/src/spdk/test/event/reactor/.gitignore b/src/spdk/test/event/reactor/.gitignore
new file mode 100644
index 00000000..194b15d7
--- /dev/null
+++ b/src/spdk/test/event/reactor/.gitignore
@@ -0,0 +1 @@
+reactor
diff --git a/src/spdk/test/event/reactor/Makefile b/src/spdk/test/event/reactor/Makefile
new file mode 100644
index 00000000..c5a6168a
--- /dev/null
+++ b/src/spdk/test/event/reactor/Makefile
@@ -0,0 +1,54 @@
+#
+# BSD LICENSE
+#
+# Copyright (c) Intel Corporation.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
+include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
+include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
+
+APP = reactor
+C_SRCS := reactor.c
+
+SPDK_LIB_LIST = event trace conf thread util log rpc jsonrpc json
+
+LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS)
+
+all : $(APP)
+ @:
+
+$(APP) : $(OBJS) $(SPDK_LIB_FILES) $(ENV_LIBS)
+ $(LINK_C)
+
+clean :
+ $(CLEAN_C) $(APP)
+
+include $(SPDK_ROOT_DIR)/mk/spdk.deps.mk
diff --git a/src/spdk/test/event/reactor/reactor.c b/src/spdk/test/event/reactor/reactor.c
new file mode 100644
index 00000000..d79f94ba
--- /dev/null
+++ b/src/spdk/test/event/reactor/reactor.c
@@ -0,0 +1,144 @@
+/*-
+ * BSD LICENSE
+ *
+ * Copyright (c) Intel Corporation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "spdk/stdinc.h"
+
+#include "spdk/event.h"
+#include "spdk/thread.h"
+
+static int g_time_in_sec;
+static struct spdk_poller *test_end_poller;
+static struct spdk_poller *poller_100ms;
+static struct spdk_poller *poller_250ms;
+static struct spdk_poller *poller_500ms;
+static struct spdk_poller *poller_oneshot;
+static struct spdk_poller *poller_unregister;
+
+static int
+test_end(void *arg)
+{
+ printf("test_end\n");
+
+ spdk_poller_unregister(&test_end_poller);
+ spdk_poller_unregister(&poller_100ms);
+ spdk_poller_unregister(&poller_250ms);
+ spdk_poller_unregister(&poller_500ms);
+
+ spdk_app_stop(0);
+ return -1;
+}
+
+static int
+tick(void *arg)
+{
+ uintptr_t period = (uintptr_t)arg;
+
+ printf("tick %" PRIu64 "\n", (uint64_t)period);
+
+ return -1;
+}
+
+static int
+oneshot(void *arg)
+{
+ printf("oneshot\n");
+ spdk_poller_unregister(&poller_oneshot);
+
+ return -1;
+}
+
+static int
+nop(void *arg)
+{
+ return -1;
+}
+
+static void
+test_start(void *arg1, void *arg2)
+{
+ printf("test_start\n");
+
+ /* Register a poller that will stop the test after the time has elapsed. */
+ test_end_poller = spdk_poller_register(test_end, NULL, g_time_in_sec * 1000000ULL);
+
+ poller_100ms = spdk_poller_register(tick, (void *)100, 100000);
+ poller_250ms = spdk_poller_register(tick, (void *)250, 250000);
+ poller_500ms = spdk_poller_register(tick, (void *)500, 500000);
+ poller_oneshot = spdk_poller_register(oneshot, NULL, 0);
+
+ poller_unregister = spdk_poller_register(nop, NULL, 0);
+ spdk_poller_unregister(&poller_unregister);
+}
+
+static void
+usage(const char *program_name)
+{
+ printf("%s options\n", program_name);
+ printf("\t[-t time in seconds]\n");
+}
+
+int
+main(int argc, char **argv)
+{
+ struct spdk_app_opts opts;
+ int op;
+ int rc = 0;
+
+ spdk_app_opts_init(&opts);
+ opts.name = "reactor";
+ opts.max_delay_us = 1000;
+
+ g_time_in_sec = 0;
+
+ while ((op = getopt(argc, argv, "t:")) != -1) {
+ switch (op) {
+ case 't':
+ g_time_in_sec = atoi(optarg);
+ break;
+ default:
+ usage(argv[0]);
+ exit(1);
+ }
+ }
+
+ if (!g_time_in_sec) {
+ usage(argv[0]);
+ exit(1);
+ }
+
+ rc = spdk_app_start(&opts, test_start, NULL, NULL);
+
+ spdk_app_fini();
+
+ return rc;
+}
diff --git a/src/spdk/test/event/reactor_perf/.gitignore b/src/spdk/test/event/reactor_perf/.gitignore
new file mode 100644
index 00000000..32160228
--- /dev/null
+++ b/src/spdk/test/event/reactor_perf/.gitignore
@@ -0,0 +1 @@
+reactor_perf
diff --git a/src/spdk/test/event/reactor_perf/Makefile b/src/spdk/test/event/reactor_perf/Makefile
new file mode 100644
index 00000000..820a6042
--- /dev/null
+++ b/src/spdk/test/event/reactor_perf/Makefile
@@ -0,0 +1,54 @@
+#
+# BSD LICENSE
+#
+# Copyright (c) Intel Corporation.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
+include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
+include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
+
+APP = reactor_perf
+C_SRCS := reactor_perf.c
+
+SPDK_LIB_LIST = event trace conf thread util log rpc jsonrpc json
+
+LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS)
+
+all : $(APP)
+ @:
+
+$(APP) : $(OBJS) $(SPDK_LIB_FILES) $(ENV_LIBS)
+ $(LINK_C)
+
+clean :
+ $(CLEAN_C) $(APP)
+
+include $(SPDK_ROOT_DIR)/mk/spdk.deps.mk
diff --git a/src/spdk/test/event/reactor_perf/reactor_perf.c b/src/spdk/test/event/reactor_perf/reactor_perf.c
new file mode 100644
index 00000000..357f9038
--- /dev/null
+++ b/src/spdk/test/event/reactor_perf/reactor_perf.c
@@ -0,0 +1,144 @@
+/*-
+ * BSD LICENSE
+ *
+ * Copyright (c) Intel Corporation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "spdk/stdinc.h"
+
+#include "spdk/env.h"
+#include "spdk/event.h"
+#include "spdk/thread.h"
+
+static int g_time_in_sec;
+static int g_queue_depth;
+static struct spdk_poller *test_end_poller;
+static uint64_t g_call_count = 0;
+
+static int
+__test_end(void *arg)
+{
+ printf("test_end\n");
+ spdk_app_stop(0);
+ return -1;
+}
+
+static void
+__submit_next(void *arg1, void *arg2)
+{
+ struct spdk_event *event;
+
+ g_call_count++;
+
+ event = spdk_event_allocate(spdk_env_get_current_core(),
+ __submit_next, NULL, NULL);
+ spdk_event_call(event);
+}
+
+static void
+test_start(void *arg1, void *arg2)
+{
+ int i;
+
+ printf("test_start\n");
+
+ /* Register a poller that will stop the test after the time has elapsed. */
+ test_end_poller = spdk_poller_register(__test_end, NULL,
+ g_time_in_sec * 1000000ULL);
+
+ for (i = 0; i < g_queue_depth; i++) {
+ __submit_next(NULL, NULL);
+ }
+}
+
+static void
+test_cleanup(void)
+{
+ printf("test_abort\n");
+
+ spdk_poller_unregister(&test_end_poller);
+ spdk_app_stop(0);
+}
+
+static void
+usage(const char *program_name)
+{
+ printf("%s options\n", program_name);
+ printf("\t[-d Allowed delay when passing messages between cores in microseconds]\n");
+ printf("\t[-q Queue depth (default: 1)]\n");
+ printf("\t[-t time in seconds]\n");
+}
+
+int
+main(int argc, char **argv)
+{
+ struct spdk_app_opts opts;
+ int op;
+ int rc;
+
+ spdk_app_opts_init(&opts);
+ opts.name = "reactor_perf";
+ opts.max_delay_us = 1000;
+
+ g_time_in_sec = 0;
+ g_queue_depth = 1;
+
+ while ((op = getopt(argc, argv, "d:q:t:")) != -1) {
+ switch (op) {
+ case 'd':
+ opts.max_delay_us = atoi(optarg);
+ break;
+ case 'q':
+ g_queue_depth = atoi(optarg);
+ break;
+ case 't':
+ g_time_in_sec = atoi(optarg);
+ break;
+ default:
+ usage(argv[0]);
+ exit(1);
+ }
+ }
+
+ if (!g_time_in_sec) {
+ usage(argv[0]);
+ exit(1);
+ }
+
+ opts.shutdown_cb = test_cleanup;
+
+ rc = spdk_app_start(&opts, test_start, NULL, NULL);
+
+ spdk_app_fini();
+
+ printf("Performance: %8ju events per second\n", g_call_count / g_time_in_sec);
+
+ return rc;
+}