-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathliburing-comment-for-commit-f8b12e48bffc.patch
133 lines (125 loc) · 3.52 KB
/
liburing-comment-for-commit-f8b12e48bffc.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
From 5019a2a7869f2ddaa7fa5139d0f194ec7c3010ae Mon Sep 17 00:00:00 2001
From: Dongli Zhang <dongli.zhang0129@gmail.com>
Date: Wed, 3 Apr 2019 01:50:33 +0800
Subject: [PATCH 1/1] liburing comment for commit f8b12e48bffc
This is for liburing commit f8b12e48bffc
Signed-off-by: Dongli Zhang <dongli.zhang0129@gmail.com>
---
src/liburing.h | 11 +++++++++++
src/queue.c | 3 +++
src/setup.c | 6 ++++++
test/io_uring-cp.c | 6 ++++++
test/io_uring-test.c | 12 ++++++++++++
5 files changed, 38 insertions(+)
diff --git a/src/liburing.h b/src/liburing.h
index 1cea6a5..2b87992 100644
--- a/src/liburing.h
+++ b/src/liburing.h
@@ -13,6 +13,13 @@ struct io_uring_sq {
unsigned *khead;
unsigned *ktail;
unsigned *kring_mask;
+ /*
+ * used by:
+ * - src/queue.c|93| <<io_uring_submit>> submitted = *sq->kring_entries;
+ * - src/queue.c|160| <<io_uring_get_sqe>> if (next - sq->sqe_head > *sq->kring_entries)
+ * - src/setup.c|27| <<io_uring_mmap>> sq->kring_entries = ptr + p->sq_off.ring_entries;
+ * - src/setup.c|107| <<io_uring_queue_exit>> munmap(sq->sqes, *sq->kring_entries * sizeof(struct io_uring_sqe));
+ */
unsigned *kring_entries;
unsigned *kflags;
unsigned *kdropped;
@@ -29,6 +36,10 @@ struct io_uring_cq {
unsigned *khead;
unsigned *ktail;
unsigned *kring_mask;
+ /*
+ * used by:
+ * - src/setup.c|54| <<io_uring_mmap>> cq->kring_entries = ptr + p->cq_off.ring_entries;
+ */
unsigned *kring_entries;
unsigned *koverflow;
struct io_uring_cqe *cqes;
diff --git a/src/queue.c b/src/queue.c
index 6767790..660aea8 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -148,6 +148,9 @@ submit:
*
* Returns a vacant sqe, or NULL if we're full.
*/
+/*
+ * 获取下一个sqe, sq->sqe_tail会增加1
+ */
struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring)
{
struct io_uring_sq *sq = &ring->sq;
diff --git a/src/setup.c b/src/setup.c
index 9979dd0..2a8d750 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -93,6 +93,12 @@ int io_uring_queue_init(unsigned entries, struct io_uring *ring, unsigned flags)
return io_uring_queue_mmap(fd, &p, ring);
}
+/*
+ * munmap以下3个:
+ * - sq->sqes
+ * - sq->khead
+ * - cq->khead
+ */
void io_uring_queue_exit(struct io_uring *ring)
{
struct io_uring_sq *sq = &ring->sq;
diff --git a/test/io_uring-cp.c b/test/io_uring-cp.c
index 3790736..4b511c2 100644
--- a/test/io_uring-cp.c
+++ b/test/io_uring-cp.c
@@ -241,6 +241,12 @@ int main(int argc, char *argv[])
close(infd);
close(outfd);
+ /*
+ * munmap以下3个:
+ * - sq->sqes
+ * - sq->khead
+ * - cq->khead
+ */
io_uring_queue_exit(&ring);
return ret;
}
diff --git a/test/io_uring-test.c b/test/io_uring-test.c
index caca379..d49da43 100644
--- a/test/io_uring-test.c
+++ b/test/io_uring-test.c
@@ -42,6 +42,7 @@ int main(int argc, char *argv[])
iovecs = calloc(QD, sizeof(struct iovec));
for (i = 0; i < QD; i++) {
+ /* Allocate memory of SIZE bytes with an alignment of ALIGNMENT. */
if (posix_memalign(&buf, 4096, 4096))
return 1;
iovecs[i].iov_base = buf;
@@ -51,6 +52,11 @@ int main(int argc, char *argv[])
offset = 0;
i = 0;
do {
+ /*
+ * sqe类型: struct io_uring_sqe *sqe;
+ *
+ * 获取下一个sqe, sq->sqe_tail会增加1
+ */
sqe = io_uring_get_sqe(&ring);
if (!sqe)
break;
@@ -82,6 +88,12 @@ int main(int argc, char *argv[])
printf("Submitted=%d, completed=%d\n", pending, done);
close(fd);
+ /*
+ * munmap以下3个:
+ * - sq->sqes
+ * - sq->khead
+ * - cq->khead
+ */
io_uring_queue_exit(&ring);
return 0;
}
--
2.7.4