chore: add readme link, comment

Signed-off-by: Nugraha <26342994+ii64@users.noreply.github.com>
This commit is contained in:
Nugraha 2022-02-09 20:00:10 +07:00
parent 375c7b76d2
commit b8dab73acf
Signed by untrusted user who does not match committer: Xeffy
GPG key ID: E41C08AD390E7C49
3 changed files with 66 additions and 11 deletions

View file

@ -77,7 +77,7 @@ if err != nil {
## Graph
> Check out test script [here](https://gist.github.com/ii64/3a4e8f5c689bb65b2fb9c5f2b1a5904d)
> Check out test script [here][5]
<table><tr>
<td>SQPOLL</td><td>non-SQPOLL</td>
@ -100,4 +100,5 @@ if err != nil {
[1]: https://img.shields.io/badge/License-MIT-yellow.svg
[2]: https://pkg.go.dev/badge/github.com/ii64/gouring.svg
[3]: assets/sqpoll.svg
[4]: assets/nosqpoll.svg
[4]: assets/nosqpoll.svg
[5]: https://gist.github.com/ii64/3a4e8f5c689bb65b2fb9c5f2b1a5904d

View file

@ -20,6 +20,7 @@ func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int6
//go:linkname munmap syscall.munmap
func munmap(addr uintptr, length uintptr) (err error)
// io uring setup
func setup(r *Ring, entries uint, parmas *IOUringParams) (ringFd int, err error) {
var sq = &r.sq
var cq = &r.cq
@ -114,6 +115,7 @@ func setup(r *Ring, entries uint, parmas *IOUringParams) (ringFd int, err error)
return
}
// io uring unsetup
func unsetup(r *Ring) (err error) {
if r.sqesPtr != 0 {
if err = munmap(r.sqesPtr, uintptr(r.params.SQEntries)); err != nil {
@ -135,6 +137,7 @@ func unsetup(r *Ring) (err error) {
return
}
// io uring register fd
func register(r *Ring, opcode UringRegisterOpcode, arg uintptr, nrArg uint) (ret int, err error) {
if ret, err = io_uring_register(r.fd, opcode, arg, nrArg); err != nil {
err = errors.Wrap(err, "io_uring_register")
@ -143,6 +146,7 @@ func register(r *Ring, opcode UringRegisterOpcode, arg uintptr, nrArg uint) (ret
return
}
// io uirng enter
func enter(r *Ring, toSubmit, minComplete uint, flags UringEnterFlag, sig *Sigset_t) (ret int, err error) {
if ret, err = io_uring_enter(r.fd, toSubmit, minComplete, uint(flags), sig); err != nil {
err = errors.Wrap(err, "io_uring_enter")

View file

@ -17,29 +17,79 @@ var (
//-- SQEntry
type SQEntry struct {
// type of operation for this sqe
Opcode UringOpcode
Flags UringSQEFlag
// IOSQE_ flags
Flags UringSQEFlag
// ioprio for the request
Ioprio uint16
Fd int32
off__addr2 uint64 // union { off, addr2 }
addr__splice_off_in uint64 // union { addr, splice_off_in }
// file descriptor to do IO on
Fd int32
/* union {
off, // offset into file
addr2;
} */
off__addr2 uint64
/* union {
addr, // pointer to buffer or iovecs
splice_off_in
} */
addr__splice_off_in uint64
// buffer size or number iovecs
Len uint32
opcode__flags_events uint32 // union of events and flags for opcode
/* union of events and flags for Opcode
union {
__kernel_rwf_t rw_flags;
__u32 fsync_flags;
__u16 poll_events; // compatibility
__u32 poll32_events; // word-reversed for BE
__u32 sync_range_flags;
__u32 msg_flags;
__u32 timeout_flags;
__u32 accept_flags;
__u32 cancel_flags;
__u32 open_flags;
__u32 statx_flags;
__u32 fadvise_advice;
__u32 splice_flags;
__u32 rename_flags;
__u32 unlink_flags;
__u32 hardlink_flags;
__u32 xattr_flags;
} */
opcode__flags_events uint32
// data to be passed back at completion time
UserData uint64
buf__index_group uint16 // union {buf_index, buf_group}
/* pack this to avoid bogus arm OABI complaints
union {
// index into fixed buffers, if used
__u16 buf_index;
// for grouped buffer selection
__u16 buf_group;
} __attribute__((packed)); */
buf__index_group uint16
// personality to use, if used
Personality uint16
splice_fd_in__file_index int32 // union { __s32 splice_fd_in, __u32 file_index }
/* -
union {
__s32 splice_fd_in;
__u32 file_index;
} */
splice_fd_in__file_index int32
addr3 uint64
pad2 [1]uint64
pad2 [1]uint64
}
func (sqe *SQEntry) Offset() *uint64 {