Skip to content

Commit 8b0c602

Browse files
committed
io_uring/rsrc: get rid of io_mapped_ubuf->folio_mask
We don't really need to cache this, let's reclaim 8 bytes from struct io_mapped_ubuf and just calculate it when we need it. The only hot path here is io_import_fixed(). Signed-off-by: Jens Axboe <[email protected]>
1 parent 636119a commit 8b0c602

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

io_uring/rsrc.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -988,13 +988,10 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov,
988988
imu->ubuf_end = imu->ubuf + iov->iov_len;
989989
imu->nr_bvecs = nr_pages;
990990
imu->folio_shift = PAGE_SHIFT;
991-
imu->folio_mask = PAGE_MASK;
992-
if (coalesced) {
991+
if (coalesced)
993992
imu->folio_shift = data.folio_shift;
994-
imu->folio_mask = ~((1UL << data.folio_shift) - 1);
995-
}
996993
refcount_set(&imu->refs, 1);
997-
off = (unsigned long) iov->iov_base & ~imu->folio_mask;
994+
off = (unsigned long) iov->iov_base & ((1UL << imu->folio_shift) - 1);
998995
*pimu = imu;
999996
ret = 0;
1000997

@@ -1132,7 +1129,7 @@ int io_import_fixed(int ddir, struct iov_iter *iter,
11321129
iter->bvec = bvec + seg_skip;
11331130
iter->nr_segs -= seg_skip;
11341131
iter->count -= bvec->bv_len + offset;
1135-
iter->iov_offset = offset & ~imu->folio_mask;
1132+
iter->iov_offset = offset & ((1UL << imu->folio_shift) - 1);
11361133
}
11371134
}
11381135

io_uring/rsrc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ struct io_mapped_ubuf {
4646
unsigned int nr_bvecs;
4747
unsigned int folio_shift;
4848
unsigned long acct_pages;
49-
unsigned long folio_mask;
5049
refcount_t refs;
5150
struct bio_vec bvec[] __counted_by(nr_bvecs);
5251
};

0 commit comments

Comments
 (0)