From 35c7c72601cee9692846de13117411d80b3d13f6 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 27 Nov 2024 20:10:19 -0500 Subject: ioq: Add an ioq_nop() operation for benchmarking --- src/ioq.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/ioq.h') diff --git a/src/ioq.h b/src/ioq.h index cb14be4..fce1d7f 100644 --- a/src/ioq.h +++ b/src/ioq.h @@ -22,6 +22,8 @@ struct ioq; * I/O queue operations. */ enum ioq_op { + /** ioq_nop(). */ + IOQ_NOP, /** ioq_close(). */ IOQ_CLOSE, /** ioq_opendir(). */ @@ -32,6 +34,16 @@ enum ioq_op { IOQ_STAT, }; +/** + * ioq_nop() types. + */ +enum ioq_nop_type { + /** A lightweight nop that avoids syscalls. */ + IOQ_NOP_LIGHT, + /** A heavyweight nop that involves a syscall. */ + IOQ_NOP_HEAVY, +}; + /** * The I/O queue implementation needs two tag bits in each pointer to a struct * ioq_ent, so we need to ensure at least 4-byte alignment. The natural @@ -54,6 +66,10 @@ struct ioq_ent { /** Operation-specific arguments. */ union { + /** ioq_nop() args. */ + struct ioq_nop { + enum ioq_nop_type type; + } nop; /** ioq_close() args. */ struct ioq_close { int fd; @@ -97,6 +113,20 @@ struct ioq *ioq_create(size_t depth, size_t nthreads); */ size_t ioq_capacity(const struct ioq *ioq); +/** + * A no-op, for benchmarking. + * + * @ioq + * The I/O queue. + * @type + * The type of operation to perform. + * @ptr + * An arbitrary pointer to associate with the request. + * @return + * 0 on success, or -1 on failure. + */ +int ioq_nop(struct ioq *ioq, enum ioq_nop_type type, void *ptr); + /** * Asynchronous close(). * -- cgit v1.2.3