summaryrefslogtreecommitdiffstats
path: root/vespalib/src/apps
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@yahooinc.com>2022-12-01 14:53:34 +0000
committerHåvard Pettersen <havardpe@yahooinc.com>2022-12-01 15:45:59 +0000
commit5d9eac1a85bca46a0bfb4296a0414c71b7aba867 (patch)
tree972cd766663cb7856069652e3cbcabc9fa007adc /vespalib/src/apps
parente6058f9f2370298dd40f15090307106ae98773f5 (diff)
added simple program to probe io_uring support
Diffstat (limited to 'vespalib/src/apps')
-rw-r--r--vespalib/src/apps/vespa-probe-io-uring/.gitignore1
-rw-r--r--vespalib/src/apps/vespa-probe-io-uring/CMakeLists.txt9
-rw-r--r--vespalib/src/apps/vespa-probe-io-uring/probe_io_uring.cpp95
3 files changed, 105 insertions, 0 deletions
diff --git a/vespalib/src/apps/vespa-probe-io-uring/.gitignore b/vespalib/src/apps/vespa-probe-io-uring/.gitignore
new file mode 100644
index 00000000000..9fa20bbf9d4
--- /dev/null
+++ b/vespalib/src/apps/vespa-probe-io-uring/.gitignore
@@ -0,0 +1 @@
+/vespa-probe-io-uring
diff --git a/vespalib/src/apps/vespa-probe-io-uring/CMakeLists.txt b/vespalib/src/apps/vespa-probe-io-uring/CMakeLists.txt
new file mode 100644
index 00000000000..24ceda46a87
--- /dev/null
+++ b/vespalib/src/apps/vespa-probe-io-uring/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+vespa_add_executable(vespalib_vespa-probe-io-uring_app
+ SOURCES
+ probe_io_uring.cpp
+ OUTPUT_NAME vespa-probe-io-uring
+ INSTALL bin
+ DEPENDS
+ vespalib
+)
diff --git a/vespalib/src/apps/vespa-probe-io-uring/probe_io_uring.cpp b/vespalib/src/apps/vespa-probe-io-uring/probe_io_uring.cpp
new file mode 100644
index 00000000000..ef3e6ddbef2
--- /dev/null
+++ b/vespalib/src/apps/vespa-probe-io-uring/probe_io_uring.cpp
@@ -0,0 +1,95 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include <vespa/config.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef VESPA_HAS_IO_URING
+
+#include <sys/utsname.h>
+#include <liburing.h>
+#include <liburing/io_uring.h>
+
+#include <string>
+#include <vector>
+
+std::vector<std::string> op_names = {
+ "IORING_OP_NOP",
+ "IORING_OP_READV",
+ "IORING_OP_WRITEV",
+ "IORING_OP_FSYNC",
+ "IORING_OP_READ_FIXED",
+ "IORING_OP_WRITE_FIXED",
+ "IORING_OP_POLL_ADD",
+ "IORING_OP_POLL_REMOVE",
+ "IORING_OP_SYNC_FILE_RANGE",
+ "IORING_OP_SENDMSG",
+ "IORING_OP_RECVMSG",
+ "IORING_OP_TIMEOUT",
+ "IORING_OP_TIMEOUT_REMOVE",
+ "IORING_OP_ACCEPT",
+ "IORING_OP_ASYNC_CANCEL",
+ "IORING_OP_LINK_TIMEOUT",
+ "IORING_OP_CONNECT",
+ "IORING_OP_FALLOCATE",
+ "IORING_OP_OPENAT",
+ "IORING_OP_CLOSE",
+ "IORING_OP_FILES_UPDATE",
+ "IORING_OP_STATX",
+ "IORING_OP_READ",
+ "IORING_OP_WRITE",
+ "IORING_OP_FADVISE",
+ "IORING_OP_MADVISE",
+ "IORING_OP_SEND",
+ "IORING_OP_RECV",
+ "IORING_OP_OPENAT2",
+ "IORING_OP_EPOLL_CTL",
+ "IORING_OP_SPLICE",
+ "IORING_OP_PROVIDE_BUFFERS",
+ "IORING_OP_REMOVE_BUFFERS",
+ "IORING_OP_TEE",
+ "IORING_OP_SHUTDOWN",
+ "IORING_OP_RENAMEAT",
+ "IORING_OP_UNLINKAT",
+ "IORING_OP_MKDIRAT",
+ "IORING_OP_SYMLINKAT",
+ "IORING_OP_LINKAT",
+ "IORING_OP_MSG_RING",
+ "IORING_OP_FSETXATTR",
+ "IORING_OP_SETXATTR",
+ "IORING_OP_FGETXATTR",
+ "IORING_OP_GETXATTR",
+ "IORING_OP_SOCKET",
+ "IORING_OP_URING_CMD",
+ "IORING_OP_SEND_ZC",
+ "IORING_OP_SENDMSG_ZC"
+};
+
+int main() {
+ fprintf(stderr, "Vespa was compiled with io_uring\n");
+ utsname host_info;
+ uname(&host_info);
+ fprintf(stderr, "kernel version: %s\n", host_info.release);
+ io_uring_probe *probe = io_uring_get_probe();
+ if (probe == nullptr) {
+ fprintf(stderr, "io_uring probe failed!\n");
+ return 1;
+ }
+ fprintf(stderr, "operation support: {\n");
+ for (size_t i = 0; i < op_names.size(); ++i) {
+ fprintf(stderr, " %s: %s\n", op_names[i].c_str(),
+ io_uring_opcode_supported(probe, i) ? "yes" : "no");
+ }
+ fprintf(stderr, "}\n");
+ free(probe);
+ return 0;
+}
+
+#else // VESPA_HAS_IO_URING
+
+int main() {
+ fprintf(stderr, "Vespa was compiled without io_uring\n");
+ return 1;
+}
+
+#endif // VESPA_HAS_IO_URING