Documentation
¶
Overview ¶
Package uring provides the kernel-boundary `io_uring` surface for Linux 6.18+. `uring` assumes the 6.18+ baseline and carries no fallback branches for older kernels. Its core Linux `io_uring` implementation was refactored from `code.hybscloud.com/sox` into this dedicated package. It prepares SQEs, decodes CQEs, transports submission context through `user_data`, and exposes kernel-boundary facts. Dispatch, retry, completion correlation, and connection/session orchestration stay in caller-side runtime code above this boundary.
A typical caller starts the ring, submits an operation, and then treats the completion queue as the source of truth for kernel results. Semantic no-progress conditions such as iox.ErrWouldBlock are classified through iox.Classify instead of being treated as ordinary failures.
ring, err := uring.New(func(opt *uring.Options) {
opt.Entries = uring.EntriesMedium
})
if err != nil {
return err
}
if err := ring.Start(); err != nil {
return err
}
defer ring.Stop()
fd := iofd.NewFD(int(file.Fd()))
buf := make([]byte, 4096)
ctx := uring.PackDirect(uring.IORING_OP_READ, 0, 0, 0).WithFD(fd)
if err := ring.Read(ctx, buf); err != nil {
return err
}
cqes := make([]uring.CQEView, 64)
var backoff iox.Backoff
for {
n, err := ring.Wait(cqes)
switch iox.Classify(err) {
case iox.OutcomeWouldBlock:
backoff.Wait()
continue
case iox.OutcomeFailure:
return err
}
if n == 0 {
backoff.Wait()
continue
}
backoff.Reset()
for i := range n {
cqe := cqes[i]
if cqe.Op() != uring.IORING_OP_READ || cqe.FD() != fd {
continue
}
if err := cqe.Err(); err != nil {
return fmt.Errorf("uring read failed: %w", err)
}
handle(buf[:int(cqe.Res)])
return nil
}
}
Uring.SubmitAcceptMultishot, Uring.SubmitReceiveMultishot, and Uring.SubmitReceiveBundleMultishot submit raw multishot SQEs and keep the kernel-boundary flow explicit. Uring.AcceptMultishot and Uring.ReceiveMultishot use the same kernel path and return a MultishotSubscription for caller-owned callback dispatch in the same serialized completion loop. If caller code keeps copied CQEs beyond that loop, it must keep its own route state and reject observations for retired subscriptions.
sqeCtx := uring.ForFD(listenerFD)
sub, err := ring.AcceptMultishot(sqeCtx, handler)
if err != nil {
return err
}
// Process CQEs in the same serialized completion loop.
for i := range n {
if sub.HandleCQE(cqes[i]) {
continue
}
dispatch(ring, cqes[i])
}
// Cancel when done
// On single-issuer rings, call Cancel from the ring owner or otherwise
// serialize it with submit, Wait, WaitDirect, WaitExtended, Stop, and ResizeRings.
if err := sub.Cancel(); err != nil {
return err
}
Listener setup advances with DecodeListenerCQE, PrepareListenerBind, PrepareListenerListen, and SetListenerReady. ListenerManager is a thin convenience for the initial SOCKET submission and returns a ListenerOp. If ListenerOp.Close races a pending listener setup CQE, drain that CQE before the final Close that returns the pooled listener context.
pool := uring.NewContextPools(16)
manager := uring.NewListenerManager(ring, pool)
addr := &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 8080}
op, err := manager.ListenTCP4(addr, 128, handler)
// Caller decodes CQEs and chains bind→listen via Prepare helpers
// After LISTEN completes, start accepting:
acceptSub, err := op.AcceptMultishot(acceptHandler)
Extended-mode raw `UserData` is caller-beware storage. Prefer scalar payloads there; if raw overlays or typed context views place Go pointers, interfaces, func values, maps, slices, strings, chans, or structs containing them in those bytes, caller code must keep the live roots outside `UserData`.
SQEContext packs submission metadata into `user_data`.
Direct mode layout (inline context, zero allocation):
┌─────────┬─────────┬──────────────┬────────────────────────────┬────┐ │ Op (8b) │Flags(8b)│ BufGrp (16b) │ FD (30b) │Mode│ └─────────┴─────────┴──────────────┴────────────────────────────┴────┘ Bits 0-7 Bits 8-15 Bits 16-31 Bits 32-61 Bits 62-63
Mode bits (62-63): 00=Direct, 01=Indirect (64B ptr), 10=Extended (128B ptr)
Pack context for submission:
ctx := uring.PackDirect(
uring.IORING_OP_RECV, // Op: operation type
0, // Flags: SQE flags
bufferGroupID, // BufGroup: for buffer selection
clientFD, // FD: target file descriptor
)
If `IOSQE_FIXED_FILE` is set, the FD field stores the registered file index instead of a raw file descriptor.
Or use the fluent builder:
ctx := uring.ForFD(clientFD).WithOp(uring.IORING_OP_RECV).WithBufGroup(groupID)
Handler Patterns ¶
Handler helpers provide convenience step/action adapters. They do not change the underlying CQE facts and are optional.
Subscriber pattern (functional callbacks):
handler := uring.NewMultishotSubscriber().
OnStep(func(step uring.MultishotStep) uring.MultishotAction {
if step.Err == nil {
return uring.MultishotContinue
}
return uring.MultishotStop
}).
OnStop(func(err error, cancelled bool) {
log.Println("stopped", err, cancelled)
})
Noop embedding pattern (override only needed methods):
type myHandler struct {
uring.NoopMultishotHandler
connections int
}
func (h *myHandler) OnMultishotStep(step uring.MultishotStep) uring.MultishotAction {
if step.Err == nil && step.CQE.Res >= 0 {
h.connections++
return uring.MultishotContinue
}
return h.NoopMultishotHandler.OnMultishotStep(step)
}
Handlers either return `MultishotContinue` to keep a live subscription, or `MultishotStop` to request cancellation after the current step. The request is local until the cancel SQE is successfully enqueued.
Multishot Subscription Lifecycle ¶
A live subscription keeps its submitted ExtSQE until the terminal CQE for that operation is handled. The kernel may emit multiple CQEs for the same submission before that terminal CQE; each non-terminal CQE carries `IORING_CQE_F_MORE`. The package keeps the submitted ExtSQE and encoded `user_data` associated with the subscription, and returns the ExtSQE to its pool only after handling a CQE without `HasMore()`. Caller-side runtime code should treat intermediate CQEs as progress for the live subscription and the final CQE as the point where the subscription can be retired.
Runtime Boundary ¶
uring is a kernel boundary, not a scheduler. It owns SQE encoding, CQE observation, `user_data` identity, capability exposure, and kernel-facing lifetimes. Runtime policy, connection routing, batching, retries, parking, and terminal resource release belong above this package.
Buffer Groups ¶
Buffer groups enable kernel-side buffer selection for receive operations. The kernel picks an available buffer from the group at completion time; userspace does not select or assign buffers per receive. The package exposes three practical buffer-management paths: registered fixed buffers for fixed-buffer file I/O, provided buffers selected by the kernel, and bundle receives over contiguous ranges of provided buffers.
opts := uring.OptionsForBudget(256 * uring.MiB)
ring, err := uring.New(func(opt *uring.Options) {
*opt = opts
})
if err != nil {
return err
}
cfg, scale := uring.BufferConfigForBudget(256 * uring.MiB)
fmt.Printf("buffer tiers=%+v scale=%d\n", cfg, scale)
A registered fixed buffer is ring-owned memory addressed by index. Keep the buffer live until the fixed operation completes.
fd := iofd.NewFD(int(file.Fd()))
buf := ring.RegisteredBuffer(0)
copy(buf, payload)
writeCtx := uring.PackDirect(uring.IORING_OP_WRITE_FIXED, 0, 0, 0).WithFD(fd)
if err := ring.WriteFixed(writeCtx, 0, len(payload)); err != nil {
return err
}
For socket receive with kernel buffer selection, pass nil as the receive buffer and request the desired read-buffer size class. The matching CQE reports which buffer group and buffer ID were consumed.
recvCtx := uring.PackDirect(uring.IORING_OP_RECV, 0, 0, 0)
if err := ring.Receive(recvCtx, &socketFD, nil, uring.WithReadBufferSize(uring.BufferSizeSmall)); err != nil {
return err
}
if cqe.HasBuffer() {
fmt.Printf("kernel selected group=%d id=%d\n", cqe.BufGroup(), cqe.BufID())
}
Bundle receives may consume more than one provided buffer in one CQE. Process the iterator and then recycle the consumed slots.
if err := ring.ReceiveBundle(recvCtx, &socketFD, uring.WithReadBufferSize(uring.BufferSizeSmall)); err != nil {
return err
}
if it, ok := ring.BundleIterator(cqe, cqe.BufGroup()); ok {
for buf := range it.All() {
handle(buf)
}
it.Recycle(ring)
}
Supported Operations ¶
Socket creation:
- TCP: Uring.TCP4Socket, Uring.TCP6Socket, Uring.TCP4SocketDirect, Uring.TCP6SocketDirect
- UDP: Uring.UDP4Socket, Uring.UDP6Socket, Uring.UDP4SocketDirect, Uring.UDP6SocketDirect
- UDPLITE: Uring.UDPLITE4Socket, Uring.UDPLITE6Socket, Uring.UDPLITE4SocketDirect, Uring.UDPLITE6SocketDirect
- SCTP: Uring.SCTP4Socket, Uring.SCTP6Socket, Uring.SCTP4SocketDirect, Uring.SCTP6SocketDirect
- Unix: Uring.UnixSocket, Uring.UnixSocketDirect
- Generic: Uring.SocketRaw, Uring.SocketDirect
Socket operations:
- Uring.Bind, Uring.Listen, Uring.Accept, Uring.AcceptDirect, Uring.Connect, Uring.Shutdown
- Uring.Receive, Uring.Send, Uring.RecvMsg, Uring.SendMsg
- Uring.ReceiveBundle, Uring.ReceiveZeroCopy
- Uring.Multicast, Uring.MulticastZeroCopy
- Raw multishot submits: Uring.SubmitAcceptMultishot, Uring.SubmitAcceptDirectMultishot, Uring.SubmitReceiveMultishot, Uring.SubmitReceiveBundleMultishot
- Helper-backed multishot subscriptions: Uring.AcceptMultishot, Uring.ReceiveMultishot
File operations:
- Uring.Read, Uring.Write, Uring.ReadV, Uring.WriteV
- Uring.ReadFixed, Uring.WriteFixed, Uring.ReadvFixed, Uring.WritevFixed with registered buffers
- Uring.OpenAt, Uring.Close, Uring.Sync, Uring.Fallocate, Uring.FTruncate
- Uring.Statx, Uring.RenameAt, Uring.UnlinkAt, Uring.MkdirAt, Uring.SymlinkAt, Uring.LinkAt
- Uring.FGetXattr, Uring.FSetXattr, Uring.GetXattr, Uring.SetXattr
- Uring.Splice, Uring.Tee, Uring.Pipe for zero-copy data transfer
- Uring.SyncFileRange, Uring.FileAdvise
- Uring.Close submits `IORING_OP_CLOSE` for the target file descriptor; it does not tear down the ring itself
Control operations:
- Uring.Timeout, Uring.TimeoutRemove, Uring.TimeoutUpdate, Uring.LinkTimeout
- Uring.AsyncCancel, Uring.AsyncCancelFD, Uring.AsyncCancelOpcode, Uring.AsyncCancelAny, Uring.AsyncCancelAll
- Uring.PollAdd, Uring.PollRemove, Uring.PollUpdate, Uring.PollAddLevel, Uring.PollAddMultishot, Uring.PollAddMultishotLevel
- Uring.EpollWait, Uring.FutexWait, Uring.FutexWake, Uring.FutexWaitV, Uring.Waitid
- Uring.MsgRing, Uring.MsgRingFD
- Uring.FixedFdInstall, Uring.FilesUpdate
- Uring.UringCmd
- Uring.Nop
Registration:
- Files: Uring.RegisterFiles, Uring.RegisterFilesSparse, Uring.RegisterFilesUpdate, Uring.UnregisterFiles, Uring.RegisteredFileCount
- Buffers: Uring.RegisterBufRingMMAP, Uring.RegisterBufRingIncremental, Uring.RegisterBufRingWithFlags, Uring.RegisteredBuffer, Uring.RegisteredBufferCount
- Buffer cloning: Uring.CloneBuffers, Uring.CloneBuffersFromRegistered
- Memory: Uring.RegisterMemRegion
- NAPI: Uring.RegisterNAPI, Uring.UnregisterNAPI, Uring.NAPIAddStaticID, Uring.NAPIDelStaticID
Ring management:
- Uring.Start, Uring.Stop, Uring.Wait, Uring.ResizeRings
- Uring.SQAvailable, Uring.CQPending, Uring.RingFD
- Uring.ExtSQE, Uring.PutExtSQE, Uring.IndirectSQE, Uring.PutIndirectSQE, Uring.SubmitExtended
Capability queries:
Zero-copy receive (ZCRX):
- Uring.QueryZCRX, Uring.RegisterZCRXIfq
- NewZCRXReceiver is wired for rings created with 32-byte CQEs. The current Options surface does not expose `IORING_SETUP_CQE32`, so rings created through the standard New path return ErrNotSupported from this constructor. Until a CQE32 setup path is exposed, the receiver docs describe the boundary contract rather than a runnable public setup recipe.
Performance ¶
The hot submit and reap paths are designed to remain zero-allocation. See the benchmark tests for current machine-specific numbers.
Ring Setup ¶
Create and start an io_uring instance:
ring, err := uring.New(func(opt *uring.Options) {
opt.Entries = uring.EntriesMedium // 2048 entries
})
if err != nil {
return err
}
if err := ring.Start(); err != nil {
return err
}
Memory Barriers ¶
The package uses dwcas.BarrierAcquire and dwcas.BarrierRelease for SQ/CQ ring synchronization. On amd64 (TSO), these are compiler barriers. On arm64, they emit DMB ISHLD/ISHST instructions. User code does not manage these barriers.
Dependencies ¶
- code.hybscloud.com/zcall: Zero-overhead syscalls
- code.hybscloud.com/iox: Non-blocking I/O semantics and error types
- code.hybscloud.com/iofd: File descriptor abstractions
- code.hybscloud.com/iobuf: Buffer pools and aligned memory
- code.hybscloud.com/sock: Socket types and address handling
- code.hybscloud.com/dwcas: Memory barriers for ring synchronization
- code.hybscloud.com/spin: Spin-wait primitives
- code.hybscloud.com/framer: Message framing for length-prefix encoding
Index ¶
- Constants
- Variables
- func AlignedMemBlock() []byte
- func CastUserData[T any](ext *ExtSQE) *T
- func CompletionError(res int32) error
- func ContextUserData[T any](ctx context.Context) T
- func ContextWithUserData[T any](ctx context.Context, val T) context.Context
- func PrepareListenerBind(ext *ExtSQE, fd iofd.FD)
- func PrepareListenerListen(ext *ExtSQE, fd iofd.FD)
- func PrepareListenerSocket(ext *ExtSQE, domain, sockType, proto int, sa Sockaddr, backlog int, ...) error
- func SetListenerReady(ext *ExtSQE)
- type Addr
- type AttrPI
- type BigBuffer
- type BufferGroupsConfig
- type BundleIterator
- func (it BundleIterator) All() iter.Seq[[]byte]
- func (it BundleIterator) AllWithSlotID() iter.Seq2[uint16, []byte]
- func (it BundleIterator) Buffer(index int) []byte
- func (it BundleIterator) Collect() [][]byte
- func (it BundleIterator) CopyTo(dst []byte) int
- func (it BundleIterator) Count() int
- func (it BundleIterator) Recycle(ur *Uring)
- func (it BundleIterator) SlotID(index int) uint16
- func (it BundleIterator) TotalBytes() int
- type CQEView
- func (c *CQEView) BufGroup() uint16
- func (c *CQEView) BufID() uint16
- func (c *CQEView) BundleBuffers(bufferSize int) (startID uint16, count int)
- func (c *CQEView) BundleCount(bufferSize int) int
- func (c *CQEView) BundleStartID() uint16
- func (c *CQEView) Context() SQEContext
- func (c *CQEView) Err() error
- func (c *CQEView) ExtSQE() *ExtSQE
- func (c *CQEView) Extended() bool
- func (c *CQEView) FD() iofd.FD
- func (c *CQEView) FullSQE() bool
- func (c *CQEView) HasBuffer() bool
- func (c *CQEView) HasBufferMore() bool
- func (c *CQEView) HasMore() bool
- func (c *CQEView) IsNotification() bool
- func (c *CQEView) Op() uint8
- func (c *CQEView) SQE() SQEView
- func (c *CQEView) SocketNonEmpty() bool
- type CloneBuffers
- type ContextPools
- func (p *ContextPools) Capacity() int
- func (p *ContextPools) Extended() *ExtSQE
- func (p *ContextPools) ExtendedAvailable() int
- func (p *ContextPools) Indirect() *IndirectSQE
- func (p *ContextPools) IndirectAvailable() int
- func (p *ContextPools) PutExtended(ext *ExtSQE)
- func (p *ContextPools) PutIndirect(indirect *IndirectSQE)
- func (p *ContextPools) Reset()
- type Ctx0
- type Ctx0V1
- type Ctx0V2
- type Ctx0V3
- type Ctx0V4
- type Ctx0V5
- type Ctx0V6
- type Ctx0V7
- type Ctx1
- type Ctx1V1
- type Ctx1V2
- type Ctx1V3
- type Ctx1V4
- type Ctx1V5
- type Ctx1V6
- type Ctx2
- type Ctx2V1
- type Ctx2V2
- type Ctx2V3
- type Ctx2V4
- type Ctx2V5
- type Ctx3
- type Ctx3V1
- type Ctx3V2
- type Ctx3V3
- type Ctx3V4
- type Ctx4
- type Ctx4V1
- type Ctx4V2
- type Ctx4V3
- type Ctx5
- type Ctx5V1
- type Ctx5V2
- type Ctx6
- type Ctx6V1
- type Ctx7
- type CtxRefs0
- type CtxRefs1
- type CtxRefs2
- type CtxRefs3
- type CtxRefs4
- type CtxRefs5
- type CtxRefs6
- type CtxRefs7
- type DirectCQE
- type EpollEvent
- type ExtCQE
- type ExtSQE
- type Features
- type GiantBuffer
- type GreatBuffer
- type Handler
- type HugeBuffer
- type IncrementalHandler
- type IncrementalReceiver
- type IncrementalSubscriber
- func (s *IncrementalSubscriber) Handler() IncrementalHandler
- func (s *IncrementalSubscriber) OnComplete(fn func()) *IncrementalSubscriber
- func (s *IncrementalSubscriber) OnData(fn func(buf []byte, hasMore bool)) *IncrementalSubscriber
- func (s *IncrementalSubscriber) OnError(fn func(err error)) *IncrementalSubscriber
- type IndirectSQE
- type IoTimespec
- type IoVec
- type LargeBuffer
- type ListenerHandler
- type ListenerManager
- func (m *ListenerManager) ListenTCP4(addr *net.TCPAddr, backlog int, handler ListenerHandler) (*ListenerOp, error)
- func (m *ListenerManager) ListenTCP6(addr *net.TCPAddr, backlog int, handler ListenerHandler) (*ListenerOp, error)
- func (m *ListenerManager) ListenUnix(addr *net.UnixAddr, backlog int, handler ListenerHandler) (*ListenerOp, error)
- func (m *ListenerManager) Pool() *ContextPools
- func (m *ListenerManager) Ring() *Uring
- type ListenerOp
- type ListenerState
- type ListenerStep
- type ListenerSubscriber
- func (s *ListenerSubscriber) Handler() ListenerHandler
- func (s *ListenerSubscriber) OnBound(fn func() bool) *ListenerSubscriber
- func (s *ListenerSubscriber) OnError(fn func(op uint8, err error)) *ListenerSubscriber
- func (s *ListenerSubscriber) OnListening(fn func()) *ListenerSubscriber
- func (s *ListenerSubscriber) OnSocketCreated(fn func(fd iofd.FD) bool) *ListenerSubscriber
- type MediumBuffer
- type MemRegionReg
- type MicroBuffer
- type Msghdr
- type MultishotAction
- type MultishotHandler
- type MultishotStep
- type MultishotSubscriber
- func (s *MultishotSubscriber) Handler() MultishotHandler
- func (s *MultishotSubscriber) OnMultishotStep(step MultishotStep) MultishotAction
- func (s *MultishotSubscriber) OnMultishotStop(err error, cancelled bool)
- func (s *MultishotSubscriber) OnStep(fn func(step MultishotStep) MultishotAction) *MultishotSubscriber
- func (s *MultishotSubscriber) OnStop(fn func(err error, cancelled bool)) *MultishotSubscriber
- type MultishotSubscription
- type NanoBuffer
- type NapiReg
- type NetworkType
- type NoopIncrementalHandler
- type NoopListenerHandler
- type NoopMultishotHandler
- type NoopZCHandler
- type NoopZCRXHandler
- type OpOption
- type OpOptionFunc
- func WithBacklog(n int) OpOptionFunc
- func WithCount(cnt int) OpOptionFunc
- func WithDuration(d time.Duration) OpOptionFunc
- func WithFadvise(advice int) OpOptionFunc
- func WithFileIndex(idx uint32) OpOptionFunc
- func WithFileMode(mode os.FileMode) OpOptionFunc
- func WithFlags(flags uint8) OpOptionFunc
- func WithFsyncDataSync() OpOptionFunc
- func WithIOPrio(ioprio uint16) OpOptionFunc
- func WithIOPrioClass(class, level uint8) OpOptionFunc
- func WithN(n int) OpOptionFunc
- func WithOffset(offset int64) OpOptionFunc
- func WithPersonality(id uint16) OpOptionFunc
- func WithReadBufferSize(n int) OpOptionFunc
- func WithSpliceFlags(flags uint32) OpOptionFunc
- func WithTimeoutAbsolute() OpOptionFunc
- func WithTimeoutBootTime() OpOptionFunc
- func WithTimeoutEtimeSuccess() OpOptionFunc
- func WithTimeoutFlags(flags uint32) OpOptionFunc
- func WithTimeoutMultishot() OpOptionFunc
- func WithTimeoutRealTime() OpOptionFunc
- func WithWriteBufferSize(n int) OpOptionFunc
- type OpenHow
- type OptionFunc
- type Options
- type PicoBuffer
- type PollCloser
- type PollFd
- type QueryHdr
- type QueryOpcode
- type QuerySCQ
- type QueryZCRX
- type RawSockaddr
- type RawSockaddrAny
- type RawSockaddrInet4
- type RawSockaddrInet6
- type RawSockaddrUnix
- type RegWait
- type RegionDesc
- type RegisterBuffer
- type RegisterBufferPool
- type SQEContext
- func (c SQEContext) BufGroup() uint16
- func (c SQEContext) ExtSQE() *ExtSQE
- func (c SQEContext) FD() int32
- func (c SQEContext) Flags() uint8
- func (c SQEContext) HasBufferSelect() bool
- func (c SQEContext) IndirectSQE() *IndirectSQE
- func (c SQEContext) IsDirect() bool
- func (c SQEContext) IsExtended() bool
- func (c SQEContext) IsIndirect() bool
- func (c SQEContext) Mode() SQEContext
- func (c SQEContext) Op() uint8
- func (c SQEContext) OrFlags(flags uint8) SQEContext
- func (c SQEContext) Raw() uint64
- func (c SQEContext) WithBufGroup(bufGroup uint16) SQEContext
- func (c SQEContext) WithFD(fd iofd.FD) SQEContext
- func (c SQEContext) WithFlags(flags uint8) SQEContext
- func (c SQEContext) WithOp(op uint8) SQEContext
- type SQEView
- func (v SQEView) Addr() uint64
- func (v SQEView) BufGroup() uint16
- func (v SQEView) BufIndex() uint16
- func (v SQEView) FD() iofd.FD
- func (v SQEView) FileIndex() uint32
- func (v SQEView) Flags() uint8
- func (v SQEView) HasAsync() bool
- func (v SQEView) HasBufferSelect() bool
- func (v SQEView) HasCQESkipSuccess() bool
- func (v SQEView) HasFixedFile() bool
- func (v SQEView) HasIODrain() bool
- func (v SQEView) HasIOHardlink() bool
- func (v SQEView) HasIOLink() bool
- func (v SQEView) IoPrio() uint16
- func (v SQEView) Len() uint32
- func (v SQEView) Off() uint64
- func (v SQEView) Opcode() uint8
- func (v SQEView) Personality() uint16
- func (v SQEView) RawFD() int32
- func (v SQEView) SpliceFDIn() int32
- func (v SQEView) UFlags() uint32
- func (v SQEView) UserData() uint64
- func (v SQEView) Valid() bool
- type ScopedExtSQE
- type SendTargets
- type SmallBuffer
- type Sockaddr
- type Socket
- type Statx
- type StatxTimestamp
- type SubscriptionState
- type Timespec
- type TitanBuffer
- type UnderlyingProtocol
- type Uring
- func (ur *Uring) Accept(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) AcceptDirect(sqeCtx SQEContext, fileIndex uint32, options ...OpOptionFunc) error
- func (ur *Uring) AcceptMultishot(sqeCtx SQEContext, handler MultishotHandler, options ...OpOptionFunc) (*MultishotSubscription, error)
- func (ur *Uring) AsyncCancel(sqeCtx SQEContext, targetUserData uint64, options ...OpOptionFunc) error
- func (ur *Uring) AsyncCancelAll(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) AsyncCancelAny(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) AsyncCancelFD(sqeCtx SQEContext, cancelAll bool, options ...OpOptionFunc) error
- func (ur *Uring) AsyncCancelOpcode(sqeCtx SQEContext, opcode uint8, cancelAll bool, options ...OpOptionFunc) error
- func (ur *Uring) Bind(sqeCtx SQEContext, addr Addr, options ...OpOptionFunc) error
- func (ur *Uring) BundleIterator(cqe CQEView, group uint16) (BundleIterator, bool)
- func (ur *Uring) CQPending() int
- func (ur *Uring) CloneBuffers(srcFD int, srcOff, dstOff, count uint32, replace bool) error
- func (ur *Uring) CloneBuffersFromRegistered(srcRegisteredIdx int, srcOff, dstOff, count uint32, replace bool) error
- func (ur *Uring) Close(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) Connect(sqeCtx SQEContext, remote Addr, options ...OpOptionFunc) error
- func (ur *Uring) EpollWait(sqeCtx SQEContext, events []EpollEvent, timeout int32, options ...OpOptionFunc) error
- func (ur *Uring) ExtSQE() *ExtSQE
- func (ur *Uring) FGetXattr(sqeCtx SQEContext, name string, value []byte, options ...OpOptionFunc) error
- func (ur *Uring) FSetXattr(sqeCtx SQEContext, name string, value []byte, flags int, ...) error
- func (ur *Uring) FTruncate(sqeCtx SQEContext, length int64, options ...OpOptionFunc) error
- func (ur *Uring) Fallocate(sqeCtx SQEContext, mode uint32, offset int64, length int64, ...) error
- func (ur *Uring) FileAdvise(sqeCtx SQEContext, offset int64, length int, advice int, ...) error
- func (ur *Uring) FilesUpdate(sqeCtx SQEContext, fds []int32, offset int, options ...OpOptionFunc) error
- func (ur *Uring) FixedFdInstall(sqeCtx SQEContext, fixedIndex int, flags uint32, options ...OpOptionFunc) error
- func (ur *Uring) FutexWait(sqeCtx SQEContext, addr *uint32, val uint64, mask uint64, flags uint32, ...) error
- func (ur *Uring) FutexWaitV(sqeCtx SQEContext, waitv unsafe.Pointer, count uint32, flags uint32, ...) error
- func (ur *Uring) FutexWake(sqeCtx SQEContext, addr *uint32, val uint64, mask uint64, flags uint32, ...) error
- func (ur *Uring) GetXattr(sqeCtx SQEContext, path, name string, value []byte, options ...OpOptionFunc) error
- func (ur *Uring) IndirectSQE() *IndirectSQE
- func (ur *Uring) LinkAt(sqeCtx SQEContext, oldDirfd int, oldPath, newPath string, flags int, ...) error
- func (ur *Uring) LinkTimeout(sqeCtx SQEContext, d time.Duration, options ...OpOptionFunc) error
- func (ur *Uring) Listen(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) MkdirAt(sqeCtx SQEContext, path string, mode uint32, options ...OpOptionFunc) error
- func (ur *Uring) MsgRing(sqeCtx SQEContext, userData int64, result int32, options ...OpOptionFunc) error
- func (ur *Uring) MsgRingFD(sqeCtx SQEContext, srcFD uint32, dstSlot uint32, userData int64, skipCQE bool, ...) error
- func (ur *Uring) Multicast(sqeCtx SQEContext, targets SendTargets, bufIndex int, p []byte, offset int64, ...) error
- func (ur *Uring) MulticastZeroCopy(sqeCtx SQEContext, targets SendTargets, bufIndex int, offset int64, n int, ...) error
- func (ur *Uring) MustExtSQE() *ExtSQE
- func (ur *Uring) NAPIAddStaticID(napiID uint32) error
- func (ur *Uring) NAPIDelStaticID(napiID uint32) error
- func (ur *Uring) NewScopedExtSQE() ScopedExtSQE
- func (ur *Uring) Nop(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) Nop128(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) OpenAt(sqeCtx SQEContext, pathname string, openFlags int, mode uint32, ...) error
- func (ur *Uring) Pipe(sqeCtx SQEContext, fds *[2]int32, pipeFlags uint32, options ...OpOptionFunc) error
- func (ur *Uring) PollAdd(sqeCtx SQEContext, events int, options ...OpOptionFunc) error
- func (ur *Uring) PollAddLevel(sqeCtx SQEContext, events int, options ...OpOptionFunc) error
- func (ur *Uring) PollAddMultishot(sqeCtx SQEContext, events int, options ...OpOptionFunc) error
- func (ur *Uring) PollAddMultishotLevel(sqeCtx SQEContext, events int, options ...OpOptionFunc) error
- func (ur *Uring) PollRemove(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) PollUpdate(sqeCtx SQEContext, oldUserData, newUserData uint64, newEvents, updateFlags int, ...) error
- func (ur *Uring) PutExtSQE(sqe *ExtSQE)
- func (ur *Uring) PutIndirectSQE(sqe *IndirectSQE)
- func (ur *Uring) QueryOpcodes() (*QueryOpcode, error)
- func (ur *Uring) QuerySCQ() (*QuerySCQ, error)
- func (ur *Uring) QueryZCRX() (*QueryZCRX, error)
- func (ur *Uring) Read(sqeCtx SQEContext, b []byte, options ...OpOptionFunc) error
- func (ur *Uring) ReadFixed(sqeCtx SQEContext, bufIndex int, options ...OpOptionFunc) ([]byte, error)
- func (ur *Uring) ReadV(sqeCtx SQEContext, iovs [][]byte, options ...OpOptionFunc) error
- func (ur *Uring) ReadvFixed(sqeCtx SQEContext, offset int64, bufIndices []int, options ...OpOptionFunc) error
- func (ur *Uring) Receive(sqeCtx SQEContext, pollFD PollFd, b []byte, options ...OpOptionFunc) error
- func (ur *Uring) ReceiveBundle(sqeCtx SQEContext, pollFD PollFd, options ...OpOptionFunc) error
- func (ur *Uring) ReceiveMultishot(sqeCtx SQEContext, handler MultishotHandler, options ...OpOptionFunc) (*MultishotSubscription, error)
- func (ur *Uring) ReceiveZeroCopy(sqeCtx SQEContext, pollFD PollFd, n int, zcrxIfqIdx uint32, ...) error
- func (ur *Uring) RecvMsg(sqeCtx SQEContext, pollFD PollFd, buffers [][]byte, oob []byte, ...) error
- func (ur *Uring) RegisterBufRingIncremental(entries int, groupID uint16) (*ioUringBufRing, error)
- func (ur *Uring) RegisterBufRingMMAP(entries int, groupID uint16) (*ioUringBufRing, error)
- func (ur *Uring) RegisterBufRingWithFlags(entries int, groupID uint16, flags uint16) (*ioUringBufRing, error)
- func (ur *Uring) RegisterFiles(fds []int32) error
- func (ur *Uring) RegisterFilesSparse(count uint32) error
- func (ur *Uring) RegisterFilesUpdate(offset uint32, fds []int32) error
- func (ur *Uring) RegisterMemRegion(region *RegionDesc, flags uint64) error
- func (ur *Uring) RegisterNAPI(busyPollTimeout uint32, preferBusyPoll bool, strategy uint32) error
- func (ur *Uring) RegisterZCRXIfq(ifIdx, ifRxq uint32, rqEntries uint32, area *ZCRXAreaReg, region *RegionDesc, ...) (uint32, ZCRXOffsets, error)
- func (ur *Uring) RegisteredBuffer(index int) []byte
- func (ur *Uring) RegisteredBufferCount() int
- func (ur *Uring) RegisteredFileCount() int
- func (ur *Uring) RenameAt(sqeCtx SQEContext, oldPath, newPath string, flags int, options ...OpOptionFunc) error
- func (ur *Uring) ResizeRings(newSQSize, newCQSize uint32) error
- func (ur *Uring) RingFD() iofd.FD
- func (ur *Uring) SCTP4Socket(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) SCTP4SocketDirect(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) SCTP6Socket(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) SCTP6SocketDirect(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) SQAvailable() int
- func (ur *Uring) Send(sqeCtx SQEContext, pollFD PollFd, p []byte, options ...OpOptionFunc) error
- func (ur *Uring) SendMsg(sqeCtx SQEContext, pollFD PollFd, buffers [][]byte, oob []byte, to Addr, ...) error
- func (ur *Uring) SetXattr(sqeCtx SQEContext, path, name string, value []byte, flags int, ...) error
- func (ur *Uring) Shutdown(sqeCtx SQEContext, how int, options ...OpOptionFunc) error
- func (ur *Uring) SocketDirect(sqeCtx SQEContext, domain, typ, proto int, fileIndex uint32, ...) error
- func (ur *Uring) SocketRaw(sqeCtx SQEContext, domain, typ, proto int, options ...OpOptionFunc) error
- func (ur *Uring) Splice(sqeCtx SQEContext, fdIn int, n int, options ...OpOptionFunc) error
- func (ur *Uring) Start() (err error)
- func (ur *Uring) Statx(sqeCtx SQEContext, path string, flags, mask int, stat *Statx, ...) error
- func (ur *Uring) Stop() error
- func (ur *Uring) SubmitAcceptDirectMultishot(sqeCtx SQEContext, fileIndex uint32, options ...OpOptionFunc) error
- func (ur *Uring) SubmitAcceptMultishot(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) SubmitExtended(sqeCtx SQEContext) error
- func (ur *Uring) SubmitReceiveBundleMultishot(sqeCtx SQEContext, pollFD PollFd, options ...OpOptionFunc) error
- func (ur *Uring) SubmitReceiveMultishot(sqeCtx SQEContext, pollFD PollFd, b []byte, options ...OpOptionFunc) error
- func (ur *Uring) SymlinkAt(sqeCtx SQEContext, target, linkpath string, options ...OpOptionFunc) error
- func (ur *Uring) Sync(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) SyncFileRange(sqeCtx SQEContext, offset int64, length int, syncFlags int, ...) error
- func (ur *Uring) TCP4Socket(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) TCP4SocketDirect(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) TCP6Socket(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) TCP6SocketDirect(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) Tee(sqeCtx SQEContext, fdIn int, length int, options ...OpOptionFunc) error
- func (ur *Uring) Timeout(sqeCtx SQEContext, d time.Duration, options ...OpOptionFunc) error
- func (ur *Uring) TimeoutRemove(sqeCtx SQEContext, userData uint64, options ...OpOptionFunc) error
- func (ur *Uring) TimeoutUpdate(sqeCtx SQEContext, userData uint64, d time.Duration, absolute bool, ...) error
- func (ur *Uring) UDP4Socket(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) UDP4SocketDirect(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) UDP6Socket(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) UDP6SocketDirect(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) UDPLITE4Socket(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) UDPLITE4SocketDirect(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) UDPLITE6Socket(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) UDPLITE6SocketDirect(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) UnixSocket(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) UnixSocketDirect(sqeCtx SQEContext, options ...OpOptionFunc) error
- func (ur *Uring) UnlinkAt(sqeCtx SQEContext, path string, flags int, options ...OpOptionFunc) error
- func (ur *Uring) UnregisterFiles() error
- func (ur *Uring) UnregisterNAPI() error
- func (ur *Uring) UringCmd(sqeCtx SQEContext, cmdOp uint32, cmdData []byte, options ...OpOptionFunc) error
- func (ur *Uring) UringCmd128(sqeCtx SQEContext, cmdOp uint32, cmdData []byte, options ...OpOptionFunc) error
- func (ur *Uring) Wait(cqes []CQEView) (n int, err error)
- func (ur *Uring) WaitDirect(cqes []DirectCQE) (int, error)
- func (ur *Uring) WaitExtended(cqes []ExtCQE) (int, error)
- func (ur *Uring) Waitid(sqeCtx SQEContext, idtype, id int, infop unsafe.Pointer, options int, ...) error
- func (ur *Uring) WithExtSQE(fn func(ext *ExtSQE) error) error
- func (ur *Uring) Write(sqeCtx SQEContext, b []byte, options ...OpOptionFunc) error
- func (ur *Uring) WriteFixed(sqeCtx SQEContext, bufIndex int, n int, options ...OpOptionFunc) error
- func (ur *Uring) WriteV(sqeCtx SQEContext, iovs [][]byte, options ...OpOptionFunc) error
- func (ur *Uring) WritevFixed(sqeCtx SQEContext, offset int64, bufIndices []int, lengths []int, ...) error
- func (ur *Uring) ZCRXExport(zcrxID uint32) (int, error)
- func (ur *Uring) ZCRXFlushRQ(zcrxID uint32) error
- type VastBuffer
- type ZCHandler
- type ZCRXAreaReg
- type ZCRXBuffer
- type ZCRXConfig
- type ZCRXCqe
- type ZCRXCtrl
- type ZCRXHandler
- type ZCRXIfqReg
- type ZCRXOffsets
- type ZCRXReceiver
- type ZCRXRqe
- type ZCSubscriber
- type ZCTracker
Constants ¶
const ( KiB = 1 << 10 MiB = 1 << 20 GiB = 1 << 30 )
Memory size constants for budget specification.
const ( MachineMemory512MB = 512 * MiB MachineMemory1GB = 1 * GiB MachineMemory2GB = 2 * GiB MachineMemory4GB = 4 * GiB MachineMemory8GB = 8 * GiB MachineMemory16GB = 16 * GiB MachineMemory32GB = 32 * GiB MachineMemory64GB = 64 * GiB MachineMemory96GB = 96 * GiB MachineMemory128GB = 128 * GiB )
Common machine memory sizes for OptionsForSystem.
const ( BufferSizePico = iobuf.BufferSizePico // 32 B BufferSizeNano = iobuf.BufferSizeNano // 128 B BufferSizeMicro = iobuf.BufferSizeMicro // 512 B BufferSizeSmall = iobuf.BufferSizeSmall // 2 KiB BufferSizeMedium = iobuf.BufferSizeMedium // 8 KiB BufferSizeBig = iobuf.BufferSizeBig // 32 KiB BufferSizeLarge = iobuf.BufferSizeLarge // 128 KiB BufferSizeGreat = iobuf.BufferSizeGreat // 512 KiB BufferSizeHuge = iobuf.BufferSizeHuge // 2 MiB BufferSizeVast = iobuf.BufferSizeVast // 8 MiB BufferSizeGiant = iobuf.BufferSizeGiant // 32 MiB BufferSizeTitan = iobuf.BufferSizeTitan // 128 MiB )
Buffer size constants re-exported from iobuf for API compatibility. These follow a power-of-4 progression starting at 32 bytes.
const ( EPERM = uintptr(zcall.EPERM) EINTR = uintptr(zcall.EINTR) EAGAIN = uintptr(zcall.EAGAIN) EWOULDBLOCK = EAGAIN ENOMEM = uintptr(zcall.ENOMEM) EACCES = uintptr(zcall.EACCES) EFAULT = uintptr(zcall.EFAULT) EBUSY = uintptr(zcall.EBUSY) EEXIST = uintptr(zcall.EEXIST) ENAMETOOLONG = uintptr(zcall.ENAMETOOLONG) ENODEV = uintptr(zcall.ENODEV) EINVAL = uintptr(zcall.EINVAL) EPIPE = uintptr(zcall.EPIPE) EMFILE = uintptr(zcall.EMFILE) ENFILE = uintptr(zcall.ENFILE) ENOSYS = uintptr(zcall.ENOSYS) ENOTSUP = uintptr(zcall.ENOTSUP) EINPROGRESS = uintptr(zcall.EINPROGRESS) EALREADY = uintptr(zcall.EALREADY) ENOTSOCK = uintptr(zcall.ENOTSOCK) EDESTADDRREQ = uintptr(zcall.EDESTADDRREQ) EMSGSIZE = uintptr(zcall.EMSGSIZE) EPROTOTYPE = uintptr(zcall.EPROTOTYPE) ENOPROTOOPT = uintptr(zcall.ENOPROTOOPT) EPROTONOSUPPORT = uintptr(zcall.EPROTONOSUPPORT) EOPNOTSUPP = uintptr(zcall.EOPNOTSUPP) EAFNOSUPPORT = uintptr(zcall.EAFNOSUPPORT) EADDRINUSE = uintptr(zcall.EADDRINUSE) EADDRNOTAVAIL = uintptr(zcall.EADDRNOTAVAIL) ENETDOWN = uintptr(zcall.ENETDOWN) ENETUNREACH = uintptr(zcall.ENETUNREACH) ENETRESET = uintptr(zcall.ENETRESET) ECONNABORTED = uintptr(zcall.ECONNABORTED) ECONNRESET = uintptr(zcall.ECONNRESET) ENOBUFS = uintptr(zcall.ENOBUFS) EISCONN = uintptr(zcall.EISCONN) ENOTCONN = uintptr(zcall.ENOTCONN) ESHUTDOWN = uintptr(zcall.ESHUTDOWN) ETIMEDOUT = uintptr(zcall.ETIMEDOUT) ECONNREFUSED = uintptr(zcall.ECONNREFUSED) EHOSTDOWN = uintptr(zcall.EHOSTDOWN) EHOSTUNREACH = uintptr(zcall.EHOSTUNREACH) ECANCELED = uintptr(zcall.ECANCELED) )
Errno constants aliased from zcall for architecture-safe error handling.
const ( EntriesPico = 1 << 3 // 8 entries EntriesNano = 1 << 5 // 32 entries EntriesMicro = 1 << 7 // 128 entries EntriesSmall = 1 << 9 // 512 entries EntriesMedium = 1 << 11 // 2048 entries EntriesLarge = 1 << 13 // 8192 entries EntriesHuge = 1 << 15 // 32768 entries )
Uring entry count constants define submission queue sizes. The values scale by powers of four: 8, 32, 128, 512, 2048, 8192, and 32768.
const ( IORING_SETUP_IOPOLL = zcall.IORING_SETUP_IOPOLL IORING_SETUP_SQPOLL = zcall.IORING_SETUP_SQPOLL IORING_SETUP_SQ_AFF = zcall.IORING_SETUP_SQ_AFF IORING_SETUP_CQSIZE = zcall.IORING_SETUP_CQSIZE IORING_SETUP_CLAMP = zcall.IORING_SETUP_CLAMP IORING_SETUP_ATTACH_WQ = zcall.IORING_SETUP_ATTACH_WQ IORING_SETUP_R_DISABLED = zcall.IORING_SETUP_R_DISABLED IORING_SETUP_SUBMIT_ALL = zcall.IORING_SETUP_SUBMIT_ALL IORING_SETUP_COOP_TASKRUN = zcall.IORING_SETUP_COOP_TASKRUN IORING_SETUP_TASKRUN_FLAG = zcall.IORING_SETUP_TASKRUN_FLAG IORING_SETUP_SQE128 = zcall.IORING_SETUP_SQE128 IORING_SETUP_CQE32 = zcall.IORING_SETUP_CQE32 IORING_SETUP_SINGLE_ISSUER = zcall.IORING_SETUP_SINGLE_ISSUER IORING_SETUP_DEFER_TASKRUN = zcall.IORING_SETUP_DEFER_TASKRUN IORING_SETUP_NO_MMAP = zcall.IORING_SETUP_NO_MMAP IORING_SETUP_REGISTERED_FD_ONLY = zcall.IORING_SETUP_REGISTERED_FD_ONLY IORING_SETUP_NO_SQARRAY = zcall.IORING_SETUP_NO_SQARRAY IORING_SETUP_HYBRID_IOPOLL = zcall.IORING_SETUP_HYBRID_IOPOLL IORING_SETUP_CQE_MIXED = zcall.IORING_SETUP_CQE_MIXED // Allow both 16b and 32b CQEs IORING_SETUP_SQE_MIXED = zcall.IORING_SETUP_SQE_MIXED // Allow both 64b and 128b SQEs )
const ( IORING_ENTER_GETEVENTS = zcall.IORING_ENTER_GETEVENTS IORING_ENTER_SQ_WAKEUP = zcall.IORING_ENTER_SQ_WAKEUP IORING_ENTER_SQ_WAIT = zcall.IORING_ENTER_SQ_WAIT IORING_ENTER_EXT_ARG = zcall.IORING_ENTER_EXT_ARG IORING_ENTER_REGISTERED_RING = zcall.IORING_ENTER_REGISTERED_RING IORING_ENTER_ABS_TIMER = zcall.IORING_ENTER_ABS_TIMER // Absolute timeout IORING_ENTER_EXT_ARG_REG = zcall.IORING_ENTER_EXT_ARG_REG // Use registered wait region IORING_ENTER_NO_IOWAIT = zcall.IORING_ENTER_NO_IOWAIT // Skip I/O wait )
const ( IORING_OFF_SQ_RING int64 = 0 IORING_OFF_CQ_RING int64 = 0x8000000 IORING_OFF_SQES int64 = 0x10000000 IORING_OFF_PBUF_RING = 0x80000000 IORING_OFF_PBUF_SHIFT = 16 IORING_OFF_MMAP_MASK = 0xf8000000 )
const ( IORING_SQ_NEED_WAKEUP = 1 << iota IORING_SQ_CQ_OVERFLOW IORING_SQ_TASKRUN )
const ( IOSQE_FIXED_FILE = zcall.IOSQE_FIXED_FILE IOSQE_IO_DRAIN = zcall.IOSQE_IO_DRAIN IOSQE_IO_LINK = zcall.IOSQE_IO_LINK IOSQE_IO_HARDLINK = zcall.IOSQE_IO_HARDLINK IOSQE_ASYNC = zcall.IOSQE_ASYNC IOSQE_BUFFER_SELECT = zcall.IOSQE_BUFFER_SELECT IOSQE_CQE_SKIP_SUCCESS = zcall.IOSQE_CQE_SKIP_SUCCESS )
const ( IORING_POLL_ADD_MULTI = 1 << iota IORING_POLL_UPDATE_EVENTS IORING_POLL_UPDATE_USER_DATA IORING_POLL_ADD_LEVEL )
const ( IORING_ASYNC_CANCEL_ALL = 1 << iota IORING_ASYNC_CANCEL_FD IORING_ASYNC_CANCEL_ANY IORING_ASYNC_CANCEL_FD_FIXED IORING_ASYNC_CANCEL_USERDATA IORING_ASYNC_CANCEL_OP )
const ( IORING_CQE_F_BUFFER = 1 << 0 IORING_CQE_F_MORE = 1 << 1 IORING_CQE_F_SOCK_NONEMPTY = 1 << 2 IORING_CQE_F_NOTIF = 1 << 3 IORING_CQE_F_BUF_MORE = 1 << 4 // Buffer partially consumed (incremental mode) IORING_CQE_F_SKIP = 1 << 5 // Skip CQE (gap filler for ring wrap) IORING_CQE_F_32 = 1 << 15 // 32-byte CQE in mixed mode )
const ( IORING_REGISTER_BUFFERS = zcall.IORING_REGISTER_BUFFERS IORING_UNREGISTER_BUFFERS = zcall.IORING_UNREGISTER_BUFFERS IORING_REGISTER_FILES = zcall.IORING_REGISTER_FILES IORING_UNREGISTER_FILES = zcall.IORING_UNREGISTER_FILES IORING_REGISTER_EVENTFD = zcall.IORING_REGISTER_EVENTFD IORING_UNREGISTER_EVENTFD = zcall.IORING_UNREGISTER_EVENTFD IORING_REGISTER_FILES_UPDATE = zcall.IORING_REGISTER_FILES_UPDATE IORING_REGISTER_EVENTFD_ASYNC = zcall.IORING_REGISTER_EVENTFD_ASYNC IORING_REGISTER_PROBE = zcall.IORING_REGISTER_PROBE IORING_REGISTER_PERSONALITY = zcall.IORING_REGISTER_PERSONALITY IORING_UNREGISTER_PERSONALITY = zcall.IORING_UNREGISTER_PERSONALITY IORING_REGISTER_RESTRICTIONS = zcall.IORING_REGISTER_RESTRICTIONS IORING_REGISTER_ENABLE_RINGS = zcall.IORING_REGISTER_ENABLE_RINGS IORING_REGISTER_FILES2 = zcall.IORING_REGISTER_FILES2 IORING_REGISTER_FILES_UPDATE2 = zcall.IORING_REGISTER_FILES_UPDATE2 IORING_REGISTER_BUFFERS2 = zcall.IORING_REGISTER_BUFFERS2 IORING_REGISTER_BUFFERS_UPDATE = zcall.IORING_REGISTER_BUFFERS_UPDATE IORING_REGISTER_IOWQ_AFF = zcall.IORING_REGISTER_IOWQ_AFF IORING_UNREGISTER_IOWQ_AFF = zcall.IORING_UNREGISTER_IOWQ_AFF IORING_REGISTER_IOWQ_MAX_WORKERS = zcall.IORING_REGISTER_IOWQ_MAX_WORKERS IORING_REGISTER_RING_FDS = zcall.IORING_REGISTER_RING_FDS IORING_UNREGISTER_RING_FDS = zcall.IORING_UNREGISTER_RING_FDS IORING_REGISTER_PBUF_RING = zcall.IORING_REGISTER_PBUF_RING IORING_UNREGISTER_PBUF_RING = zcall.IORING_UNREGISTER_PBUF_RING IORING_REGISTER_SYNC_CANCEL = zcall.IORING_REGISTER_SYNC_CANCEL IORING_REGISTER_FILE_ALLOC_RANGE = zcall.IORING_REGISTER_FILE_ALLOC_RANGE IORING_REGISTER_PBUF_STATUS = zcall.IORING_REGISTER_PBUF_STATUS IORING_REGISTER_NAPI = zcall.IORING_REGISTER_NAPI IORING_UNREGISTER_NAPI = zcall.IORING_UNREGISTER_NAPI IORING_REGISTER_CLOCK = zcall.IORING_REGISTER_CLOCK // Register clock source IORING_REGISTER_CLONE_BUFFERS = zcall.IORING_REGISTER_CLONE_BUFFERS // Clone buffers from another ring IORING_REGISTER_SEND_MSG_RING = zcall.IORING_REGISTER_SEND_MSG_RING // Send MSG_RING without ring IORING_REGISTER_ZCRX_IFQ = zcall.IORING_REGISTER_ZCRX_IFQ // Register ZCRX interface queue IORING_REGISTER_RESIZE_RINGS = zcall.IORING_REGISTER_RESIZE_RINGS // Resize CQ ring IORING_REGISTER_MEM_REGION = zcall.IORING_REGISTER_MEM_REGION // Memory region setup (6.19+) IORING_REGISTER_QUERY = zcall.IORING_REGISTER_QUERY // Query ring state (6.19+) IORING_REGISTER_ZCRX_CTRL = zcall.IORING_REGISTER_ZCRX_CTRL // ZCRX control operations (6.19+) )
const ( FUTEX2_SIZE_U8 uint32 = 0x00 // 8-bit futex FUTEX2_SIZE_U16 uint32 = 0x01 // 16-bit futex FUTEX2_SIZE_U32 uint32 = 0x02 // 32-bit futex (most common) FUTEX2_SIZE_U64 uint32 = 0x03 // 64-bit futex FUTEX2_NUMA uint32 = 0x04 // NUMA-aware futex FUTEX2_PRIVATE uint32 = 128 // Private futex (process-local, faster) )
Futex2 flags for FutexWait/FutexWake operations. These follow the futex2(2) interface, not the legacy futex(2) v1 flags.
const ( // IORING_MSG_DATA sends data (result + userData) to target ring's CQ. IORING_MSG_DATA uint64 = 0 // IORING_MSG_SEND_FD transfers a fixed file from source to target ring. IORING_MSG_SEND_FD uint64 = 1 )
MSG_RING command types for the addr field.
const ( // IORING_MSG_RING_CQE_SKIP skips posting CQE to target ring. // The source ring still gets a completion. IORING_MSG_RING_CQE_SKIP uint32 = 1 << 0 // IORING_MSG_RING_FLAGS_PASS passes the specified flags to target CQE. IORING_MSG_RING_FLAGS_PASS uint32 = 1 << 1 )
MSG_RING flags for MsgRing operations.
const ( IOU_PBUF_RING_MMAP = 1 // Kernel allocates memory, app uses mmap IOU_PBUF_RING_INC = 2 // Incremental buffer consumption mode )
Buffer ring registration flags.
const ( IORING_ZCRX_AREA_SHIFT = 48 IORING_ZCRX_AREA_MASK = ^((uint64(1) << IORING_ZCRX_AREA_SHIFT) - 1) )
ZCRX area shift and mask for encoding area ID into offsets.
const ( ZCRX_CTRL_FLUSH_RQ = 0 // Flush refill queue ZCRX_CTRL_EXPORT = 1 // Export ZCRX state )
ZCRX control operations.
const ( IO_URING_QUERY_OPCODES = 0 // Query supported opcodes IO_URING_QUERY_ZCRX = 1 // Query ZCRX capabilities IO_URING_QUERY_SCQ = 2 // Query SQ/CQ ring info )
Query operation types for IORING_REGISTER_QUERY.
const ( IO_URING_NAPI_REGISTER_OP = 0 // Register/unregister (backward compatible) IO_URING_NAPI_STATIC_ADD_ID = 1 // Add NAPI ID with static tracking IO_URING_NAPI_STATIC_DEL_ID = 2 // Delete NAPI ID with static tracking )
NAPI operation types.
const ( IO_URING_NAPI_TRACKING_DYNAMIC = 0 // Dynamic tracking (default) IO_URING_NAPI_TRACKING_STATIC = 1 // Static tracking IO_URING_NAPI_TRACKING_INACTIVE = 255 // Inactive/disabled )
NAPI tracking strategies.
const ( SOCKET_URING_OP_SIOCINQ = 0 // Get input queue size SOCKET_URING_OP_SIOCOUTQ = 1 // Get output queue size SOCKET_URING_OP_GETSOCKOPT = 2 // Get socket option SOCKET_URING_OP_SETSOCKOPT = 3 // Set socket option SOCKET_URING_OP_TX_TIMESTAMP = 4 // TX timestamp support SOCKET_URING_OP_GETSOCKNAME = 5 // Get socket name )
Socket uring command operations.
const ( IORING_TIMESTAMP_HW_SHIFT = 16 // CQE flags bit shift for HW timestamp IORING_TIMESTAMP_TYPE_SHIFT = IORING_TIMESTAMP_HW_SHIFT + 1 // CQE flags bit shift for timestamp type IORING_CQE_F_TSTAMP_HW = 1 << IORING_TIMESTAMP_HW_SHIFT // Hardware timestamp flag )
Timestamp constants for SOCKET_URING_OP_TX_TIMESTAMP.
const ( IORING_NOP_INJECT_RESULT = 1 << 0 // Inject result from sqe->result IORING_NOP_FILE = 1 << 1 // NOP with file reference IORING_NOP_FIXED_FILE = 1 << 2 // NOP with fixed file IORING_NOP_FIXED_BUFFER = 1 << 3 // NOP with fixed buffer IORING_NOP_TW = 1 << 4 // NOP via task work IORING_NOP_CQE32 = 1 << 5 // NOP produces 32-byte CQE )
NOP operation flags for IORING_OP_NOP.
const ( IORING_REGISTER_SRC_REGISTERED = 1 << 0 // Source ring is registered IORING_REGISTER_DST_REPLACE = 1 << 1 // Replace destination buffers )
Clone buffers registration flags.
const ( IOPrioClassNone = 0 IOPrioClassRT = 1 // Real-time IOPrioClassBE = 2 // Best-effort IOPrioClassIDLE = 3 // Idle )
I/O priority class constants for WithIOPrioClass.
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_SHUTDOWN IORING_OP_RENAMEAT IORING_OP_UNLINKAT IORING_OP_MKDIRAT IORING_OP_SYMLINKAT IORING_OP_LINKAT IORING_OP_MSG_RING IORING_OP_FSETXATTR IORING_OP_SETXATTR IORING_OP_FGETXATTR IORING_OP_GETXATTR IORING_OP_SOCKET IORING_OP_URING_CMD IORING_OP_SEND_ZC IORING_OP_SENDMSG_ZC IORING_OP_READ_MULTISHOT IORING_OP_WAITID IORING_OP_FUTEX_WAIT IORING_OP_FUTEX_WAKE IORING_OP_FUTEX_WAITV IORING_OP_FIXED_FD_INSTALL IORING_OP_FTRUNCATE IORING_OP_BIND IORING_OP_LISTEN IORING_OP_RECV_ZC // Zero-copy receive IORING_OP_EPOLL_WAIT // Epoll wait IORING_OP_READV_FIXED // Vectored read with fixed buffers IORING_OP_WRITEV_FIXED // Vectored write with fixed buffers IORING_OP_PIPE // Create pipe IORING_OP_NOP128 // 128-byte NOP opcode IORING_OP_URING_CMD128 // 128-byte uring command opcode )
IORING_OP_* values encode io_uring operation types in SQEs and SQEContext.
const ( IORING_TIMEOUT_ABS = 1 << iota IORING_TIMEOUT_UPDATE IORING_TIMEOUT_BOOTTIME IORING_TIMEOUT_REALTIME IORING_LINK_TIMEOUT_UPDATE IORING_TIMEOUT_ETIME_SUCCESS IORING_TIMEOUT_MULTISHOT IORING_TIMEOUT_CLOCK_MASK = IORING_TIMEOUT_BOOTTIME | IORING_TIMEOUT_REALTIME IORING_TIMEOUT_UPDATE_MASK = IORING_TIMEOUT_UPDATE | IORING_LINK_TIMEOUT_UPDATE )
Timeout operation flags.
const ( IORING_ACCEPT_MULTISHOT = 1 << 0 // Multi-shot accept: one SQE, multiple completions IORING_ACCEPT_DONTWAIT = 1 << 1 // Non-blocking accept IORING_ACCEPT_POLL_FIRST = 1 << 2 // Poll for connection before accepting )
Accept operation flags.
const ( IORING_RECVSEND_POLL_FIRST = 1 << iota // Poll before send/recv IORING_RECV_MULTISHOT // Multi-shot receive IORING_RECVSEND_FIXED_BUF // Use registered buffer IORING_SEND_ZC_REPORT_USAGE // Report zero-copy usage IORING_RECVSEND_BUNDLE // Bundle mode IORING_SEND_VECTORIZED // Vectorized send )
Send/receive operation flags.
const ( DefaultBufferNumPico = 1 << 15 // 32768 × 32 B = 1 MiB DefaultBufferNumNano = 1 << 14 // 16384 × 128 B = 2 MiB DefaultBufferNumMicro = 1 << 13 // 8192 × 512 B = 4 MiB DefaultBufferNumSmall = 1 << 12 // 4096 × 2 KiB = 8 MiB DefaultBufferNumMedium = 1 << 11 // 2048 × 8 KiB = 16 MiB DefaultBufferNumBig = 1 << 10 // 1024 × 32 KiB = 32 MiB DefaultBufferNumLarge = 1 << 9 // 512 × 128 KiB = 64 MiB DefaultBufferNumGreat = 1 << 8 // 256 × 512 KiB = 128 MiB DefaultBufferNumHuge = 1 << 7 // 128 × 2 MiB = 256 MiB DefaultBufferNumVast = 1 << 6 // 64 × 8 MiB = 512 MiB DefaultBufferNumGiant = 1 << 5 // 32 × 32 MiB = 1 GiB DefaultBufferNumTitan = 1 << 4 // 16 × 128 MiB = 2 GiB )
Default buffer counts per tier. Smaller buffers have more instances to handle high-frequency small I/O. Larger buffers have fewer instances due to memory constraints.
const ( NetworkUnix = sock.NetworkUnix NetworkIPv4 = sock.NetworkIPv4 NetworkIPv6 = sock.NetworkIPv6 )
Network family aliases.
const ( SizeofSockaddrAny = sock.SizeofSockaddrAny SizeofSockaddrInet4 = sock.SizeofSockaddrInet4 SizeofSockaddrInet6 = sock.SizeofSockaddrInet6 SizeofSockaddrUnix = sock.SizeofSockaddrUnix )
Raw socket address size constants.
const ( AF_UNIX = sock.AF_UNIX AF_LOCAL = sock.AF_LOCAL AF_INET = sock.AF_INET AF_INET6 = sock.AF_INET6 SOCK_STREAM = sock.SOCK_STREAM SOCK_DGRAM = sock.SOCK_DGRAM SOCK_RAW = sock.SOCK_RAW SOCK_SEQPACKET = sock.SOCK_SEQPACKET SOCK_NONBLOCK = sock.SOCK_NONBLOCK SOCK_CLOEXEC = sock.SOCK_CLOEXEC IPPROTO_IP = sock.IPPROTO_IP IPPROTO_RAW = sock.IPPROTO_RAW IPPROTO_TCP = sock.IPPROTO_TCP IPPROTO_UDP = sock.IPPROTO_UDP IPPROTO_IPV6 = sock.IPPROTO_IPV6 IPPROTO_SCTP = sock.IPPROTO_SCTP MSG_WAITALL = sock.MSG_WAITALL MSG_ZEROCOPY = sock.MSG_ZEROCOPY SHUT_RD = sock.SHUT_RD SHUT_WR = sock.SHUT_WR SHUT_RDWR = sock.SHUT_RDWR PROT_READ = zcall.PROT_READ PROT_WRITE = zcall.PROT_WRITE MAP_SHARED = zcall.MAP_SHARED MAP_POPULATE = zcall.MAP_POPULATE )
Socket, protocol, message, shutdown, and memory-mapping aliases.
const ( EPOLL_CTL_ADD = 1 EPOLL_CTL_DEL = 2 EPOLL_CTL_MOD = 3 EPOLLIN = 0x1 EPOLLOUT = 0x4 EPOLLET = 0x80000000 )
Epoll constants.
const AT_FDCWD = -100
AT_FDCWD is the special value for current working directory.
const FUTEX_BITSET_MATCH_ANY uint64 = 0xFFFFFFFF
FUTEX_BITSET_MATCH_ANY matches any waker when used as mask in FutexWait.
const (
IORING_CQE_BUFFER_SHIFT = 16
)
const IORING_FILE_INDEX_ALLOC uint32 = 0xFFFFFFFF
IORING_FILE_INDEX_ALLOC is passed as file_index to have io_uring allocate a free direct descriptor slot. The allocated index is returned in cqe->res. Returns -ENFILE if no free slots available.
const IORING_FIXED_FD_NO_CLOEXEC uint32 = 1 << 0
IORING_FIXED_FD_NO_CLOEXEC omits O_CLOEXEC when installing a fixed fd. By default, FixedFdInstall sets O_CLOEXEC on the new regular fd.
const (
IORING_MEM_REGION_REG_WAIT_ARG = 1 // Expose region as registered wait arguments
)
Memory region registration flags.
const (
IORING_MEM_REGION_TYPE_USER = 1 // User-provided memory
)
Memory region types.
const (
IORING_NOTIF_USAGE_ZC_COPIED = 1 << 31 // Data was copied instead of zero-copy
)
Notification CQE usage flags for zero-copy operations.
const IORING_REGISTER_USE_REGISTERED_RING = zcall.IORING_REGISTER_USE_REGISTERED_RING
IORING_REGISTER_USE_REGISTERED_RING is a flag that can be OR'd with register opcodes to use a registered ring fd instead of a regular fd.
const (
IORING_REG_WAIT_TS = 1 << 0 // Timestamp in wait region
)
Registered wait flags.
const (
IORING_RSRC_REGISTER_SPARSE = 1 << 0 // Sparse registration
)
Resource registration flags.
const (
IORING_RW_ATTR_FLAG_PI = 1 << 0 // PI (Protection Information) attribute
)
RW attribute flags for sqe->attr_type_mask.
const (
IORING_ZCRX_AREA_DMABUF = 1 // Use DMA buffer
)
ZCRX area registration flags.
const (
IO_URING_OP_SUPPORTED = 1 << 0
)
const IPPROTO_UDPLITE = sock.IPPROTO_UDPLITE
IPPROTO_UDPLITE is UDP-Lite protocol number.
const O_LARGEFILE = 0x8000
O_LARGEFILE flag for openat.
const SizeofOpenHow = 24
SizeofOpenHow is the size of OpenHow structure.
const (
ZCRX_REG_IMPORT = 1 // Import mode
)
ZCRX registration flags.
Variables ¶
var ( ErrInvalidParam = iofd.ErrInvalidParam ErrInterrupted = iofd.ErrInterrupted ErrNoMemory = iofd.ErrNoMemory ErrPermission = iofd.ErrPermission )
Common errors reused from iofd for semantic consistency across the ecosystem.
var ( // ErrInProgress indicates the operation is in progress. ErrInProgress = errors.New("uring: operation in progress") // ErrFaultParams indicates a fault in parameters (bad address). ErrFaultParams = errors.New("uring: fault in parameters") // ErrProcessFileLimit indicates the process file descriptor limit was reached. ErrProcessFileLimit = errors.New("uring: process file descriptor limit") // ErrSystemFileLimit indicates the system file descriptor limit was reached. ErrSystemFileLimit = errors.New("uring: system file descriptor limit") // ErrNoDevice indicates no such device. ErrNoDevice = errors.New("uring: no such device") // ErrNotSupported indicates the operation is not supported. ErrNotSupported = errors.New("uring: operation not supported") // ErrBusy indicates the resource is busy. ErrBusy = errors.New("uring: resource busy") // ErrClosed indicates the ring has already been stopped. ErrClosed = errors.New("uring: ring closed") // ErrCQOverflow indicates the CQ overflow condition was observed while the CQ appeared empty. ErrCQOverflow = errors.New("uring: completion queue overflow") // ErrExists indicates the resource already exists. ErrExists = errors.New("uring: already exists") // ErrNameTooLong indicates a pathname exceeds the kernel limit. ErrNameTooLong = errors.New("uring: name too long") // ErrNotFound indicates the resource was not found. ErrNotFound = errors.New("uring: not found") // ErrCanceled indicates the operation was canceled. ErrCanceled = errors.New("uring: operation canceled") // ErrTimedOut indicates the operation timed out. ErrTimedOut = errors.New("uring: operation timed out") // ErrConnectionRefused indicates the connection was refused. ErrConnectionRefused = errors.New("uring: connection refused") // ErrConnectionReset indicates the connection was reset. ErrConnectionReset = errors.New("uring: connection reset") // ErrNotConnected indicates the socket is not connected. ErrNotConnected = errors.New("uring: not connected") // ErrAlreadyConnected indicates the socket is already connected. ErrAlreadyConnected = errors.New("uring: already connected") // ErrAddressInUse indicates the address is already in use. ErrAddressInUse = errors.New("uring: address in use") // ErrNetworkUnreachable indicates the network is unreachable. ErrNetworkUnreachable = errors.New("uring: network unreachable") // ErrHostUnreachable indicates the host is unreachable. ErrHostUnreachable = errors.New("uring: host unreachable") // ErrBrokenPipe indicates the pipe is broken (EPIPE). ErrBrokenPipe = errors.New("uring: broken pipe") // ErrNoBufferSpace indicates no buffer space available (ENOBUFS). ErrNoBufferSpace = errors.New("uring: no buffer space available") )
Error definitions for uring operations.
var ErrNotReady = errors.New("uring: listener not ready")
ErrNotReady indicates the listener is not yet ready for accept.
Functions ¶
func AlignedMemBlock ¶
func AlignedMemBlock() []byte
AlignedMemBlock returns a page-aligned memory block.
func CastUserData ¶
CastUserData casts `ExtSQE.UserData` to `*T`. The returned pointer is borrowed from `ext` and is valid only until release. `T` must fit within `ExtSQE.UserData`.
`ExtSQE.UserData` is raw caller-beware storage. Prefer scalar payloads here; if a raw overlay stores Go pointers, interfaces, func values, maps, slices, strings, chans, or structs containing them in these bytes, caller code must keep the live roots outside `UserData`.
func CompletionError ¶
CompletionError decodes a CQE result into the package error model. Non-negative results are successful byte counts or operation values. Negative results are kernel -errno values.
func ContextUserData ¶
ContextUserData extracts a typed value from context. Returns the zero value of T if not found.
func ContextWithUserData ¶
ContextWithUserData returns a new context with the typed value stored.
func PrepareListenerBind ¶
PrepareListenerBind fills ext's SQE for IORING_OP_BIND using the sockaddr stored from PrepareListenerSocket. fd is the socket from SOCKET completion.
func PrepareListenerListen ¶
PrepareListenerListen fills ext's SQE for IORING_OP_LISTEN. fd is the bound socket, backlog from the stored context.
func PrepareListenerSocket ¶
func PrepareListenerSocket(ext *ExtSQE, domain, sockType, proto int, sa Sockaddr, backlog int, handler ListenerHandler) error
PrepareListenerSocket fills ext's SQE for IORING_OP_SOCKET and stores the sockaddr + backlog for subsequent stages. Small sockaddrs stay inline in ext.UserData; oversized ones stay anchored in the pooled sidecar. After calling this, submit with ring.SubmitExtended(PackExtended(ext)).
ext must be a pool-borrowed slot obtained from ContextPools.Extended. Passing a non-pooled ExtSQE is undefined behavior: the sidecar anchors live past the end of a standalone ExtSQE object.
A nil handler is normalized to NoopListenerHandler.
func SetListenerReady ¶
func SetListenerReady(ext *ExtSQE)
SetListenerReady marks the listener context as ready. Call after LISTEN completes successfully.
Types ¶
type AttrPI ¶
type AttrPI struct {
Flags uint16 // PI flags
AppTag uint16 // Application tag
Len uint32 // Length
Addr uint64 // Address
Seed uint64 // Seed value
// contains filtered or unexported fields
}
AttrPI is the PI attribute information for read/write operations. Matches struct io_uring_attr_pi in Linux.
type BufferGroupsConfig ¶
type BufferGroupsConfig struct {
PicoNum int // 32 B buffers
NanoNum int // 128 B buffers
MicroNum int // 512 B buffers
SmallNum int // 2 KiB buffers
MediumNum int // 8 KiB buffers
BigNum int // 32 KiB buffers
LargeNum int // 128 KiB buffers
GreatNum int // 512 KiB buffers
HugeNum int // 2 MiB buffers
VastNum int // 8 MiB buffers
GiantNum int // 32 MiB buffers
TitanNum int // 128 MiB buffers
}
BufferGroupsConfig configures buffer counts for each tier.
Each field specifies the number of buffers to allocate for that tier. A zero count disables the tier (no memory allocated).
Memory usage calculation:
Total = Sum(TierSize × TierCount × Scale)
Example with the default config (Scale=1):
Pico: 32768 × 32 B = 1 MiB
Nano: 16384 × 128 B = 2 MiB
Micro: 8192 × 512 B = 4 MiB
Small: 4096 × 2 KiB = 8 MiB
Medium: 2048 × 8 KiB = 16 MiB
Big: 1024 × 32 KiB = 32 MiB
Large: 512 × 128 KiB = 64 MiB
Total ≈ 127 MiB per scale
func BufferConfigForBudget ¶
func BufferConfigForBudget(budget int) (BufferGroupsConfig, int)
BufferConfigForBudget returns the BufferGroupsConfig and scale selected for the given memory budget. Use this when you need to inspect or model the largest tier set that fits in the remaining buffer-group memory.
Budget handling matches OptionsForBudget's memory reservation:
- registered buffers use 25% of the budget (minimum 8 MiB)
- ring overhead is reserved from the same budget
- buffer groups use the remaining memory
- if the remaining memory cannot fit the minimal tier set, the returned config is empty and scale is 0
OptionsForBudget does not carry BufferGroupsConfig through Options. It sets Options.MultiSizeBuffer from the default buffer-group shape that New actually allocates, so the scale returned here can differ from OptionsForBudget for budgets where a smaller tier set fits but the default tier set does not.
Example:
cfg, scale := BufferConfigForBudget(256 * MiB) // cfg contains tier configuration, scale is the multiplier
func DefaultBufferGroupsConfig ¶
func DefaultBufferGroupsConfig() BufferGroupsConfig
DefaultBufferGroupsConfig returns the default configuration. It enables the first 7 tiers (Pico through Large), totaling ~127 MiB per scale.
func FullBufferGroupsConfig ¶
func FullBufferGroupsConfig() BufferGroupsConfig
FullBufferGroupsConfig returns configuration with all 12 tiers enabled. It uses ~4 GiB per scale. Use it only on high-memory systems.
func MinimalBufferGroupsConfig ¶
func MinimalBufferGroupsConfig() BufferGroupsConfig
MinimalBufferGroupsConfig returns a reduced configuration. It enables the first 5 tiers (Pico through Medium), totaling ~31 MiB per scale.
type BundleIterator ¶
type BundleIterator struct {
// contains filtered or unexported fields
}
BundleIterator iterates over buffers consumed in a bundle receive operation. Bundle receives allow receiving multiple buffers in a single syscall, with data spanning the logical sequence of buffer IDs starting at the CQE's first ID.
The iterator handles buffer ring wrap-around using the ring mask.
func NewBundleIterator ¶
func NewBundleIterator(cqe CQEView, bufBacking []byte, bufSize int, ringEntries int) (BundleIterator, bool)
NewBundleIterator creates an iterator for the buffers consumed by a bundle CQE.
Parameters:
- cqe: the CQE from a bundle receive operation
- bufBacking: backing memory for the full ring, such as the slice returned by AlignedMem
- bufSize: size of each buffer in the ring
- ringEntries: number of entries in the buffer ring; must be a power of two
bufBacking must remain alive for the iterator's lifetime and must cover at least bufSize*ringEntries bytes.
Returns a zero BundleIterator and false if the CQE indicates no data was received or if the constructor arguments are invalid.
func (BundleIterator) All ¶
func (it BundleIterator) All() iter.Seq[[]byte]
All returns an iterator function for use with Go 1.23+ range-over-func. Each iteration yields one buffer from the bundle.
Usage:
for buf := range iter.All() {
process(buf)
}
func (BundleIterator) AllWithSlotID ¶
func (it BundleIterator) AllWithSlotID() iter.Seq2[uint16, []byte]
AllWithSlotID returns an iterator that yields both buffer data and masked ring slot ID. Useful when you need to track which ring slots were consumed.
Usage:
for id, buf := range iter.AllWithSlotID() {
fmt.Printf("Slot ID %d: %d bytes\n", id, len(buf))
}
func (BundleIterator) Buffer ¶
func (it BundleIterator) Buffer(index int) []byte
Buffer returns the buffer at the given index without advancing the iterator. Index must be in range [0, Count()). The last buffer may be partial.
func (BundleIterator) Collect ¶
func (it BundleIterator) Collect() [][]byte
Collect returns all buffers as a slice. This allocates a new slice; for zero-allocation iteration, use All().
func (BundleIterator) CopyTo ¶
func (it BundleIterator) CopyTo(dst []byte) int
CopyTo copies all bundle data to the destination slice. Returns the number of bytes copied.
func (BundleIterator) Count ¶
func (it BundleIterator) Count() int
Count returns the number of buffers consumed in this bundle.
func (BundleIterator) Recycle ¶
func (it BundleIterator) Recycle(ur *Uring)
Recycle returns all consumed buffers to the buffer ring via provide and commits them with advance. This MUST be called after the bundle data has been fully processed to prevent buffer ring entry leaks.
Recycle is single-threaded: do not call it concurrently with another Recycle on the same Uring, or with any other path that can race with buffer ring provide/advance.
The group info (gidOffset, group) is captured at construction time.
func (BundleIterator) SlotID ¶
func (it BundleIterator) SlotID(index int) uint16
SlotID returns the masked ring slot ID at the given index in the bundle. Handles ring wrap-around automatically. Index must be in range [0, Count()).
func (BundleIterator) TotalBytes ¶
func (it BundleIterator) TotalBytes() int
TotalBytes returns the total bytes received in this bundle.
type CQEView ¶
type CQEView struct {
Res int32 // Completion result (directly accessible)
Flags uint32 // CQE flags (directly accessible)
// contains filtered or unexported fields
}
CQEView provides a view into a completion queue entry. It exposes kernel completion facts directly and lets caller-side runtime code decide how to route or interpret them. When available, it also exposes the submission context that produced those facts. A copied CQEView is a completion observation, not durable route state. If caller code stores it beyond the current dispatch turn, caller code must keep its own route state.
Property Patterns ¶
| FullSQE() | Extended() | Mode | Available Data | |-----------|------------|----------|-----------------------------------------------| | false | false | Direct | Op, SQE flags, BufGroup, FD, Res, CQE flags | | true | false | Indirect | + full ioUringSqe copy | | true | true | Extended | + borrowed `ExtSQE` escape hatch |
Usage ¶
n, err := ring.Wait(cqes)
for i := range n {
cqe := cqes[i]
// Observe the kernel facts first.
if err := cqe.Err(); err != nil {
return fmt.Errorf("completion failed: op=%d fd=%d: %w", cqe.Op(), cqe.FD(), err)
}
fmt.Printf("completed op=%d on fd=%d with res=%d\n", cqe.Op(), cqe.FD(), cqe.Res)
if cqe.HasMore() {
// Caller-side runtime code decides whether to keep routing this live stream.
}
if cqe.FullSQE() {
// Indirect and Extended modes also expose the submitted SQE.
fmt.Printf("submitted opcode=%d\n", cqe.SQE().Opcode())
}
}
func (*CQEView) BufGroup ¶
BufGroup returns the observed submission buffer group index. It is non-zero only when buffer selection was part of the submission.
func (*CQEView) BufID ¶
BufID returns the buffer ID from CQE flags. Only valid when IORING_CQE_F_BUFFER flag is set.
func (*CQEView) BundleBuffers ¶
BundleBuffers returns the logical range of buffer IDs consumed. The returned startID is the first buffer ID; count is the number of buffers. The range [startID, startID+count) is logical and may wrap around the ring. Callers must apply (id & ringMask) to obtain physical buffer IDs, or use BundleIterator which handles wrap-around automatically.
func (*CQEView) BundleCount ¶
BundleCount returns the number of buffers consumed in a bundle operation. For receive bundles, this is derived from the result (bytes received) divided by the buffer size. For accurate count, use with known buffer sizes.
func (*CQEView) BundleStartID ¶
BundleStartID returns the starting buffer ID for a bundle operation. For bundle receives, buffers are consumed contiguously from this ID. Only valid when IORING_CQE_F_BUFFER flag is set.
func (*CQEView) Context ¶
func (c *CQEView) Context() SQEContext
Context returns the underlying SQEContext. Use this for advanced mode-specific inspection beyond the CQEView helpers.
func (*CQEView) ExtSQE ¶
ExtSQE returns the borrowed ExtSQE backing Extended mode contexts. Caller should check Extended() first.
func (*CQEView) Extended ¶
Extended reports whether extended user data is available. Returns true only for Extended mode.
func (*CQEView) FD ¶
FD returns the file descriptor associated with the operation. Always available.
func (*CQEView) FullSQE ¶
FullSQE reports whether full SQE information is available. Returns true for Indirect and Extended modes.
func (*CQEView) HasBufferMore ¶
HasBufferMore reports whether the buffer was partially consumed (incremental mode). When set, the same buffer ID remains valid for additional data.
func (*CQEView) IsNotification ¶
IsNotification reports whether this is a zero-copy notification CQE. Zero-copy sends generate two CQEs: one for completion, one for notification when the buffer can be reused.
func (*CQEView) Op ¶
Op returns the IORING_OP_* opcode. Always available (extracted from Direct mode context or from SQE in other modes).
func (*CQEView) SQE ¶
SQE returns a view of the submitted SQE when the context retains one. Caller should check FullSQE() first; Direct mode returns an invalid view because it keeps only compact completion-context facts.
func (*CQEView) SocketNonEmpty ¶
SocketNonEmpty reports whether the socket has more data available. This is set when a short read/recv occurred but more data remains.
type CloneBuffers ¶
type CloneBuffers struct {
SrcFD uint32 // Source ring file descriptor
Flags uint32 // IORING_REGISTER_SRC_* flags
SrcOff uint32 // Source buffer offset
DstOff uint32 // Destination buffer offset
Nr uint32 // Number of buffers to clone
// contains filtered or unexported fields
}
CloneBuffers describes a buffer clone operation. Matches struct io_uring_clone_buffers in Linux.
type ContextPools ¶
type ContextPools struct {
// contains filtered or unexported fields
}
ContextPools holds pooled IndirectSQE and ExtSQE contexts. IndirectSQE slots use explicit aligned backing; extended slots pair each ExtSQE with adjacent GC-visible sidecar anchors.
func NewContextPools ¶
func NewContextPools(capacity int) *ContextPools
NewContextPools creates pooled IndirectSQE and ExtSQE contexts with the given per-pool capacity. New pools are ready for immediate use.
func (*ContextPools) Capacity ¶
func (p *ContextPools) Capacity() int
Capacity returns the per-pool slot count.
func (*ContextPools) Extended ¶
func (p *ContextPools) Extended() *ExtSQE
Extended borrows an ExtSQE from the pool. Returns nil if exhausted.
func (*ContextPools) ExtendedAvailable ¶
func (p *ContextPools) ExtendedAvailable() int
ExtendedAvailable returns the number of ExtSQE slots available.
func (*ContextPools) Indirect ¶
func (p *ContextPools) Indirect() *IndirectSQE
Indirect borrows an IndirectSQE from the pool. Returns nil if exhausted.
func (*ContextPools) IndirectAvailable ¶
func (p *ContextPools) IndirectAvailable() int
IndirectAvailable returns the number of IndirectSQE slots available.
func (*ContextPools) PutExtended ¶
func (p *ContextPools) PutExtended(ext *ExtSQE)
PutExtended returns an ExtSQE to the pool and clears its sidecar anchors.
func (*ContextPools) PutIndirect ¶
func (p *ContextPools) PutIndirect(indirect *IndirectSQE)
PutIndirect returns an IndirectSQE to the pool.
func (*ContextPools) Reset ¶
func (p *ContextPools) Reset()
Reset scrubs pooled slot state and reinitializes both pool queues, making all slots available again.
type Ctx0 ¶
Ctx0 has 0 refs, 0 vals, and 56 bytes of data.
type Ctx0V1 ¶
Ctx0V1 has 0 refs, 1 val, and 48 bytes of data.
type Ctx0V2 ¶
type Ctx0V2 struct {
Fn Handler // 8 bytes
Val1 int64 // 8 bytes
Val2 int64 // 8 bytes
Data [40]byte // 40 bytes
}
Ctx0V2 has 0 refs, 2 vals, and 40 bytes of data.
type Ctx0V3 ¶
type Ctx0V3 struct {
Fn Handler // 8 bytes
Val1 int64 // 8 bytes
Val2 int64 // 8 bytes
Val3 int64 // 8 bytes
Data [32]byte // 32 bytes
}
Ctx0V3 has 0 refs, 3 vals, and 32 bytes of data.
type Ctx0V4 ¶
type Ctx0V4 struct {
Fn Handler // 8 bytes
Val1 int64 // 8 bytes
Val2 int64 // 8 bytes
Val3 int64 // 8 bytes
Val4 int64 // 8 bytes
Data [24]byte // 24 bytes
}
Ctx0V4 has 0 refs, 4 vals, and 24 bytes of data.
type Ctx0V5 ¶
type Ctx0V5 struct {
Fn Handler // 8 bytes
Val1 int64 // 8 bytes
Val2 int64 // 8 bytes
Val3 int64 // 8 bytes
Val4 int64 // 8 bytes
Val5 int64 // 8 bytes
Data [16]byte // 16 bytes
}
Ctx0V5 has 0 refs, 5 vals, and 16 bytes of data.
type Ctx0V6 ¶
type Ctx0V6 struct {
Fn Handler // 8 bytes
Val1 int64 // 8 bytes
Val2 int64 // 8 bytes
Val3 int64 // 8 bytes
Val4 int64 // 8 bytes
Val5 int64 // 8 bytes
Val6 int64 // 8 bytes
Data [8]byte // 8 bytes
}
Ctx0V6 has 0 refs, 6 vals, and 8 bytes of data.
type Ctx0V7 ¶
type Ctx0V7 struct {
Fn Handler // 8 bytes
Val1 int64 // 8 bytes
Val2 int64 // 8 bytes
Val3 int64 // 8 bytes
Val4 int64 // 8 bytes
Val5 int64 // 8 bytes
Val6 int64 // 8 bytes
Val7 int64 // 8 bytes
}
Ctx0V7 has 0 refs, 7 vals, and 0 bytes of data.
type Ctx1V1 ¶
type Ctx1V1[T1 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Val1 int64 // 8 bytes Data [40]byte // 40 bytes }
Ctx1V1 has 1 ref, 1 val, 40 bytes data.
type Ctx1V2 ¶
type Ctx1V2[T1 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Val1 int64 // 8 bytes Val2 int64 // 8 bytes Data [32]byte // 32 bytes }
Ctx1V2 has 1 ref, 2 vals, 32 bytes data.
type Ctx1V3 ¶
type Ctx1V3[T1 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Val1 int64 // 8 bytes Val2 int64 // 8 bytes Val3 int64 // 8 bytes Data [24]byte // 24 bytes }
Ctx1V3 has 1 ref, 3 vals, 24 bytes data.
type Ctx1V4 ¶
type Ctx1V4[T1 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Val1 int64 // 8 bytes Val2 int64 // 8 bytes Val3 int64 // 8 bytes Val4 int64 // 8 bytes Data [16]byte // 16 bytes }
Ctx1V4 has 1 ref, 4 vals, 16 bytes data.
type Ctx1V5 ¶
type Ctx1V5[T1 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Val1 int64 // 8 bytes Val2 int64 // 8 bytes Val3 int64 // 8 bytes Val4 int64 // 8 bytes Val5 int64 // 8 bytes Data [8]byte // 8 bytes }
Ctx1V5 has 1 ref, 5 vals, 8 bytes data.
type Ctx1V6 ¶
type Ctx1V6[T1 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Val1 int64 // 8 bytes Val2 int64 // 8 bytes Val3 int64 // 8 bytes Val4 int64 // 8 bytes Val5 int64 // 8 bytes Val6 int64 // 8 bytes }
Ctx1V6 has 1 ref, 6 vals, 0 bytes data.
type Ctx2 ¶
type Ctx2[T1, T2 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Data [40]byte // 40 bytes }
Ctx2 has 2 refs, 0 vals, 40 bytes data.
type Ctx2V1 ¶
type Ctx2V1[T1, T2 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Val1 int64 // 8 bytes Data [32]byte // 32 bytes }
Ctx2V1 has 2 refs, 1 val, 32 bytes data.
type Ctx2V2 ¶
type Ctx2V2[T1, T2 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Val1 int64 // 8 bytes Val2 int64 // 8 bytes Data [24]byte // 24 bytes }
Ctx2V2 has 2 refs, 2 vals, 24 bytes data.
type Ctx2V3 ¶
type Ctx2V3[T1, T2 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Val1 int64 // 8 bytes Val2 int64 // 8 bytes Val3 int64 // 8 bytes Data [16]byte // 16 bytes }
Ctx2V3 has 2 refs, 3 vals, 16 bytes data.
type Ctx2V4 ¶
type Ctx2V4[T1, T2 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Val1 int64 // 8 bytes Val2 int64 // 8 bytes Val3 int64 // 8 bytes Val4 int64 // 8 bytes Data [8]byte // 8 bytes }
Ctx2V4 has 2 refs, 4 vals, 8 bytes data.
type Ctx2V5 ¶
type Ctx2V5[T1, T2 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Val1 int64 // 8 bytes Val2 int64 // 8 bytes Val3 int64 // 8 bytes Val4 int64 // 8 bytes Val5 int64 // 8 bytes }
Ctx2V5 has 2 refs, 5 vals, 0 bytes data.
type Ctx3 ¶
type Ctx3[T1, T2, T3 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Ref3 *T3 // 8 bytes Data [32]byte // 32 bytes }
Ctx3 has 3 refs, 0 vals, 32 bytes data.
type Ctx3V1 ¶
type Ctx3V1[T1, T2, T3 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Ref3 *T3 // 8 bytes Val1 int64 // 8 bytes Data [24]byte // 24 bytes }
Ctx3V1 has 3 refs, 1 val, 24 bytes data.
type Ctx3V2 ¶
type Ctx3V2[T1, T2, T3 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Ref3 *T3 // 8 bytes Val1 int64 // 8 bytes Val2 int64 // 8 bytes Data [16]byte // 16 bytes }
Ctx3V2 has 3 refs, 2 vals, 16 bytes data.
type Ctx3V3 ¶
type Ctx3V3[T1, T2, T3 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Ref3 *T3 // 8 bytes Val1 int64 // 8 bytes Val2 int64 // 8 bytes Val3 int64 // 8 bytes Data [8]byte // 8 bytes }
Ctx3V3 has 3 refs, 3 vals, 8 bytes data.
type Ctx3V4 ¶
type Ctx3V4[T1, T2, T3 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Ref3 *T3 // 8 bytes Val1 int64 // 8 bytes Val2 int64 // 8 bytes Val3 int64 // 8 bytes Val4 int64 // 8 bytes }
Ctx3V4 has 3 refs, 4 vals, 0 bytes data.
type Ctx4 ¶
type Ctx4[T1, T2, T3, T4 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Ref3 *T3 // 8 bytes Ref4 *T4 // 8 bytes Data [24]byte // 24 bytes }
Ctx4 has 4 refs, 0 vals, 24 bytes data.
type Ctx4V1 ¶
type Ctx4V1[T1, T2, T3, T4 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Ref3 *T3 // 8 bytes Ref4 *T4 // 8 bytes Val1 int64 // 8 bytes Data [16]byte // 16 bytes }
Ctx4V1 has 4 refs, 1 val, 16 bytes data.
type Ctx4V2 ¶
type Ctx4V2[T1, T2, T3, T4 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Ref3 *T3 // 8 bytes Ref4 *T4 // 8 bytes Val1 int64 // 8 bytes Val2 int64 // 8 bytes Data [8]byte // 8 bytes }
Ctx4V2 has 4 refs, 2 vals, 8 bytes data.
type Ctx4V3 ¶
type Ctx4V3[T1, T2, T3, T4 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Ref3 *T3 // 8 bytes Ref4 *T4 // 8 bytes Val1 int64 // 8 bytes Val2 int64 // 8 bytes Val3 int64 // 8 bytes }
Ctx4V3 has 4 refs, 3 vals, 0 bytes data.
type Ctx5 ¶
type Ctx5[T1, T2, T3, T4, T5 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Ref3 *T3 // 8 bytes Ref4 *T4 // 8 bytes Ref5 *T5 // 8 bytes Data [16]byte // 16 bytes }
Ctx5 has 5 refs, 0 vals, 16 bytes data.
type Ctx5V1 ¶
type Ctx5V1[T1, T2, T3, T4, T5 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Ref3 *T3 // 8 bytes Ref4 *T4 // 8 bytes Ref5 *T5 // 8 bytes Val1 int64 // 8 bytes Data [8]byte // 8 bytes }
Ctx5V1 has 5 refs, 1 val, 8 bytes data.
type Ctx5V2 ¶
type Ctx5V2[T1, T2, T3, T4, T5 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Ref3 *T3 // 8 bytes Ref4 *T4 // 8 bytes Ref5 *T5 // 8 bytes Val1 int64 // 8 bytes Val2 int64 // 8 bytes }
Ctx5V2 has 5 refs, 2 vals, 0 bytes data.
type Ctx6 ¶
type Ctx6[T1, T2, T3, T4, T5, T6 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Ref3 *T3 // 8 bytes Ref4 *T4 // 8 bytes Ref5 *T5 // 8 bytes Ref6 *T6 // 8 bytes Data [8]byte // 8 bytes }
Ctx6 has 6 refs, 0 vals, 8 bytes data.
type Ctx6V1 ¶
type Ctx6V1[T1, T2, T3, T4, T5, T6 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Ref3 *T3 // 8 bytes Ref4 *T4 // 8 bytes Ref5 *T5 // 8 bytes Ref6 *T6 // 8 bytes Val1 int64 // 8 bytes }
Ctx6V1 has 6 refs, 1 val, 0 bytes data.
type Ctx7 ¶
type Ctx7[T1, T2, T3, T4, T5, T6, T7 any] struct { Fn Handler // 8 bytes Ref1 *T1 // 8 bytes Ref2 *T2 // 8 bytes Ref3 *T3 // 8 bytes Ref4 *T4 // 8 bytes Ref5 *T5 // 8 bytes Ref6 *T6 // 8 bytes Ref7 *T7 // 8 bytes }
Ctx7 has 7 refs, 0 vals, 0 bytes data.
type CtxRefs0 ¶
type CtxRefs0 struct {
// contains filtered or unexported fields
}
CtxRefs0 is a view into ExtSQE with 0 refs. Use its methods to select the number of vals (0-7).
func ViewCtx ¶
ViewCtx creates a CtxRefs0 for accessing the UserData with 0 refs. Raw overlay; caller must ensure pointer-free refs or keep roots externally.
Example:
c := uring.ViewCtx(sqe).Vals3() // 0 refs, 3 vals c.Val1 = timestamp c.Val2 = flags c.Val3 = seqNum
type CtxRefs1 ¶
type CtxRefs1[T1 any] struct { // contains filtered or unexported fields }
CtxRefs1 is a view into ExtSQE with 1 ref. Use its methods to select the number of vals (0-6).
func ViewCtx1 ¶
ViewCtx1 creates a CtxRefs1 for accessing the UserData with 1 typed ref. Raw overlay; caller must ensure pointer-free refs or keep roots externally.
Example:
c := uring.ViewCtx1[Connection](sqe).Vals1() // 1 ref, 1 val c.Val1 = time.Now().UnixNano()
type CtxRefs2 ¶
type CtxRefs2[T1, T2 any] struct { // contains filtered or unexported fields }
CtxRefs2 is a view into ExtSQE with 2 refs. Use its methods to select the number of vals (0-5).
func ViewCtx2 ¶
ViewCtx2 creates a CtxRefs2 for accessing the UserData with 2 typed refs. Raw overlay; caller must ensure pointer-free refs or keep roots externally.
Example:
c := uring.ViewCtx2[Connection, Buffer](sqe).Vals2() // 2 refs, 2 vals c.Val1 = offset c.Val2 = length
type CtxRefs3 ¶
type CtxRefs3[T1, T2, T3 any] struct { // contains filtered or unexported fields }
CtxRefs3 is a view into ExtSQE with 3 refs. Use its methods to select the number of vals (0-4).
func ViewCtx3 ¶
ViewCtx3 creates a CtxRefs3 for accessing the UserData with 3 typed refs. Raw overlay; caller must ensure pointer-free refs or keep roots externally.
type CtxRefs4 ¶
type CtxRefs4[T1, T2, T3, T4 any] struct { // contains filtered or unexported fields }
CtxRefs4 is a view into ExtSQE with 4 refs. Use its methods to select the number of vals (0-3).
func ViewCtx4 ¶
ViewCtx4 creates a CtxRefs4 for accessing the UserData with 4 typed refs. Raw overlay; caller must ensure pointer-free refs or keep roots externally.
type CtxRefs5 ¶
type CtxRefs5[T1, T2, T3, T4, T5 any] struct { // contains filtered or unexported fields }
CtxRefs5 is a view into ExtSQE with 5 refs. Use its methods to select the number of vals (0-2).
func ViewCtx5 ¶
ViewCtx5 creates a CtxRefs5 for accessing the UserData with 5 typed refs. Raw overlay; caller must ensure pointer-free refs or keep roots externally.
func (CtxRefs5[T1, T2, T3, T4, T5]) Vals0 ¶
Vals0 returns a Ctx5 pointer (5 refs, 0 vals, 16B data).
type CtxRefs6 ¶
type CtxRefs6[T1, T2, T3, T4, T5, T6 any] struct { // contains filtered or unexported fields }
CtxRefs6 is a view into ExtSQE with 6 refs. Use its methods to select the number of vals (0-1).
func ViewCtx6 ¶
ViewCtx6 creates a CtxRefs6 for accessing the UserData with 6 typed refs. Raw overlay; caller must ensure pointer-free refs or keep roots externally.
type CtxRefs7 ¶
type CtxRefs7[T1, T2, T3, T4, T5, T6, T7 any] struct { // contains filtered or unexported fields }
CtxRefs7 is a view into ExtSQE with 7 refs. The only option is Vals0 (no vals available).
type DirectCQE ¶
type DirectCQE struct {
Res int32 // Completion result (bytes transferred or negative errno)
Flags uint32 // CQE flags (IORING_CQE_F_*)
Op uint8 // IORING_OP_* opcode
SQEFlags uint8 // SQE flags (IOSQE_*)
BufGroup uint16 // Buffer group index
FD iofd.FD
}
DirectCQE is a compact copied CQE for Direct mode operations. It stores the completion result and unpacked context fields without mode checking or pointer indirection.
Use WaitDirect when every submitted operation uses Direct mode (PackDirect). That path skips the generic Wait/CQEView mode dispatch per CQE.
Layout: 16 bytes on supported platforms.
func (*DirectCQE) BufID ¶
BufID returns the buffer ID from CQE flags. Only valid when HasBuffer() returns true.
func (*DirectCQE) IsNotification ¶
IsNotification reports whether this is a zero-copy notification CQE.
type EpollEvent ¶
type EpollEvent struct {
Events uint32
Fd int32
Pad int32
// contains filtered or unexported fields
}
EpollEvent represents an epoll event. Layout matches struct epoll_event in Linux.