* [PATCH 0/3] xen-blkback: do some I/O statistics rework
@ 2026-11-11 16:20 Juergen Gross
2026-11-11 16:20 ` [PATCH 1/3] xen-blkback: Remove statistics logging on console Juergen Gross
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Juergen Gross @ 2026-11-11 16:20 UTC (permalink / raw)
To: linux-kernel, linux-block
Cc: Juergen Gross, Roger Pau Monné, Jens Axboe, xen-devel
Some rework of the blkback statics data handling.
Juergen Gross (3):
xen-blkback: Remove statistics logging on console
xen-blkback: move statistics data into sub-structure
xen-blkback: make statistics data persistent across disconnect/connect
drivers/block/xen-blkback/blkback.c | 39 ++++++-----------------------
drivers/block/xen-blkback/common.h | 22 ++++++++++------
drivers/block/xen-blkback/xenbus.c | 22 ++++++++++++----
3 files changed, 38 insertions(+), 45 deletions(-)
--
2.56.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] xen-blkback: Remove statistics logging on console
2026-11-11 16:20 [PATCH 0/3] xen-blkback: do some I/O statistics rework Juergen Gross
@ 2026-11-11 16:20 ` 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 ` [PATCH 3/3] xen-blkback: make statistics data persistent across disconnect/connect Juergen Gross
2 siblings, 0 replies; 4+ messages in thread
From: Juergen Gross @ 2026-11-11 16:20 UTC (permalink / raw)
To: linux-kernel, linux-block
Cc: Juergen Gross, Roger Pau Monné, Jens Axboe, xen-devel
The xen-blkback can print I/O statistics data to the console every
10 seconds. This functionality has been present since the introduction
of xen-blkback, but retrieving the data is possible via sysfs, too.
So remove the console logging, as there is no need to have the same
functionality twice.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
drivers/block/xen-blkback/blkback.c | 25 -------------------------
drivers/block/xen-blkback/common.h | 1 -
drivers/block/xen-blkback/xenbus.c | 1 -
3 files changed, 27 deletions(-)
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 88526e349ce1..f3a8f3eae86b 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -126,10 +126,6 @@ MODULE_PARM_DESC(max_ring_page_order, "Maximum order of pages to be used for the
*/
#define LRU_PERCENT_CLEAN 5
-/* Run-time switchable: /sys/module/blkback/parameters/ */
-static unsigned int log_stats;
-module_param(log_stats, int, 0644);
-
#define BLKBACK_INVALID_HANDLE (~0)
static inline bool persistent_gnt_timeout(struct persistent_gnt *persistent_gnt)
@@ -536,21 +532,6 @@ irqreturn_t xen_blkif_be_int(int irq, void *dev_id)
* SCHEDULER FUNCTIONS
*/
-static void print_stats(struct xen_blkif_ring *ring)
-{
- pr_info("(%s): oo %3llu | rd %4llu | wr %4llu | f %4llu"
- " | ds %4llu | pg: %4u/%4d\n",
- current->comm, ring->st_oo_req,
- ring->st_rd_req, ring->st_wr_req,
- ring->st_f_req, ring->st_ds_req,
- ring->persistent_gnt_c, max_pgrants);
- ring->st_print = jiffies + secs_to_jiffies(10);
- ring->st_rd_req = 0;
- ring->st_wr_req = 0;
- ring->st_oo_req = 0;
- ring->st_ds_req = 0;
-}
-
int xen_blkif_schedule(void *arg)
{
struct xen_blkif_ring *ring = arg;
@@ -614,17 +595,11 @@ int xen_blkif_schedule(void *arg)
else
gnttab_page_cache_shrink(&ring->free_pages,
max_buffer_pages);
-
- if (log_stats && time_after(jiffies, ring->st_print))
- print_stats(ring);
}
/* Drain pending purge work */
flush_work(&ring->persistent_purge_work);
- if (log_stats)
- print_stats(ring);
-
ring->xenblkd = NULL;
return 0;
diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
index f5890b3f1df9..0a60e29a7cc3 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -277,7 +277,6 @@ struct xen_blkif_ring {
unsigned long next_lru;
/* Statistics. */
- unsigned long st_print;
unsigned long long st_rd_req;
unsigned long long st_wr_req;
unsigned long long st_oo_req;
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 8d0ff8fcac22..62e3bad4ab0e 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -158,7 +158,6 @@ static int xen_blkif_alloc_rings(struct xen_blkif *blkif,
init_waitqueue_head(&ring->pending_free_wq);
init_waitqueue_head(&ring->shutdown_wq);
ring->blkif = blkif;
- ring->st_print = jiffies;
ring->active = true;
}
--
2.56.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] xen-blkback: move statistics data into sub-structure
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
2026-11-11 16:20 ` [PATCH 3/3] xen-blkback: make statistics data persistent across disconnect/connect Juergen Gross
2 siblings, 0 replies; 4+ messages in thread
From: Juergen Gross @ 2026-11-11 16:20 UTC (permalink / raw)
To: linux-kernel, linux-block
Cc: Juergen Gross, Roger Pau Monné, Jens Axboe, xen-devel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] xen-blkback: make statistics data persistent across disconnect/connect
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
2 siblings, 0 replies; 4+ messages in thread
From: Juergen Gross @ 2026-11-11 16:20 UTC (permalink / raw)
To: linux-kernel, linux-block
Cc: Juergen Gross, Roger Pau Monné, Jens Axboe, xen-devel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-11 16:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 3/3] xen-blkback: make statistics data persistent across disconnect/connect Juergen Gross
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®