From 684ce94729d68e84fd7ab6067998781fdc891358 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Thu, 11 Jun 2020 16:12:42 +0200 Subject: Track cqe and sqe usage --- uring.c | 6 ++++++ uring.h | 3 +++ utils.c | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/uring.c b/uring.c index 78a084a..9075327 100644 --- a/uring.c +++ b/uring.c @@ -16,6 +16,9 @@ struct uring_ev { struct uring_task task; }; +uint64_t sqe_count = 0; +uint64_t cqe_count = 0; + static struct io_uring_sqe * get_sqe(struct cfg *cfg, struct uring_task *task) { @@ -32,6 +35,7 @@ get_sqe(struct cfg *cfg, struct uring_task *task) perrordie("Failed to get an sqe!\n"); } + sqe_count++; uring_task_get(cfg, task); return sqe; } @@ -548,6 +552,8 @@ uring_event_loop(struct cfg *cfg) struct uring_task *task = io_uring_cqe_get_data(cqe); bool do_callback; + cqe_count++; + if (!task) die("%s: null task\n", __func__); diff --git a/uring.h b/uring.h index 11fd656..680684a 100644 --- a/uring.h +++ b/uring.h @@ -1,6 +1,9 @@ #ifndef foouringhfoo #define foouringhfoo +extern uint64_t sqe_count; +extern uint64_t cqe_count; + void uring_task_refdump(struct uring_task *task); void uring_task_destroy(struct cfg *cfg, struct uring_task *task); diff --git a/utils.c b/utils.c index 93bc0b8..0718ea9 100644 --- a/utils.c +++ b/utils.c @@ -11,9 +11,11 @@ #include #include #include +#include #include "main.h" #include "utils.h" +#include "uring.h" static unsigned total_malloc_count = 0; static int malloc_count = 0; @@ -156,6 +158,9 @@ debug_resource_usage() fprintf(stderr, "Lost file descriptor(s)\n"); exit(EXIT_FAILURE); } + + fprintf(stderr, "CQEs used: %" PRIu64 ", SQEs used: %" PRIu64 "\n", + cqe_count, sqe_count); } void -- cgit v1.2.3