From: Chenliang Li <[email protected]>
To: [email protected], [email protected]
Cc: [email protected], [email protected],
[email protected], [email protected],
[email protected], [email protected],
Chenliang Li <[email protected]>
Subject: [PATCH v5 2/3] io_uring/rsrc: store folio shift and mask into imu
Date: Fri, 28 Jun 2024 16:44:10 +0800 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Store the folio shift and folio mask into imu struct and use it in
iov_iter adjust, as we will have non PAGE_SIZE'd chunks if a
multi-hugepage buffer get coalesced.
Signed-off-by: Chenliang Li <[email protected]>
Reviewed-by: Anuj Gupta <[email protected]>
---
io_uring/rsrc.c | 15 ++++++---------
io_uring/rsrc.h | 2 ++
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index c88ce8c38515..3198cf854db1 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -1002,6 +1002,8 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov,
imu->ubuf = (unsigned long) iov->iov_base;
imu->ubuf_end = imu->ubuf + iov->iov_len;
imu->nr_bvecs = nr_pages;
+ imu->folio_shift = PAGE_SHIFT;
+ imu->folio_mask = PAGE_MASK;
*pimu = imu;
ret = 0;
@@ -1118,23 +1120,18 @@ int io_import_fixed(int ddir, struct iov_iter *iter,
* we know that:
*
* 1) it's a BVEC iter, we set it up
- * 2) all bvecs are PAGE_SIZE in size, except potentially the
+ * 2) all bvecs are the same in size, except potentially the
* first and last bvec
*
* So just find our index, and adjust the iterator afterwards.
* If the offset is within the first bvec (or the whole first
* bvec, just use iov_iter_advance(). This makes it easier
* since we can just skip the first segment, which may not
- * be PAGE_SIZE aligned.
+ * be folio_size aligned.
*/
const struct bio_vec *bvec = imu->bvec;
if (offset < bvec->bv_len) {
- /*
- * Note, huge pages buffers consists of one large
- * bvec entry and should always go this way. The other
- * branch doesn't expect non PAGE_SIZE'd chunks.
- */
iter->bvec = bvec;
iter->nr_segs = bvec->bv_len;
iter->count -= offset;
@@ -1144,12 +1141,12 @@ int io_import_fixed(int ddir, struct iov_iter *iter,
/* skip first vec */
offset -= bvec->bv_len;
- seg_skip = 1 + (offset >> PAGE_SHIFT);
+ seg_skip = 1 + (offset >> imu->folio_shift);
iter->bvec = bvec + seg_skip;
iter->nr_segs -= seg_skip;
iter->count -= bvec->bv_len + offset;
- iter->iov_offset = offset & ~PAGE_MASK;
+ iter->iov_offset = offset & ~imu->folio_mask;
}
}
diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h
index cc66323535f6..b02fc0ef59fe 100644
--- a/io_uring/rsrc.h
+++ b/io_uring/rsrc.h
@@ -46,7 +46,9 @@ struct io_mapped_ubuf {
u64 ubuf;
u64 ubuf_end;
unsigned int nr_bvecs;
+ unsigned int folio_shift;
unsigned long acct_pages;
+ unsigned long folio_mask;
struct bio_vec bvec[] __counted_by(nr_bvecs);
};
--
2.34.1
next prev parent reply other threads:[~2024-06-29 7:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20240628084418epcas5p14c304761ca375a6afba3aa199c27f9e3@epcas5p1.samsung.com>
2024-06-28 8:44 ` [PATCH v5 0/3] io_uring/rsrc: coalescing multi-hugepage registered buffers Chenliang Li
[not found] ` <CGME20240628084420epcas5p32f49e7c977695d20bcef7734eb2e38b4@epcas5p3.samsung.com>
2024-06-28 8:44 ` [PATCH v5 1/3] io_uring/rsrc: add hugepage fixed buffer coalesce helpers Chenliang Li
2024-07-09 13:09 ` Pavel Begunkov
[not found] ` <CGME20240710022336epcas5p2685a44c8e04962830f4e7f8ffee8168f@epcas5p2.samsung.com>
2024-07-10 2:23 ` Chenliang Li
[not found] ` <CGME20240628084422epcas5p3b5d4c93e5fa30069c703bcead1fa0033@epcas5p3.samsung.com>
2024-06-28 8:44 ` Chenliang Li [this message]
[not found] ` <CGME20240628084424epcas5p3c34ec2fb8fb45752ef6a11447812ae0d@epcas5p3.samsung.com>
2024-06-28 8:44 ` [PATCH v5 3/3] io_uring/rsrc: enable multi-hugepage buffer coalescing Chenliang Li
2024-07-09 13:17 ` Pavel Begunkov
[not found] ` <CGME20240710022900epcas5p368c4ebc44f3ace1ca0804116bd913512@epcas5p3.samsung.com>
2024-07-10 2:28 ` Chenliang Li
[not found] ` <CGME20240708021432epcas5p4e7e74d81a42a559f2b059e94e7022740@epcas5p4.samsung.com>
2024-07-08 2:14 ` [PATCH v5 0/3] io_uring/rsrc: coalescing multi-hugepage registered buffers Chenliang Li
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] \
[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