From: Chenliang Li <[email protected]>
To: [email protected], [email protected]
Cc: [email protected], [email protected],
Chenliang Li <[email protected]>
Subject: [PATCH liburing] test/fixed-hugepage: Add small-huge page mixture testcase
Date: Mon, 5 Aug 2024 16:44:42 +0800 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: CGME20240805084453epcas5p363b93b10eaf53df5725417d3d7fbcca0@epcas5p3.samsung.com
Add a test case where a fixed buffer is composed of a small page and
a huge page, and begins with the small page. Originally we have huge-small
test case where the buffer begins with the huge page, add this one to
cover more should-not-coalesce scenarios.
Suggested-by: Pavel Begunkov <[email protected]>
Signed-off-by: Chenliang Li <[email protected]>
---
test/fixed-hugepage.c | 42 ++++++++++++++++++++++++++++++++----------
1 file changed, 32 insertions(+), 10 deletions(-)
diff --git a/test/fixed-hugepage.c b/test/fixed-hugepage.c
index 67a3fa0..b455d9f 100644
--- a/test/fixed-hugepage.c
+++ b/test/fixed-hugepage.c
@@ -76,10 +76,11 @@ static int mmap_hugebufs(struct iovec *iov, int nr_bufs, size_t buf_size, size_t
}
/* map a hugepage and smaller page to a contiguous memory */
-static int mmap_mixture(struct iovec *iov, int nr_bufs, size_t buf_size)
+static int mmap_mixture(struct iovec *iov, int nr_bufs, size_t buf_size, bool huge_on_left)
{
int i;
- void *small_base = NULL, *huge_base = NULL, *start = NULL;
+ void *small_base = NULL, *huge_base = NULL, *start = NULL,
+ *huge_start = NULL, *small_start = NULL;
size_t small_size = buf_size - HUGEPAGE_SIZE;
size_t seg_size = ((buf_size / HUGEPAGE_SIZE) + 1) * HUGEPAGE_SIZE;
@@ -92,7 +93,15 @@ static int mmap_mixture(struct iovec *iov, int nr_bufs, size_t buf_size)
}
for (i = 0; i < nr_bufs; i++) {
- huge_base = mmap(start, HUGEPAGE_SIZE, PROT_READ | PROT_WRITE,
+ if (huge_on_left) {
+ huge_start = start;
+ small_start = start + HUGEPAGE_SIZE;
+ } else {
+ huge_start = start + HUGEPAGE_SIZE;
+ small_start = start + HUGEPAGE_SIZE - small_size;
+ }
+
+ huge_base = mmap(huge_start, HUGEPAGE_SIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_FIXED, -1, 0);
if (huge_base == MAP_FAILED) {
printf("Unable to map hugetlb page in the page mixture. "
@@ -101,7 +110,7 @@ static int mmap_mixture(struct iovec *iov, int nr_bufs, size_t buf_size)
return -1;
}
- small_base = mmap(start + HUGEPAGE_SIZE, small_size, PROT_READ | PROT_WRITE,
+ small_base = mmap(small_start, small_size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
if (small_base == MAP_FAILED) {
printf("Unable to map small page in the page mixture. "
@@ -110,8 +119,14 @@ static int mmap_mixture(struct iovec *iov, int nr_bufs, size_t buf_size)
return -1;
}
- memset(huge_base, 0, buf_size);
- iov[i].iov_base = huge_base;
+ if (huge_on_left) {
+ iov[i].iov_base = huge_base;
+ memset(huge_base, 0, buf_size);
+ }
+ else {
+ iov[i].iov_base = small_base;
+ memset(small_base, 0, buf_size);
+ }
iov[i].iov_len = buf_size;
start += seg_size;
}
@@ -315,13 +330,13 @@ static int test_multi_unaligned_mthps(struct io_uring *ring, int fd_in, int fd_o
}
/* Should not coalesce */
-static int test_page_mixture(struct io_uring *ring, int fd_in, int fd_out)
+static int test_page_mixture(struct io_uring *ring, int fd_in, int fd_out, int huge_on_left)
{
struct iovec iov[NR_BUFS];
size_t buf_size = HUGEPAGE_SIZE + MTHP_16KB;
int ret;
- if (mmap_mixture(iov, NR_BUFS, buf_size))
+ if (mmap_mixture(iov, NR_BUFS, buf_size, huge_on_left))
return T_EXIT_SKIP;
ret = register_submit(ring, iov, NR_BUFS, fd_in, fd_out);
@@ -377,10 +392,17 @@ int main(int argc, char *argv[])
return ret;
}
- ret = test_page_mixture(&ring, fd_in, fd_out);
+ ret = test_page_mixture(&ring, fd_in, fd_out, true);
+ if (ret != T_EXIT_PASS) {
+ if (ret != T_EXIT_SKIP)
+ fprintf(stderr, "Test huge small page mixture (start with huge) failed.\n");
+ return ret;
+ }
+
+ ret = test_page_mixture(&ring, fd_in, fd_out, false);
if (ret != T_EXIT_PASS) {
if (ret != T_EXIT_SKIP)
- fprintf(stderr, "Test huge small page mixture failed.\n");
+ fprintf(stderr, "Test huge small page mixture (start with small) failed.\n");
return ret;
}
base-commit: 118622a3188e637d66ddec386b22e86fa8c01700
--
2.34.1
next parent reply other threads:[~2024-08-05 8:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20240805084453epcas5p363b93b10eaf53df5725417d3d7fbcca0@epcas5p3.samsung.com>
2024-08-05 8:44 ` Chenliang Li [this message]
2024-08-08 2:30 ` [PATCH liburing] test/fixed-hugepage: Add small-huge page mixture testcase Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox