Documentation ¶
Index ¶
- Constants
- func Close(sqe *SQEntry, fd uintptr)
- func Fdatasync(sqe *SQEntry, fd uintptr)
- func Fsync(sqe *SQEntry, fd uintptr)
- func LinkTimeout(sqe *SQEntry, ts *unix.Timespec, abs bool)
- func Nop(sqe *SQEntry)
- func Openat(sqe *SQEntry, dfd int32, pathptr *byte, flags uint32, mode uint32)
- func Read(sqe *SQEntry, fd uintptr, buf []byte)
- func ReadFixed(sqe *SQEntry, fd uintptr, base *byte, len, offset uint64, flags uint32, ...)
- func Readv(sqe *SQEntry, fd uintptr, iovec []syscall.Iovec, offset uint64, flags uint32)
- func Recv(sqe *SQEntry, fd uintptr, buf []byte, flags uint32)
- func Send(sqe *SQEntry, fd uintptr, buf []byte, flags uint32)
- func Timeout(sqe *SQEntry, ts *unix.Timespec, abs bool, count uint64)
- func Write(sqe *SQEntry, fd uintptr, buf []byte)
- func WriteFixed(sqe *SQEntry, fd uintptr, base *byte, len, offset uint64, flags uint32, ...)
- func Writev(sqe *SQEntry, fd uintptr, iovec []syscall.Iovec, offset uint64, flags uint32)
- type CQEntry
- type CQRingOffsets
- type IOUringFilesUpdate
- type IOUringParams
- type Probe
- type ProbeOp
- type Ring
- func (r *Ring) CQSize() uint32
- func (r *Ring) Close() (err error)
- func (r *Ring) CloseEventfd() error
- func (r *Ring) Enter(submitted uint32, minComplete uint32) (uint32, error)
- func (r *Ring) Eventfd() uintptr
- func (r *Ring) Fd() uintptr
- func (r *Ring) Flush() uint32
- func (r *Ring) GetCQEntry(minComplete uint32) (CQEntry, error)
- func (r *Ring) GetSQEntry() *SQEntry
- func (r *Ring) RegisterBuffers(iovec []syscall.Iovec) error
- func (r *Ring) RegisterFiles(fds []int32) error
- func (r *Ring) RegisterProbe(probe *Probe) error
- func (r *Ring) SQSize() uint32
- func (r *Ring) SetupEventfd() error
- func (r *Ring) Submit(minComplete uint32) (uint32, error)
- func (r *Ring) UnregisterBuffers() error
- func (r *Ring) UnregisterFiles() error
- func (r *Ring) UpdateFiles(fds []int32, off uint32) error
- type SQEntry
- func (e *SQEntry) Reset()
- func (e *SQEntry) SetAddr(addr uint64)
- func (e *SQEntry) SetAddr2(addr2 uint64)
- func (e *SQEntry) SetBufGroup(group uint16)
- func (e *SQEntry) SetBufIndex(index uint16)
- func (e *SQEntry) SetFD(fd int32)
- func (e *SQEntry) SetFlags(flags uint8)
- func (e *SQEntry) SetIOPrio(ioprio uint16)
- func (e *SQEntry) SetLen(len uint32)
- func (e *SQEntry) SetOffset(off uint64)
- func (e *SQEntry) SetOpcode(opcode uint8)
- func (e *SQEntry) SetOpcodeFlags(flags uint32)
- func (e *SQEntry) SetPersonality(personality uint16)
- func (e *SQEntry) SetSpliceFdIn(val int32)
- func (e *SQEntry) SetSpliceOffIn(val uint64)
- func (e *SQEntry) SetUserData(ud uint64)
- func (e *SQEntry) UserData() uint64
- type SQRingOffsets
- type Sigset_t
Constants ¶
const ( IO_URING_SETUP uintptr = 425 + iota IO_URING_ENTER IO_URING_REGISTER )
syscalls
const ( IORING_OP_NOP uint8 = iota IORING_OP_READV IORING_OP_WRITEV IORING_OP_FSYNC IORING_OP_READ_FIXED IORING_OP_WRITE_FIXED IORING_OP_POLL_ADD IORING_OP_POLL_REMOVE IORING_OP_SYNC_FILE_RANGE IORING_OP_SENDMSG IORING_OP_RECVMSG IORING_OP_TIMEOUT IORING_OP_TIMEOUT_REMOVE IORING_OP_ACCEPT IORING_OP_ASYNC_CANCEL IORING_OP_LINK_TIMEOUT IORING_OP_CONNECT IORING_OP_FALLOCATE IORING_OP_OPENAT IORING_OP_CLOSE IORING_OP_FILES_UPDATE IORING_OP_STATX IORING_OP_READ IORING_OP_WRITE IORING_OP_FADVISE IORING_OP_MADVISE IORING_OP_SEND IORING_OP_RECV IORING_OP_OPENAT2 IORING_OP_EPOLL_CTL IORING_OP_SPLICE IORING_OP_PROVIDE_BUFFERS IORING_OP_REMOVE_BUFFERS IORING_OP_TEE IORING_OP_LAST )
operations
const ( IOSQE_FIXED_FILE uint8 = 1 << iota IOSQE_IO_DRAIN IOSQE_IO_LINK IOSQE_IO_HARDLINK IOSQE_ASYNC IOSQE_BUFFER_SELECT )
submission queue entry flags
const ( IORING_SETUP_IOPOLL uint32 = 1 << iota IORING_SETUP_SQPOLL IORING_SETUP_SQ_AFF IORING_SETUP_CQSIZE IORING_SETUP_CLAMP IORING_SETUP_ATTACH_WQ )
setup flags
const ( IORING_OFF_SQ_RING int64 = 0 IORING_OFF_CQ_RING int64 = 0x8000000 IORING_OFF_SQES int64 = 0x10000000 )
offsets for mmap
const ( IORING_SQ_NEED_WAKEUP uint32 = 1 << iota IORING_SQ_CQ_OVERFLOW )
sq ring flags
const ( IORING_ENTER_GETEVENTS uint32 = 1 << iota IORING_ENTER_SQ_WAKEUP )
enter flags
const ( IORING_FEAT_SINGLE_MMAP uint32 = 1 << iota IORING_FEAT_NODROP IORING_FEAT_SUBMIT_STABLE IORING_FEAT_RW_CUR_POS IORING_FEAT_CUR_PERSONALITY IORING_FEAT_FAST_POLL IORING_FEAT_POLL_32BITS )
params feature flags
const ( IORING_REGISTER_BUFFERS uintptr = iota IORING_UNREGISTER_BUFFERS IORING_REGISTER_FILES IORING_UNREGISTER_FILES IORING_REGISTER_EVENTFD IORING_UNREGISTER_EVENTFD IORING_REGISTER_FILES_UPDATE IORING_REGISTER_EVENTFD_ASYNC IORING_REGISTER_PROBE IORING_REGISTER_PERSONALITY IORING_UNREGISTER_PERSONALITY )
const ( MinSize = 2 MaxSize = 4096 )
const IORING_CQE_BUFFER_SHIFT uint32 = 16
const IORING_CQE_F_BUFFER uint32 = 1 << 0
cqe flags
const IORING_CQ_EVENTFD_DISABLED uint32 = 1 << 0
cqe ring flags
const IORING_FSYNC_DATASYNC uint32 = 1 << 0
sqe fsync flags
const IORING_TIMEOUT_ABS uint32 = 1 << 0
sqe timeout flags
const ( // IO_URING_OP_SUPPORTED ... IO_URING_OP_SUPPORTED uint16 = 1 << 0 )
const SPLICE_F_FD_IN_FIXED uint32 = 1 << 31
sqe splice flags
Variables ¶
This section is empty.
Functions ¶
func LinkTimeout ¶
LinkTimeout will cancel linked operation if it doesn't complete in time.
func ReadFixed ¶
func ReadFixed(sqe *SQEntry, fd uintptr, base *byte, len, offset uint64, flags uint32, bufIndex uint16)
ReadFixed ...
func Timeout ¶
Timeout operation. if abs is true then IORING_TIMEOUT_ABS will be added to timeoutFlags. count is the number of events to wait.
Types ¶
type CQEntry ¶
type CQEntry struct {
// contains filtered or unexported fields
}
CQEntry is a submission queue entry. Filled in by kernel, applications should not modify it.
type CQRingOffsets ¶
type CQRingOffsets struct { Head uint32 Tail uint32 RingMask uint32 RingEntries uint32 Overflow uint32 CQEs uint32 Flags uint32 Resv1 uint32 Resv2 uint64 }
CQRingOffsets ...
type IOUringFilesUpdate ¶
type IOUringParams ¶
type IOUringParams struct { SQEntries uint32 CQEntries uint32 Flags uint32 SQThreadCPU uint32 SQThreadIdle uint32 Features uint32 WQFd uint32 SQOff SQRingOffsets CQOff CQRingOffsets // contains filtered or unexported fields }
IOUringParams can be used to control io_uring instance behavior. For more details see manpages for IO_URING_SETUP(2).
IORING_SETUP_* can be passed to Flags to enable specific behaviour.
Specifying CQEntries will be ignored unlless IORING_SETUP_CQSIZE provided.
SQThreadIdle is in milliseconds and controls amount of time SQ thread can be idle before it will be put to sleep by kernel.
SQThreadCPU if specified together with IORING_SETUP_SQ_AFF to bound SQ thread to specific CPU.
WQFd can be used to share kernel thread worker pool between multiple io_uring instances. Ignored unless specified with IORING_SETUP_ATTACH_WQ. For an example see queue.ShardedQueue and relevant tests.
Other fields should be ignored, as they are filled in by the kernel. TODO those fields can be private, SQOff and CQOff should be definitely private
type Probe ¶
type Probe struct { LastOp uint8 OpsLen uint8 Ops [probeOpsSize]ProbeOp // contains filtered or unexported fields }
Probe ...
func (Probe) IsSupported ¶
IsSupported returns true if operation is supported.
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
Ring is an interface to io_uring kernel framework. Not safe to use from multiple goroutines without additional synchronization. API is inspired mostly by liburing.
func (*Ring) CloseEventfd ¶
CloseEventfd unregsiters eventfd from uring istance and closes associated fd.
func (*Ring) Eventfd ¶
Eventfd is a eventfd for this uring instance. Call ring.Setupeventfd() to setup one.
func (*Ring) GetCQEntry ¶
GetCQEntry returns entry from completion queue, performing IO_URING_ENTER syscall if necessary. CQE is copied from mmaped region to avoid additional sync step after CQE was consumed. syscall.EAGAIN will be returned if there are no completed entries and minComplete is 0. syscall.EINTR will be returned if IO_URING_ENTER was interrupted while waiting for completion.
func (*Ring) GetSQEntry ¶
GetSQEntry returns earliest available SQEntry. May return nil if there are no available entries. Entry can be reused after Submit or Enter.
sqe := ring.GetSQEntry() ring.Submit(0)
... or ...
sqe := ring.GetSQEntry() ring.Flush() ring.Enter(1, 0)
func (*Ring) RegisterBuffers ¶
RegisterBuffers ...
func (*Ring) SetupEventfd ¶
SetupEventfd creates eventfd and registers it with current uring instance.
type SQEntry ¶
type SQEntry struct {
// contains filtered or unexported fields
}
SQEntry is a submission queue entry. In C some of the fields are unions. Golang doesn't support union declaration, instead SQEntry provided setters with descriptive names.
func (*SQEntry) SetPersonality ¶
SetPersonality ...