summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2020-12-17 09:22:14 -0700
committerJens Axboe <axboe@kernel.dk>2020-12-17 09:22:14 -0700
commit662f7d2256b13abe26a5baa65875811a5880d92b (patch)
tree4ea3dd96370f28f4ccfcd9ba378a8d8be5328847
parent28322d35045e4f9371227edb399b9d728f7ad21e (diff)
parent6b951560f4f144d83d740b1333f4822ec82e7650 (diff)
downloadliburing-662f7d2256b13abe26a5baa65875811a5880d92b.tar.gz
liburing-662f7d2256b13abe26a5baa65875811a5880d92b.tar.bz2
Merge branch 'liburing-add-branch-helpers' of https://github.com/goldsteinn/liburing
* 'liburing-add-branch-helpers' of https://github.com/goldsteinn/liburing: Added __builtin_expect macros and wrapped IORING_ENTER_SQ_WAKEUP branch
-rw-r--r--src/include/liburing.h8
-rw-r--r--src/queue.c9
2 files changed, 13 insertions, 4 deletions
diff --git a/src/include/liburing.h b/src/include/liburing.h
index ebfc424..520cd55 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -15,6 +15,14 @@
#include "liburing/io_uring.h"
#include "liburing/barrier.h"
+#ifndef uring_unlikely
+# define uring_unlikely(cond) __builtin_expect(!!(cond), 0)
+#endif
+
+#ifndef uring_likely
+# define uring_likely(cond) __builtin_expect(!!(cond), 1)
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/src/queue.c b/src/queue.c
index df388f6..8c4f373 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -25,10 +25,11 @@ static inline bool sq_ring_needs_enter(struct io_uring *ring, unsigned *flags)
{
if (!(ring->flags & IORING_SETUP_SQPOLL))
return true;
- if (IO_URING_READ_ONCE(*ring->sq.kflags) & IORING_SQ_NEED_WAKEUP) {
- *flags |= IORING_ENTER_SQ_WAKEUP;
- return true;
- }
+ if (uring_unlikely(IO_URING_READ_ONCE(*ring->sq.kflags) &
+ IORING_SQ_NEED_WAKEUP)) {
+ *flags |= IORING_ENTER_SQ_WAKEUP;
+ return true;
+ }
return false;
}