From: Eric Curtin <ericcurtin17@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: "Ryan Roberts" <ryan.roberts@arm.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Jason Wang" <jasowangio@gmail.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Jens Axboe" <axboe@kernel.dk>,
"David Hildenbrand" <david@kernel.org>,
"Eric Van Hensbergen" <ericvh@kernel.org>,
"Latchesar Ionkov" <lucho@ionkov.net>,
"Dominique Martinet" <asmadeus@codewreck.org>,
"Christian Schoenebeck" <linux_oss@crudebyte.com>,
virtualization@lists.linux.dev, linux-block@vger.kernel.org,
v9fs@lists.linux.dev
Subject: [RFC PATCH v2 11/13] virtio: Handle boot-time PAGE_SIZE in balloon, blk and 9p transport
Date: Wed, 2 Dec 2026 03:16:32 +0000 [thread overview]
Message-ID: <20261202031647.1690622-12-ericcurtin17@gmail.com> (raw)
In-Reply-To: <20261202031647.1690622-1-ericcurtin17@gmail.com>
From: Ryan Roberts <ryan.roberts@arm.com>
With boot-time page size selection PAGE_SIZE is not a compile-time
constant.
- virtio_blk: check the serial_show() buffer size against PAGE_SIZE_MIN.
- virtio_balloon: check PAGE_SHIFT_MIN in page_to_balloon_pfn(), and
compare the new VIRTIO_BALLOON_PAGES_PER_PAGE_MAX, based on
PAGE_SIZE_MAX, with VIRTIO_BALLOON_ARRAY_PFNS_MAX in set_page_pfns().
Select the free page reporting order of 5 with a run-time
PAGE_SIZE == SZ_64K test on arm64, instead of
CONFIG_ARM64_64K_PAGES.
- 9p: define p9_virtio_trans with DEFINE_GLOBAL_PAGE_SIZE_VAR() so that
it is initialised at boot.
No functional change for compile-time page sizes.
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Eric Curtin <eric.curtin@docker.com>
---
drivers/block/virtio_blk.c | 2 +-
drivers/virtio/virtio_balloon.c | 10 ++++++----
net/9p/trans_virtio.c | 4 ++--
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 2b462005cdb6..c1b26c60ccfb 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -904,7 +904,7 @@ static ssize_t serial_show(struct device *dev,
int err;
/* sysfs gives us a PAGE_SIZE buffer */
- BUILD_BUG_ON(PAGE_SIZE < VIRTIO_BLK_ID_BYTES);
+ BUILD_BUG_ON(PAGE_SIZE_MIN < VIRTIO_BLK_ID_BYTES);
buf[VIRTIO_BLK_ID_BYTES] = '\0';
err = virtblk_get_id(disk, buf);
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 8c1b47ec17a2..a2c9429586fb 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -26,6 +26,7 @@
* page units.
*/
#define VIRTIO_BALLOON_PAGES_PER_PAGE (unsigned int)(PAGE_SIZE >> VIRTIO_BALLOON_PFN_SHIFT)
+#define VIRTIO_BALLOON_PAGES_PER_PAGE_MAX (unsigned int)(PAGE_SIZE_MAX >> VIRTIO_BALLOON_PFN_SHIFT)
#define VIRTIO_BALLOON_ARRAY_PFNS_MAX 256
/* Maximum number of (4k) pages to deflate on OOM notifications. */
#define VIRTIO_BALLOON_OOM_NR_PAGES 256
@@ -139,7 +140,7 @@ static u32 page_to_balloon_pfn(struct page *page)
{
unsigned long pfn = page_to_pfn(page);
- BUILD_BUG_ON(PAGE_SHIFT < VIRTIO_BALLOON_PFN_SHIFT);
+ BUILD_BUG_ON(PAGE_SHIFT_MIN < VIRTIO_BALLOON_PFN_SHIFT);
/* Convert pfn from Linux page size to balloon page size. */
return pfn * VIRTIO_BALLOON_PAGES_PER_PAGE;
}
@@ -231,7 +232,7 @@ static void set_page_pfns(struct virtio_balloon *vb,
{
unsigned int i;
- BUILD_BUG_ON(VIRTIO_BALLOON_PAGES_PER_PAGE > VIRTIO_BALLOON_ARRAY_PFNS_MAX);
+ BUILD_BUG_ON(VIRTIO_BALLOON_PAGES_PER_PAGE_MAX > VIRTIO_BALLOON_ARRAY_PFNS_MAX);
/*
* Set balloon pfns pointing at this page.
@@ -1040,8 +1041,9 @@ static int virtballoon_probe(struct virtio_device *vdev)
* host's base page size. However, it needs more work to report
* that value. The hard-coded order would be fine currently.
*/
-#if defined(CONFIG_ARM64) && defined(CONFIG_ARM64_64K_PAGES)
- vb->pr_dev_info.order = 5;
+#if defined(CONFIG_ARM64)
+ if (PAGE_SIZE == SZ_64K)
+ vb->pr_dev_info.order = 5;
#endif
vb->pr_dev_info.capacity = capacity;
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index 9fa63e3ebf67..181ed87f703f 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -795,7 +795,7 @@ static struct virtio_driver p9_virtio_drv = {
.remove = p9_virtio_remove,
};
-static struct p9_trans_module p9_virtio_trans = {
+static DEFINE_GLOBAL_PAGE_SIZE_VAR(struct p9_trans_module, p9_virtio_trans, {
.name = "virtio",
.create = p9_virtio_create,
.close = p9_virtio_close,
@@ -814,7 +814,7 @@ static struct p9_trans_module p9_virtio_trans = {
.def = true,
.supports_vmalloc = false,
.owner = THIS_MODULE,
-};
+});
/* The standard init function */
static int __init p9_virtio_init(void)
prev parent reply other threads:[~2026-12-02 3:17 UTC|newest]
Thread overview: 6+ 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 05/13] zram: Remove PAGE_SIZE use in preprocessor conditionals Eric Curtin
2026-12-02 3:16 ` [RFC PATCH v2 06/13] xen/blkback: Size indirect_pages for the largest page size Eric Curtin
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 ` Eric Curtin [this message]
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-12-ericcurtin17@gmail.com \
--to=ericcurtin17@gmail.com \
--cc=asmadeus@codewreck.org \
--cc=axboe@kernel.dk \
--cc=david@kernel.org \
--cc=eperezma@redhat.com \
--cc=ericvh@kernel.org \
--cc=jasowangio@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux_oss@crudebyte.com \
--cc=lucho@ionkov.net \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=ryan.roberts@arm.com \
--cc=stefanha@redhat.com \
--cc=v9fs@lists.linux.dev \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
/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