Skip to content

Commit 402dc14

Browse files
committed
add more docs
1 parent 43c653e commit 402dc14

203 files changed

Lines changed: 10147 additions & 283 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

fix.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import re
2+
import sys
3+
from pathlib import Path
4+
5+
def process(text: str) -> str:
6+
# 1. Remove the "# NAME" line entirely
7+
text = re.sub(r'^# NAME\s*\n', '', text, flags=re.MULTILINE)
8+
9+
# 2. Extract the short description line:
10+
# e.g. "io_uring_for_each_cqe - iterate pending completion events"
11+
m = re.search(r'^(.*?)\s*-\s*(.*)$', text, flags=re.MULTILINE)
12+
if m:
13+
short = m.group(2).strip()
14+
# Capitalize first word
15+
short = short[0].upper() + short[1:]
16+
# Ensure trailing period
17+
if not short.endswith('.'):
18+
short += '.'
19+
# Replace the whole line with just the cleaned short description
20+
text = re.sub(r'^.*? - .*$', short, text, flags=re.MULTILINE)
21+
22+
# 3. Remove everything from "# SYNOPSIS" up to "# DESCRIPTION"
23+
text = re.sub(
24+
r'# SYNOPSIS[\s\S]*?# DESCRIPTION',
25+
'# DESCRIPTION',
26+
text,
27+
flags=re.MULTILINE
28+
)
29+
30+
# 4. Transform SEE ALSO entries:
31+
# **symbol**(3) → [symbol]
32+
def fix_see_also(match):
33+
symbol = match.group(1)
34+
return f'[{symbol}]'
35+
36+
text = re.sub(
37+
r'\*\*([A-Za-z0-9_]+)\*\*\(\d+\)',
38+
fix_see_also,
39+
text
40+
)
41+
42+
return text
43+
44+
if __name__ == "__main__":
45+
for path in sys.argv[1:]:
46+
p = Path(path)
47+
original = p.read_text()
48+
cleaned = process(original)
49+
print(cleaned)
50+
p.write_text(cleaned)
51+
print(f"Processed {p}")

liburing-rs/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ use std::{mem::zeroed, ptr, time::Duration};
9393

9494
use liburing_rs::*;
9595

96-
#[test]
9796
pub fn queue_init() {
9897
// Setup the ring.
9998
//
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Functions and macros to check the liburing.
2+
version
3+
4+
# DESCRIPTION
5+
6+
The [io_uring_check_version] function returns *false* if the
7+
liburing library loaded by the dynamic linker is greater-than or
8+
equal-to the *major* and *minor* numbers provided.
9+
10+
The [IO_URING_CHECK_VERSION] macro returns *0* if the liburing
11+
library being compiled against is greater-than or equal-to the *major*
12+
and *minor* numbers provided.
13+
14+
The [io_uring_major_version] function returns the *major* version
15+
number of the liburing library loaded by the dynamic linker.
16+
17+
The [IO_URING_VERSION_MAJOR] macro returns the *major* version
18+
number of the liburing library being compiled against.
19+
20+
The [io_uring_minor_version] function returns the *minor* version
21+
number of the liburing library loaded by the dynamic linker.
22+
23+
The [IO_URING_VERSION_MINOR] macro returns the *minor* version
24+
number of the liburing library being compiled against.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Functions and macros to check the liburing.
2+
version
3+
4+
# DESCRIPTION
5+
6+
The [io_uring_check_version] function returns *false* if the
7+
liburing library loaded by the dynamic linker is greater-than or
8+
equal-to the *major* and *minor* numbers provided.
9+
10+
The [IO_URING_CHECK_VERSION] macro returns *0* if the liburing
11+
library being compiled against is greater-than or equal-to the *major*
12+
and *minor* numbers provided.
13+
14+
The [io_uring_major_version] function returns the *major* version
15+
number of the liburing library loaded by the dynamic linker.
16+
17+
The [IO_URING_VERSION_MAJOR] macro returns the *major* version
18+
number of the liburing library being compiled against.
19+
20+
The [io_uring_minor_version] function returns the *minor* version
21+
number of the liburing library loaded by the dynamic linker.
22+
23+
The [IO_URING_VERSION_MINOR] macro returns the *minor* version
24+
number of the liburing library being compiled against.

liburing-rs/docs/io_uring.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ or posting multiple CQEs for a single SQE for multi shot operations or
107107
requiring an **io_uring_enter**(2) syscall to make the kernel begin
108108
processing newly added SQEs when using submission queue polling.
109109

110-
## Submission queue polling
110+
**Submission**\ queue polling
111111

112112
One of the goals of **io_uring** is to provide a means for efficient
113113
I/O. To this end, **io_uring** supports a polling mode that lets you
@@ -120,7 +120,7 @@ avoid the overhead of system calls. A designated kernel thread dequeues
120120
SQEs off the SQ as you add them and dispatches them for asynchronous
121121
processing.
122122

123-
## Setting up io_uring
123+
**Setting**\ up io_uring
124124

125125
The main steps in setting up **io_uring** consist of mapping in the
126126
shared buffers with **mmap**(2) calls. In the example program included
@@ -130,7 +130,7 @@ the 2 **mmap**(2) calls that set up the shared submission and completion
130130
queues. If your kernel is older than version 5.4, three **mmap(2)**
131131
calls are required.
132132

133-
## Submitting I/O requests
133+
**Submitting**\ I/O requests
134134

135135
The process of submitting a request consists of describing the I/O
136136
operation you need to get done using an **io_uring_sqe** structure
@@ -313,7 +313,7 @@ waiting for a specified count of events to complete. This way, you can
313313
be sure to find completion events in the completion queue without having
314314
to poll it for events later.
315315

316-
## SQE pointer lifetimes & data stability
316+
**SQE**\ pointer lifetimes & data stability
317317

318318
Due to the fixed size of the submission queue entry (SQE) some data you
319319
provide in order to perform a desired operation will be passed in the
@@ -342,7 +342,7 @@ read or written while the operation is inflight. For example, the
342342
pointers to a buffer used as part of a **IORING_OP_WRITE** or
343343
**IORING_OP_READ** operation must remain valid until completion.
344344

345-
## Reading completion events
345+
**Reading**\ completion events
346346

347347
Similar to the submission queue (SQ), the completion queue (CQ) is a
348348
shared buffer between the kernel and user space. Whereas you placed
@@ -458,7 +458,7 @@ the head needs to be updated to reflect the consumption of the CQE.
458458
Attention should be paid to the read and write barriers to ensure
459459
successful read and update of the head.
460460

461-
## io_uring performance
461+
**io_uring**\ performance
462462

463463
Because of the shared ring buffers between kernel and user space,
464464
**io_uring** can be a zero-copy system. Copying buffers to and from

liburing-rs/docs/io_uring_buf_ring_cq_advance.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ call and a **io_uring_cq_advance**(3) into one operation. Since updating
1111
either ring index entails a store memory barrier, doing both at once is
1212
more efficient.
1313

14+
The **\_\_io_uring_buf_ring_cq_advance**(3) function performs the same
15+
operation, except it splits the counts into two separate values. It
16+
advances the CQ ring by *cq_count* entries, and the buffer ring by
17+
*buf_count* entries rather than increment both by the same value.
18+
1419
# RETURN VALUE
1520

1621
None

liburing-rs/docs/io_uring_clone_buffers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ for **\_\_io_uring_clone_buffers**(3) for details.
4545

4646
*flags* may be set to the following value:
4747

48-
## IORING_REGISTER_SRC_REGISTERED
48+
**IORING_REGISTER_SRC_REGISTERED**\
4949

5050
If the source ring is registered AND the calling thread is the one that
5151
originally registered its ring fd, then this flag may be set to lookup
5252
the registered index rather than use the normal file descriptor. If the
5353
normal file descriptor wasn't closed after registering it, there's no
5454
need to set this flag.
5555

56-
## IORING_REGISTER_DST_REPLACE
56+
**IORING_REGISTER_DST_REPLACE**\
5757

5858
If set, cloning may happen for a destination ring that already has a
5959
buffer table assigned. In that case, existing nodes that overlap with
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Get user data for completion event.
2+
3+
# DESCRIPTION
4+
5+
The **io_uring_cqe_get_data**(3) function returns the user_data with the
6+
completion queue entry *cqe* as a data pointer.
7+
8+
The **io_uring_cqe_get_data64**(3) function returns the user_data with
9+
the completion queue entry *cqe* as a 64-bit data value.
10+
11+
After the caller has received a completion queue entry (CQE) with
12+
**io_uring_wait_cqe**(3), the application can call
13+
**io_uring_cqe_get_data**(3) or **io_uring_cqe_get_data64**(3) function
14+
to retrieve the *user_data* value. This requires that *user_data* has
15+
been set earlier with the function **io_uring_sqe_set_data**(3) or
16+
**io_uring_sqe_set_data64**(3).
17+
18+
# RETURN VALUE
19+
20+
If the *user_data* value has been set before submitting the request, it
21+
will be returned. Otherwise, the return value is undefined.
22+
23+
# SEE ALSO
24+
25+
[io_uring_get_sqe], [io_uring_sqe_set_data],
26+
[io_uring_submit]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Return the number of CQ ring slots consumed by a CQE.
2+
3+
# DESCRIPTION
4+
5+
The **io_uring_cqe_nr**(3) function returns the number of CQ ring slots
6+
consumed by *cqe*. For normal 16-byte CQEs, this returns 1. For 32-byte
7+
CQEs (when **IORING_CQE_F_32** is set in the CQE flags), this returns 2.
8+
9+
This function is useful when advancing the CQ ring with
10+
**io_uring_cq_advance**(3) on rings that use **IORING_SETUP_CQE_MIXED**
11+
where both 16-byte and 32-byte CQEs may be present.
12+
13+
# RETURN VALUE
14+
15+
Returns 1 for normal CQEs, or 2 for 32-byte CQEs.
16+
17+
# SEE ALSO
18+
19+
[io_uring_cq_advance], [io_uring_cqe_seen],
20+
[io_uring_setup]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Mark io_uring completion event as consumed.
2+
3+
# DESCRIPTION
4+
5+
The **io_uring_cqe_seen**(3) function marks the IO completion *cqe*
6+
belonging to the *ring* param as consumed.
7+
8+
After the caller has submitted a request with **io_uring_submit**(3),
9+
the application can retrieve the completion with
10+
**io_uring_wait_cqe**(3), **io_uring_peek_cqe**(3), or any of the other
11+
CQE retrieval helpers, and mark it as consumed with
12+
**io_uring_cqe_seen**(3).
13+
14+
Completions must be marked as completed so their slot can get reused.
15+
16+
# RETURN VALUE
17+
18+
None
19+
20+
# SEE ALSO
21+
22+
[io_uring_submit], [io_uring_peek_cqe],
23+
[io_uring_wait_cqe], [io_uring_wait_cqes],
24+
[io_uring_wait_cqe_timeout]

0 commit comments

Comments
 (0)