You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by cm...@apache.org on 2024/02/01 16:39:53 UTC

(trafficserver) branch master updated: Cleanup io_uring. (#11019)

This is an automated email from the ASF dual-hosted git repository.

cmcfarlen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new e935f3e2a3 Cleanup io_uring. (#11019)
e935f3e2a3 is described below

commit e935f3e2a311e0960dee41ccff224c24ad781e39
Author: Chris McFarlen <ch...@mcfarlen.us>
AuthorDate: Thu Feb 1 10:39:47 2024 -0600

    Cleanup io_uring. (#11019)
    
    * Cleanup io_uring.
    
    * Change Gauge to counter in test
    
    ---------
    
    Co-authored-by: Chris McFarlen <cm...@apple.com>
---
 include/iocore/io_uring/IO_URING.h            |  4 ++++
 src/iocore/aio/test_AIO.cc                    |  6 +++---
 src/iocore/io_uring/CMakeLists.txt            | 10 ++++++----
 src/iocore/io_uring/io_uring.cc               |  1 -
 src/iocore/io_uring/unit_tests/test_diskIO.cc |  9 ++++-----
 5 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/include/iocore/io_uring/IO_URING.h b/include/iocore/io_uring/IO_URING.h
index 3192600f4c..18201a7732 100644
--- a/include/iocore/io_uring/IO_URING.h
+++ b/include/iocore/io_uring/IO_URING.h
@@ -53,6 +53,10 @@ public:
   next_sqe(IOUringCompletionHandler *handler)
   {
     io_uring_sqe *result = io_uring_get_sqe(&ring);
+    if (result == nullptr) {
+      submit();
+      result = io_uring_get_sqe(&ring);
+    }
     if (result != nullptr) {
       io_uring_sqe_set_data(result, handler);
     }
diff --git a/src/iocore/aio/test_AIO.cc b/src/iocore/aio/test_AIO.cc
index 4de1ba8c56..3daa770d52 100644
--- a/src/iocore/aio/test_AIO.cc
+++ b/src/iocore/aio/test_AIO.cc
@@ -222,10 +222,10 @@ dump_summary()
   printf("-----------------\n");
 
   auto completed = Metrics::Counter::lookup("proxy.process.io_uring.completed", nullptr);
-  auto completed = Metrics::Counter::lookup("proxy.process.io_uring.submitted", nullptr);
+  auto submitted = Metrics::Counter::lookup("proxy.process.io_uring.submitted", nullptr);
 
-  printf("submissions: %lu\n", Metrics::Gauge::load(submitted));
-  printf("completions: %lu\n", Metrics::Gauge::load(completed));
+  printf("submissions: %lu\n", Metrics::Counter::load(submitted));
+  printf("completions: %lu\n", Metrics::Counter::load(completed));
 #endif
 
   if (delete_disks) {
diff --git a/src/iocore/io_uring/CMakeLists.txt b/src/iocore/io_uring/CMakeLists.txt
index 68018c2387..4c5e586e21 100644
--- a/src/iocore/io_uring/CMakeLists.txt
+++ b/src/iocore/io_uring/CMakeLists.txt
@@ -24,9 +24,11 @@ target_link_libraries(
   PRIVATE ts::tsutil
 )
 
-add_executable(test_iouring unit_tests/test_diskIO.cc)
-target_link_libraries(test_iouring PRIVATE inkuring libswoc::libswoc tsutil catch2::catch2)
+if(BUILD_TESTING)
+  add_executable(test_iouring unit_tests/test_diskIO.cc)
+  target_link_libraries(test_iouring PRIVATE inkuring libswoc::libswoc tsutil catch2::catch2)
 
-target_include_directories(test_iouring PRIVATE ${CATCH_INCLUDE_DIR})
+  target_include_directories(test_iouring PRIVATE ${CATCH_INCLUDE_DIR})
 
-add_test(NAME test_iouring COMMAND $<TARGET_FILE:test_iouring>)
+  add_test(NAME test_iouring COMMAND $<TARGET_FILE:test_iouring>)
+endif()
diff --git a/src/iocore/io_uring/io_uring.cc b/src/iocore/io_uring/io_uring.cc
index 52680f232d..b92aa7e30f 100644
--- a/src/iocore/io_uring/io_uring.cc
+++ b/src/iocore/io_uring/io_uring.cc
@@ -45,7 +45,6 @@ struct IOUringStatsBlock {
 };
 
 static IOUringStatsBlock io_uring_rsb = []() {
-  auto &intm = Metrics::getInstance();
   return IOUringStatsBlock{Metrics::Counter::createPtr("proxy.process.io_uring.submitted"),
                            Metrics::Counter::createPtr("proxy.process.io_uring.completed")};
 }();
diff --git a/src/iocore/io_uring/unit_tests/test_diskIO.cc b/src/iocore/io_uring/unit_tests/test_diskIO.cc
index e6fceb042a..83ef5d0614 100644
--- a/src/iocore/io_uring/unit_tests/test_diskIO.cc
+++ b/src/iocore/io_uring/unit_tests/test_diskIO.cc
@@ -22,6 +22,7 @@
  */
 #define CATCH_CONFIG_MAIN
 #include <atomic>
+#include <fcntl.h>
 #include "catch.hpp"
 
 #include "swoc/swoc_file.h"
@@ -265,14 +266,12 @@ TEST_CASE("net_io", "[io_uring]")
     connected = true;
   });
 
-  auto &m = Metrics::getInstance();
+  const auto *completed = Metrics::Counter::lookup("proxy.process.io_uring.completed", nullptr);
 
-  Metrics::Counter::AtomicType *completed = m.lookup(m.lookup("proxy.process.io_uring.completed"));
-
-  uint64_t completions_before = Metrics::Gauge::load(completed);
+  uint64_t completions_before = Metrics::Counter::load(completed);
   uint64_t needed             = 2;
 
-  while ((Metrics::Gauge::load(completed) - completions_before) < needed) {
+  while ((Metrics::Counter::load(completed) - completions_before) < needed) {
     ctx.submit_and_wait(1 * HRTIME_SECOND);
   }