From: Juergen Gross <jgross@suse.com>
To: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org
Cc: "Juergen Gross" <jgross@suse.com>,
"Roger Pau Monné" <roger@xenproject.org>,
"Jens Axboe" <axboe@kernel.dk>,
xen-devel@lists.xenproject.org
Subject: [PATCH 3/3] xen-blkback: make statistics data persistent across disconnect/connect
Date: Wed, 11 Nov 2026 17:20:58 +0100 [thread overview]
Message-ID: <20261111162058.804033-4-jgross@suse.com> (raw)
In-Reply-To: <20261111162058.804033-1-jgross@suse.com>
Today the statistics data is living in struct xen_blkif_ring only.
This means that a disconnect/connect cycle will reset the data, as the
rings are freed and re-allocated in this case.
Add a struct xen_blkif_stat in struct xen_blkif and sum up the per-ring
data there when freeing the rings, and add those values to the printed
statistics data.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
drivers/block/xen-blkback/common.h | 2 ++
drivers/block/xen-blkback/xenbus.c | 19 ++++++++++++++++---
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
index f8385c4b9d30..c35ec207b31d 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -327,6 +327,8 @@ struct xen_blkif {
unsigned int nr_rings;
unsigned long buffer_squeeze_end;
+
+ struct xen_blkif_stat st;
};
struct seg_buf {
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index b3ef483a92fd..f0d4cec4432a 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -346,6 +346,18 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
*/
write_lock(&blkif->rings_lock);
+ for (r = 0; r < blkif->nr_rings; r++) {
+ struct xen_blkif_ring *ring = &blkif->rings[r];
+
+ blkif->st.rd_req += ring->st.rd_req;
+ blkif->st.wr_req += ring->st.wr_req;
+ blkif->st.oo_req += ring->st.oo_req;
+ blkif->st.f_req += ring->st.f_req;
+ blkif->st.ds_req += ring->st.ds_req;
+ blkif->st.rd_sect += ring->st.rd_sect;
+ blkif->st.wr_sect += ring->st.wr_sect;
+ }
+
rings = blkif->rings;
blkif->rings = NULL;
blkif->nr_rings = 0;
@@ -399,13 +411,14 @@ void xen_blkif_interface_fini(void)
struct backend_info *be = dev_get_drvdata(&dev->dev); \
struct xen_blkif *blkif = be->blkif; \
unsigned int i; \
- unsigned long long result = 0; \
+ unsigned long long result; \
\
read_lock(&blkif->rings_lock); \
- if (!blkif->rings) \
+ result = blkif->st.name; \
+ if (!blkif->rings) \
goto out; \
\
- for (i = 0; i < blkif->nr_rings; i++) { \
+ for (i = 0; i < blkif->nr_rings; i++) { \
struct xen_blkif_ring *ring = &blkif->rings[i]; \
\
result += ring->st.name; \
--
2.56.0
prev parent reply other threads:[~2026-11-11 16:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 16:20 [PATCH 0/3] xen-blkback: do some I/O statistics rework Juergen Gross
2026-11-11 16:20 ` [PATCH 1/3] xen-blkback: Remove statistics logging on console Juergen Gross
2026-11-11 16:20 ` [PATCH 2/3] xen-blkback: move statistics data into sub-structure Juergen Gross
2026-11-11 16:20 ` Juergen Gross [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=20261111162058.804033-4-jgross@suse.com \
--to=jgross@suse.com \
--cc=axboe@kernel.dk \
--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®