diff --git a/atomic.go b/atomic.go new file mode 100644 index 0000000..2316f0e --- /dev/null +++ b/atomic.go @@ -0,0 +1,13 @@ +package gouring + +import _ "unsafe" + +var io_uring_smp_mb = io_uring_smp_mb_fallback + +func io_uring_smp_mb_fallback() +func io_uring_smp_mb_mfence() + +func init() { + // temporary + io_uring_smp_mb = io_uring_smp_mb_mfence +} diff --git a/atomic_amd64.s b/atomic_amd64.s new file mode 100644 index 0000000..ca88946 --- /dev/null +++ b/atomic_amd64.s @@ -0,0 +1,12 @@ +#include "go_asm.h" +#include "funcdata.h" +#include "textflag.h" + +TEXT ·io_uring_smp_mb_fallback(SB), NOSPLIT, $0 + LOCK + ORQ $0, 0(SP) + RET + +TEXT ·io_uring_smp_mb_mfence(SB), NOSPLIT, $0 + MFENCE + RET diff --git a/queue.go b/queue.go index 42cd98f..6fbbcd0 100644 --- a/queue.go +++ b/queue.go @@ -19,7 +19,8 @@ func (ring *IoUring) sq_ring_needs_enter(flags *uint32) bool { return true } - // FIXME: io_uring_smp_mb + // FIXME: Extra call - no inline asm. + io_uring_smp_mb() if atomic.LoadUint32(ring.Sq._Flags())&IORING_SQ_NEED_WAKEUP != 0 { *flags |= IORING_ENTER_SQ_WAKEUP