MCPcopy Create free account
hub / github.com/axboe/liburing / test_merge

Function test_merge

test/regbuf-clone.c:531–580  ·  view source on GitHub ↗

* Register sparse buffer table, then try updating that with a few huge * page entries. */

Source from the content-addressed store, hash-verified

529 * page entries.
530 */
531static int test_merge(void)
532{
533 int ret, res = T_EXIT_SKIP;
534 struct iovec vecs[8];
535 struct io_uring ring;
536 __u64 tags[2];
537 void *p1;
538
539 p1 = mmap(NULL, 2*1024*1024, PROT_READ|PROT_WRITE,
540 MAP_PRIVATE|MAP_HUGETLB | MAP_HUGE_2MB | MAP_ANONYMOUS,
541 -1, 0);
542 if (p1 == MAP_FAILED)
543 return T_EXIT_SKIP;
544
545 ret = io_uring_queue_init(1, &ring, 0);
546 if (ret) {
547 fprintf(stderr, "ring_init: %d\n", ret);
548 return T_EXIT_FAIL;
549 }
550
551 memset(vecs, 0, sizeof(vecs));
552
553 ret = io_uring_register_buffers(&ring, vecs, 8);
554 if (ret < 0) {
555 if (ret == -EINVAL)
556 goto skip;
557 fprintf(stderr, "failed to register initial buffers: %d\n", ret);
558 return T_EXIT_FAIL;
559 }
560
561 vecs[0].iov_base = p1;
562 vecs[0].iov_len = 4096;
563 vecs[1].iov_base = p1 + 4096;
564 vecs[1].iov_len = 4096;
565
566 tags[0] = 1;
567 tags[1] = 2;
568 ret = io_uring_register_buffers_update_tag(&ring, 4, vecs, tags, 2);
569 if (ret < 0) {
570 if (ret == -EINVAL)
571 goto skip;
572 fprintf(stderr, "failed to register merge buffers: %d\n", ret);
573 return T_EXIT_FAIL;
574 }
575 res = T_EXIT_PASS;
576skip:
577 munmap(p1, 2*1024*1024);
578 io_uring_queue_exit(&ring);
579 return res;
580}
581
582static int test_same(void)
583{

Callers 1

mainFunction · 0.85

Calls 4

io_uring_queue_initFunction · 0.85
io_uring_queue_exitFunction · 0.85

Tested by

no test coverage detected