xen-blkback: do some I/O statistics rework
Subsystems (2)
cover xen-blkback: do some I/O statistics rework
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(-)
Signature · 1 line
2.56.0
PATCH 1/3 xen-blkback: Remove statistics logging on console
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.
--- 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(-)
drivers/block/xen-blkback/blkback.c +0 -25
@@ -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 ;
drivers/block/xen-blkback/common.h +0 -1
@@ -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;
drivers/block/xen-blkback/xenbus.c +0 -1
@@ -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; }
Signature · 1 line
2.56.0
PATCH 2/3 xen-blkback: move statistics data into sub-structure
In reply to Juergen GrossMove 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.
--- 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(-)
drivers/block/xen-blkback/blkback.c +7 -7
@@ -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 ;
drivers/block/xen-blkback/common.h +12 -7
@@ -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;
drivers/block/xen-blkback/xenbus.c +1 -1
@@ -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: \
Signature · 1 line
2.56.0
PATCH 3/3 xen-blkback: make statistics data persistent across disconnect/connect
In reply to Juergen GrossToday 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.
--- drivers/block/xen-blkback/common.h | 2 ++ drivers/block/xen-blkback/xenbus.c | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-)
drivers/block/xen-blkback/common.h +2 -0
@@ -327,6 +327,8 @@ struct xen_blkif {unsigned int nr_rings;unsigned long buffer_squeeze_end; + +struct xen_blkif_stat st; };struct seg_buf {
drivers/block/xen-blkback/xenbus.c +16 -3
@@ -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; \
Signature · 1 line
2.56.0
Quoted 6 lines · Juergen Gross
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
In the last patch a brief comment on the global stats instance may be worth, to indicate it's guarded by the rings lock.
Also, do I maybe get a Reported-by: on the last patch?
Jan
Quoted 8 lines · Jan Beulich
Quoted 6 lines · Juergen Gross
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/connectReviewed-by Jan Beulich <[email protected]>
Thanks.
Quoted 4 lines
In the last patch a brief comment on the global stats instance may be worth, to indicate it's guarded by the rings lock.
Also, do I maybe get a Reported-by: on the last patch?
Yes to both. :-)
Juergen