Skip to content

Commit

Permalink
test/reg-wait: basic test + probing of kernel regions
Browse files Browse the repository at this point in the history
  • Loading branch information
isilence authored and axboe committed Dec 9, 2024
1 parent 67a8f57 commit 30ce990
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/reg-wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ static const struct io_uring_reg_wait brief_wait = {
.ts.tv_nsec = 1000,
};

static bool has_kernel_regions;

static int test_wait_reg_offset(struct io_uring *ring,
unsigned wait_nr, unsigned long offset)
{
Expand Down Expand Up @@ -380,6 +382,27 @@ static int test_regions(void)
return T_EXIT_FAIL;
}

rd.flags = 0;
rd.user_addr = 0;
ret = test_try_register_region(&mr, true);
if (ret == -EINVAL) {
has_kernel_regions = false;
goto out;
}
if (ret) {
fprintf(stderr, "test_try_register_region() failed kernel alloc %i\n", ret);
return T_EXIT_FAIL;
}

has_kernel_regions = true;
rd.flags = 0;
rd.user_addr = (__u64)(unsigned long)buffer;
ret = test_try_register_region(&mr, true);
if (!ret) {
fprintf(stderr, "test_try_register_region() failed uptr w kernel alloc %i\n", ret);
return T_EXIT_FAIL;
}
out:
munmap(buffer, page_size);
return 0;
}
Expand Down

0 comments on commit 30ce990

Please sign in to comment.