examples/zcrx: Use PAGE_SIZE for ring refill alignment
PATCH 1/2 examples/zcrx: Use PAGE_SIZE for ring refill alignment
According to the 'Create refill ring' section in [1], use the macro PAGE_SIZE instead of 4096 hard code number.
[1]: https://www.kernel.org/doc/html/latest/networking/iou-zcrx.html
--- examples/zcrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
examples/zcrx.c +1 -1
@@ -66,7 +66,7 @@ static inline size_t get_refill_ring_size(unsigned int rq_entries) ring_size = rq_entries *sizeof (struct io_uring_zcrx_rqe );/* add space for the header (head/tail/etc.) */ ring_size +=PAGE_SIZE ; -return T_ALIGN_UP (ring_size,4096 ); +return T_ALIGN_UP (ring_size,PAGE_SIZE ); }static void setup_zcrx (struct io_uring *ring)
Signature · 1 line
2.49.0
PATCH 2/2 .gitignore: Add `examples/zcrx`
Add the built binary 'zcrx' for clean git track.
--- .gitignore | 1 + 1 file changed, 1 insertion(+)
.gitignore +1 -0
@@ -28,6 +28,7 @@ /examples/rsrc-update-bench /examples/kdigest /examples/reg-wait +/examples/zcrx /test/*.t /test/*.dmesg
Signature · 1 line
2.49.0
Jens Axboe
maintainerQuoted 15 lines · Haiyue Wang
According to the 'Create refill ring' section in [1], use the macro
PAGE_SIZEinstead of 4096 hard code number.[1]: https://www.kernel.org/doc/html/latest/networking/iou-zcrx.html
Signed-off-by Haiyue Wang <[email protected]>--- examples/zcrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)examples/zcrx.c +0
-0
examples/zcrx.c static inline size_t get_refill_ring_size(unsigned int rq_entries) · line 72
Quoted 8 lines
examples/zcrx.c +1
-1@@ -66,7 +66,7 @@ static inline size_t get_refill_ring_size(unsigned int rq_entries) ring_size = rq_entries *sizeof (struct io_uring_zcrx_rqe );/* add space for the header (head/tail/etc.) */ ring_size +=PAGE_SIZE ; -return T_ALIGN_UP (ring_size,4096 ); +return T_ALIGN_UP (ring_size,PAGE_SIZE ); }static void setup_zcrx (struct io_uring *ring)
Well, in that same file:
#define PAGE_SIZE (4096)
so this won't really fix anything. Examples or test code should use:
sysconf(_SC_PAGESIZE)
to get the page size at runtime.
Signature · 1 line
Jens Axboe
Quoted 23 lines · Jens Axboe
Quoted 22 lines · Haiyue Wang
According to the 'Create refill ring' section in [1], use the macro
PAGE_SIZEinstead of 4096 hard code number.[1]: https://www.kernel.org/doc/html/latest/networking/iou-zcrx.html
Signed-off-by Haiyue Wang <[email protected]>--- examples/zcrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)examples/zcrx.c +1
-1@@ -66,7 +66,7 @@ static inline size_t get_refill_ring_size(unsigned int rq_entries) ring_size = rq_entries *sizeof (struct io_uring_zcrx_rqe );/* add space for the header (head/tail/etc.) */ ring_size +=PAGE_SIZE ; -return T_ALIGN_UP (ring_size,4096 ); +return T_ALIGN_UP (ring_size,PAGE_SIZE ); }
Quoted 8 lines
examples/zcrx.c static inline size_t get_refill_ring_size(unsigned int rq_entries) · line 72
Quoted 1 line
examples/zcrx.c +0
-0static void setup_zcrx (struct io_uring *ring)Well, in that same file:
#define
PAGE_SIZE(4096)so this won't really fix anything. Examples or test code should use:
The original plan is to make the code consistent for page size as:
ring_size += PAGE_SIZE
Quoted 3 lines
sysconf(_SC_PAGESIZE)
So fix it as 'examples/proxy'?
static long page_size;
page_size = sysconf(_SC_PAGESIZE);
if (page_size < 0) {
perror("sysconf(_SC_PAGESIZE)");
return 1;
}Quoted 2 lines
to get the page size at runtime.
Re: (subset) [PATCH liburing v1 1/2] examples/zcrx: Use PAGE_SIZE for ring refill alignment
In reply to Haiyue WangQuoted 6 lines · Haiyue Wang
According to the 'Create refill ring' section in [1], use the macro
PAGE_SIZEinstead of 4096 hard code number.[1]: https://www.kernel.org/doc/html/latest/networking/iou-zcrx.html
Applied, thanks!
[2/2] .gitignore: Add examples/zcrx
commit: 7245359287ef984056d2ed1a62b110196492b93e
Best regards,
Signature · 1 line
Jens Axboe