From: Eric Curtin <ericcurtin17@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: "Eric Curtin" <eric.curtin@docker.com>,
"Roger Pau Monné" <roger@xenproject.org>,
"Jens Axboe" <axboe@kernel.dk>,
xen-devel@lists.xenproject.org, linux-block@vger.kernel.org
Subject: [RFC PATCH v2 06/13] xen/blkback: Size indirect_pages for the largest page size
Date: Wed, 2 Dec 2026 03:16:27 +0000 [thread overview]
Message-ID: <20261202031647.1690622-7-ericcurtin17@gmail.com> (raw)
In-Reply-To: <20261202031647.1690622-1-ericcurtin17@gmail.com>
From: Eric Curtin <eric.curtin@docker.com>
With arm64 boot-time page size selection PAGE_SIZE is not a
compile-time constant. MAX_INDIRECT_PAGES depends on the number of
segments that fit in an indirect frame, which depends on the guest page
size, so it cannot size the indirect_pages array in struct pending_req.
Add SEGS_PER_INDIRECT_FRAME_MIN, computed with the largest page size
(the fewest segments per frame), and MAX_INDIRECT_PAGES_MAX derived from
it, and use that for the array. Check the maximum against
BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST in xen_blkif_alloc().
No functional change for compile-time page sizes.
Signed-off-by: Eric Curtin <eric.curtin@docker.com>
---
drivers/block/xen-blkback/common.h | 7 ++++++-
drivers/block/xen-blkback/xenbus.c | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
index f5890b3f1df9..14c244aa8807 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -65,6 +65,11 @@ extern unsigned int xenblk_max_queues;
#define MAX_INDIRECT_PAGES \
((MAX_INDIRECT_SEGMENTS + SEGS_PER_INDIRECT_FRAME - 1)/SEGS_PER_INDIRECT_FRAME)
+#define SEGS_PER_INDIRECT_FRAME_MIN \
+ (XEN_PAGES_PER_INDIRECT_FRAME / XEN_PFN_PER_PAGE_MAX)
+#define MAX_INDIRECT_PAGES_MAX \
+ ((MAX_INDIRECT_SEGMENTS + SEGS_PER_INDIRECT_FRAME_MIN - 1) / \
+ SEGS_PER_INDIRECT_FRAME_MIN)
#define INDIRECT_PAGES(_segs) DIV_ROUND_UP(_segs, XEN_PAGES_PER_INDIRECT_FRAME)
/* Not a real protocol. Used to generate ring structs which contain
@@ -353,7 +358,7 @@ struct pending_req {
struct list_head free_list;
struct grant_page *segments[MAX_INDIRECT_SEGMENTS];
/* Indirect descriptors */
- struct grant_page *indirect_pages[MAX_INDIRECT_PAGES];
+ struct grant_page *indirect_pages[MAX_INDIRECT_PAGES_MAX];
struct seg_buf seg[MAX_INDIRECT_SEGMENTS];
struct bio *biolist[MAX_INDIRECT_SEGMENTS];
struct gnttab_unmap_grant_ref unmap[MAX_INDIRECT_SEGMENTS];
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 8d0ff8fcac22..d2d51fe6081d 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -174,7 +174,7 @@ static struct xen_blkif *xen_blkif_alloc(domid_t domid)
{
struct xen_blkif *blkif;
- BUILD_BUG_ON(MAX_INDIRECT_PAGES > BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST);
+ BUILD_BUG_ON(MAX_INDIRECT_PAGES_MAX > BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST);
blkif = kmem_cache_zalloc(xen_blkif_cachep, GFP_KERNEL);
if (!blkif)
next prev parent reply other threads:[~2026-12-02 3:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 3:16 [RFC PATCH v2 00/13] block/storage: Prepare for boot-time page size selection on arm64 Eric Curtin
2026-12-02 3:16 ` [RFC PATCH v2 01/13] scsi: core: Add dma_boundary_page for page-size DMA boundaries Eric Curtin
2026-12-02 3:16 ` [RFC PATCH v2 02/13] mtd: mtdswap: Initialise mtdswap_ops with a page size variable Eric Curtin
2026-12-02 3:16 ` [RFC PATCH v2 03/13] mmc: mmc_test: Allocate the scratch buffer with the test buffer Eric Curtin
2026-12-02 3:16 ` [RFC PATCH v2 04/13] md: Remove compile-time PAGE_SIZE use in md, dm and bcache Eric Curtin
2026-12-02 3:16 ` [RFC PATCH v2 05/13] zram: Remove PAGE_SIZE use in preprocessor conditionals Eric Curtin
2026-12-02 3:16 ` Eric Curtin [this message]
2026-12-02 3:16 ` [RFC PATCH v2 07/13] null_blk: Size the nullb_page bitmap for PAGE_SIZE_MAX Eric Curtin
2026-12-02 3:16 ` [RFC PATCH v2 08/13] drbd: Use PAGE_SHIFT_MIN in preprocessor checks Eric Curtin
2026-12-02 3:16 ` [RFC PATCH v2 09/13] nvme: Check the DSM range buffer against PAGE_SIZE_MIN Eric Curtin
2026-12-02 3:16 ` [RFC PATCH v2 10/13] dm: Initialise swap_bios from the runtime PAGE_SIZE Eric Curtin
2026-12-02 3:16 ` [RFC PATCH v2 11/13] virtio: Handle boot-time PAGE_SIZE in balloon, blk and 9p transport Eric Curtin
2026-12-02 3:16 ` [RFC PATCH v2 12/13] ata: sata_sil24: Use flexible arrays for the command block SGEs Eric Curtin
2026-12-02 3:16 ` [RFC PATCH v2 13/13] mm: Use PAGE_SIZE_MIN/MAX where a compile-time constant is required Eric Curtin
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 \
--in-reply-to=20261202031647.1690622-7-ericcurtin17@gmail.com \
--to=ericcurtin17@gmail.com \
--cc=axboe@kernel.dk \
--cc=eric.curtin@docker.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=roger@xenproject.org \
--cc=xen-devel@lists.xenproject.org \
/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
all inboxes | Powered by JetHome®