mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 2/3] xen-blkback: move statistics data into sub-structure
Date: Wed, 11 Nov 2026 17:20:57 +0100	[thread overview]
Message-ID: <20261111162058.804033-3-jgross@suse.com> (raw)
In-Reply-To: <20261111162058.804033-1-jgross@suse.com>

Move the statistics data into a dedicated new struct xen_blkif_stat.

This is done in preparation of not losing statistics in case of
disconnect/reconnect cycles.

No functional change intended.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 drivers/block/xen-blkback/blkback.c | 14 +++++++-------
 drivers/block/xen-blkback/common.h  | 19 ++++++++++++-------
 drivers/block/xen-blkback/xenbus.c  |  2 +-
 3 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index f3a8f3eae86b..e2f09bd4e84e 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -958,7 +958,7 @@ static int dispatch_discard_io(struct xen_blkif_ring *ring,
 			preq.sector_number + preq.nr_sects, blkif->vbd.pdevice);
 		goto fail_response;
 	}
-	ring->st_ds_req++;
+	ring->st.ds_req++;
 
 	if (blkif->vbd.discard_secure &&
 	    (req->u.discard.flag & BLKIF_DISCARD_SECURE))
@@ -1198,7 +1198,7 @@ __do_block_io_op(struct xen_blkif_ring *ring, unsigned int *eoi_flags)
 
 		pending_req = alloc_req(ring);
 		if (NULL == pending_req) {
-			ring->st_oo_req++;
+			ring->st.oo_req++;
 			more_to_do = 1;
 			break;
 		}
@@ -1297,11 +1297,11 @@ static int dispatch_rw_block_io(struct xen_blkif_ring *ring,
 
 	switch (req_operation) {
 	case BLKIF_OP_READ:
-		ring->st_rd_req++;
+		ring->st.rd_req++;
 		operation = REQ_OP_READ;
 		break;
 	case BLKIF_OP_WRITE:
-		ring->st_wr_req++;
+		ring->st.wr_req++;
 		operation = REQ_OP_WRITE;
 		operation_flags = REQ_SYNC | REQ_IDLE;
 		break;
@@ -1309,7 +1309,7 @@ static int dispatch_rw_block_io(struct xen_blkif_ring *ring,
 		drain = true;
 		fallthrough;
 	case BLKIF_OP_FLUSH_DISKCACHE:
-		ring->st_f_req++;
+		ring->st.f_req++;
 		operation = REQ_OP_WRITE;
 		operation_flags = REQ_PREFLUSH;
 		break;
@@ -1445,9 +1445,9 @@ static int dispatch_rw_block_io(struct xen_blkif_ring *ring,
 	blk_finish_plug(&plug);
 
 	if (operation == REQ_OP_READ)
-		ring->st_rd_sect += preq.nr_sects;
+		ring->st.rd_sect += preq.nr_sects;
 	else if (operation == REQ_OP_WRITE)
-		ring->st_wr_sect += preq.nr_sects;
+		ring->st.wr_sect += preq.nr_sects;
 
 	return 0;
 
diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
index 0a60e29a7cc3..f8385c4b9d30 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -248,6 +248,17 @@ struct persistent_gnt {
 	struct list_head remove_node;
 };
 
+/* Statistic data. */
+struct xen_blkif_stat {
+	unsigned long long	rd_req;
+	unsigned long long	wr_req;
+	unsigned long long	oo_req;
+	unsigned long long	f_req;
+	unsigned long long	ds_req;
+	unsigned long long	rd_sect;
+	unsigned long long	wr_sect;
+};
+
 /* Per-ring information. */
 struct xen_blkif_ring {
 	/* Physical parameters of the comms window. */
@@ -277,13 +288,7 @@ struct xen_blkif_ring {
 	unsigned long           next_lru;
 
 	/* Statistics. */
-	unsigned long long	st_rd_req;
-	unsigned long long	st_wr_req;
-	unsigned long long	st_oo_req;
-	unsigned long long	st_f_req;
-	unsigned long long	st_ds_req;
-	unsigned long long	st_rd_sect;
-	unsigned long long	st_wr_sect;
+	struct xen_blkif_stat	st;
 
 	/* Used by the kworker that offload work from the persistent purge. */
 	struct list_head	persistent_purge_list;
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 62e3bad4ab0e..b3ef483a92fd 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -408,7 +408,7 @@ void xen_blkif_interface_fini(void)
 		for (i = 0; i < blkif->nr_rings; i++) {		\
 			struct xen_blkif_ring *ring = &blkif->rings[i];	\
 									\
-			result += ring->st_##name;			\
+			result += ring->st.name;			\
 		}							\
 									\
 out:									\
-- 
2.56.0


  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 ` Juergen Gross [this message]
2026-11-11 16:20 ` [PATCH 3/3] xen-blkback: make statistics data persistent across disconnect/connect Juergen Gross

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-3-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®