blk-mq: remove hybrid polling
Subsystems (2)
PATCH 1/1 blk-mq: remove hybrid polling
From: Keith Busch <[email protected]>
io_uring provides the only way user space can poll completions, and that always sets BLK_POLL_NOSLEEP. This effectively makes hybrid polling dead code, so remove it and everything supporting it.
--- block/blk-core.c | 6 -- block/blk-mq-debugfs.c | 26 ------ block/blk-mq.c | 205 ++--------------------------------------- block/blk-stat.c | 18 ---- block/blk-sysfs.c | 33 +------ include/linux/blk-mq.h | 2 - include/linux/blkdev.h | 12 --- io_uring/rw.c | 2 +- 8 files changed, 9 insertions(+), 295 deletions(-)
block/blk-core.c +0 -6
@@ -263,13 +263,7 @@ static void blk_free_queue_rcu(struct rcu_head *rcu_head)static void blk_free_queue (struct request_queue *q) { -if (q->poll_stat) -blk_stat_remove_callback (q, q->poll_cb); -blk_stat_free_callback (q->poll_cb); -blk_free_queue_stats (q->stats); -kfree (q->poll_stat); -if (queue_is_mq (q))blk_mq_release (q);
block/blk-mq-debugfs.c +0 -26
@@ -15,33 +15,8 @@#include "blk-mq-tag.h" #include "blk-rq-qos.h" -static void print_stat (struct seq_file *m,struct blk_rq_stat *stat) -{ -if (stat->nr_samples) { -seq_printf (m,"samples=%d, mean=%llu, min=%llu, max=%llu" , - stat->nr_samples, stat->mean, stat->min, stat->max); - }else { -seq_puts (m,"samples=0" ); - } -} -static int queue_poll_stat_show (void *data,struct seq_file *m) { -struct request_queue *q = data; -int bucket; - -if (!q->poll_stat) -return 0 ; - -for (bucket =0 ; bucket < (BLK_MQ_POLL_STATS_BKTS /2 ); bucket++) { -seq_printf (m,"read (%d Bytes): " ,1 << (9 + bucket)); -print_stat (m, &q->poll_stat[2 * bucket]); -seq_puts (m,"\n" ); - -seq_printf (m,"write (%d Bytes): " ,1 << (9 + bucket)); -print_stat (m, &q->poll_stat[2 * bucket +1 ]); -seq_puts (m,"\n" ); - }return 0 ; }
@@ -282,7 +257,6 @@ static const char *const rqf_name[] = {RQF_NAME (STATS ),RQF_NAME (SPECIAL_PAYLOAD ),RQF_NAME (ZONE_WRITE_LOCKED ), -RQF_NAME (MQ_POLL_SLEPT ),RQF_NAME (TIMED_OUT ),RQF_NAME (ELV ), RQF_NAME(RESV),
block/blk-mq.c +6 -199
256 lines not on this page · raw message
block/blk-stat.c +0 -18
@@ -231,21 +231,3 @@ void blk_free_queue_stats(struct blk_queue_stats *stats)kfree (stats); } - -bool blk_stats_alloc_enable (struct request_queue *q) -{ -struct blk_rq_stat *poll_stat; - - poll_stat =kcalloc (BLK_MQ_POLL_STATS_BKTS ,sizeof (*poll_stat), -GFP_ATOMIC ); -if (!poll_stat) -return false; - -if (cmpxchg (&q->poll_stat,NULL , poll_stat) !=NULL ) { -kfree (poll_stat); -return true; - } - -blk_stat_add_callback (q, q->poll_cb); -return false; -}
block/blk-sysfs.c +2 -31
@@ -408,36 +408,7 @@ queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count)static ssize_t queue_poll_delay_show (struct request_queue *q,char *page) { -int val; - -if (q->poll_nsec ==BLK_MQ_POLL_CLASSIC ) - val =BLK_MQ_POLL_CLASSIC ; -else - val = q->poll_nsec /1000 ; - -return sprintf (page,"%d\n" , val); -} - -static ssize_t queue_poll_delay_store (struct request_queue *q,const char *page, -size_t count) -{ -int err, val; - -if (!q->mq_ops || !q->mq_ops->poll) -return -EINVAL ; - - err =kstrtoint (page,10 , &val); -if (err <0 ) -return err; - -if (val ==BLK_MQ_POLL_CLASSIC ) - q->poll_nsec =BLK_MQ_POLL_CLASSIC ; -else if (val >=0 ) - q->poll_nsec = val *1000 ; -else -return -EINVAL ; - -return count; +return sprintf (page,"%d\n" ,-1 ); }static ssize_t queue_poll_show (struct request_queue *q,char *page)
@@ -617,7 +588,7 @@ QUEUE_RO_ENTRY(queue_max_active_zones, "max_active_zones");QUEUE_RW_ENTRY (queue_nomerges,"nomerges" );QUEUE_RW_ENTRY (queue_rq_affinity,"rq_affinity" );QUEUE_RW_ENTRY (queue_poll,"io_poll" ); -QUEUE_RW_ENTRY (queue_poll_delay,"io_poll_delay" ); +QUEUE_RO_ENTRY (queue_poll_delay,"io_poll_delay" );QUEUE_RW_ENTRY (queue_wc,"write_cache" );QUEUE_RO_ENTRY (queue_fua,"fua" );QUEUE_RO_ENTRY (queue_dax,"dax" );
include/linux/blk-mq.h +0 -2
@@ -57,8 +57,6 @@ typedef __u32 __bitwise req_flags_t;#define RQF_SPECIAL_PAYLOAD ((__force req_flags_t)(1 << 18))/* The per-zone write lock is held for this request */ #define RQF_ZONE_WRITE_LOCKED ((__force req_flags_t)(1 << 19)) -/* already slept for hybrid poll */ -#define RQF_MQ_POLL_SLEPT ((__force req_flags_t)(1 << 20))/* ->timeout has been called, don't expire again */ #define RQF_TIMED_OUT ((__force req_flags_t)(1 << 21))/* queue has elevator attached */
include/linux/blkdev.h +0 -12
@@ -44,12 +44,6 @@ extern const struct device_type disk_type;extern struct device_type part_type;extern struct class block_class; -/* Must be consistent with blk_mq_poll_stats_bkt() */ -#define BLK_MQ_POLL_STATS_BKTS 16 - -/* Doing classic polling */ -#define BLK_MQ_POLL_CLASSIC -1 -/* * Maximum number of blkcg policies allowed to be registered concurrently. * Defined here to simplify include dependency.
@@ -468,10 +462,6 @@ struct request_queue {#endif unsigned int rq_timeout; -int poll_nsec; - -struct blk_stat_callback *poll_cb; -struct blk_rq_stat *poll_stat;struct timer_list timeout;struct work_struct timeout_work;
@@ -870,8 +860,6 @@ blk_status_t errno_to_blk_status(int errno);/* only poll the hardware once, don't continue until a completion was found */ #define BLK_POLL_ONESHOT (1 << 0) -/* do not sleep to wait for the expected completion time */ -#define BLK_POLL_NOSLEEP (1 << 1)int bio_poll (struct bio *bio,struct io_comp_batch *iob,unsigned int flags);int iocb_bio_iopoll (struct kiocb *kiocb,struct io_comp_batch *iob,unsigned int flags);
io_uring/rw.c +1 -1
@@ -1002,7 +1002,7 @@ void io_rw_fail(struct io_kiocb *req)int io_do_iopoll (struct io_ring_ctx *ctx,bool force_nonspin) {struct io_wq_work_node *pos, *start, *prev; -unsigned int poll_flags =BLK_POLL_NOSLEEP ; +unsigned int poll_flags =0 ;DEFINE_IO_COMP_BATCH (iob);int nr_events =0 ;
Signature · 1 line
2.34.1
Jens Axboe
maintainerQuoted 30 lines
block/blk-sysfs.c +0
-22@@ -408,36 +408,7 @@ queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count)static ssize_t queue_poll_delay_show (struct request_queue *q,char *page) { -int val; - -if (q->poll_nsec ==BLK_MQ_POLL_CLASSIC ) - val =BLK_MQ_POLL_CLASSIC ; -else - val = q->poll_nsec /1000 ; - -return sprintf (page,"%d\n" , val); -} - -static ssize_t queue_poll_delay_store (struct request_queue *q,const char *page, -size_t count) -{ -int err, val; - -if (!q->mq_ops || !q->mq_ops->poll) -return -EINVAL ; - - err =kstrtoint (page,10 , &val); -if (err <0 ) -return err; -
block/blk-sysfs.c queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count) · line 412
Quoted 10 lines
block/blk-sysfs.c +1
-8-if (val ==BLK_MQ_POLL_CLASSIC ) - q->poll_nsec =BLK_MQ_POLL_CLASSIC ; -else if (val >=0 ) - q->poll_nsec = val *1000 ; -else -return -EINVAL ; - -return count; +return sprintf (page,"%d\n" ,-1 ); }
Do we want to retain the _store setting here to avoid breaking anything? Yes, it won't do anything, but it's not like hybrid or classic poll had differences that would be user visible (outside of perhaps using different amounts of CPU).
Apart from that, not any major comments. Killing all of this (now) unused code is great! Thanks for doing it.
Signature · 1 line
Jens Axboe
Quoted 34 lines · Jens Axboe
Quoted 34 lines
block/blk-sysfs.c +0
-26@@ -408,36 +408,7 @@ queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count)static ssize_t queue_poll_delay_show (struct request_queue *q,char *page) { -int val; - -if (q->poll_nsec ==BLK_MQ_POLL_CLASSIC ) - val =BLK_MQ_POLL_CLASSIC ; -else - val = q->poll_nsec /1000 ; - -return sprintf (page,"%d\n" , val); -} - -static ssize_t queue_poll_delay_store (struct request_queue *q,const char *page, -size_t count) -{ -int err, val; - -if (!q->mq_ops || !q->mq_ops->poll) -return -EINVAL ; - - err =kstrtoint (page,10 , &val); -if (err <0 ) -return err; - -if (val ==BLK_MQ_POLL_CLASSIC ) - q->poll_nsec =BLK_MQ_POLL_CLASSIC ; -else if (val >=0 ) - q->poll_nsec = val *1000 ;
Quoted 8 lines
block/blk-sysfs.c queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count) · line 412
Quoted 6 lines
block/blk-sysfs.c +1
-4-else -return -EINVAL ; - -return count; +return sprintf (page,"%d\n" ,-1 ); }Do we want to retain the
_storesetting here to avoid breaking anything?
I was thinking users would want to know the kernel isn't going to honor the requested value. Errors can already happen if you're using a stacked device, so I assmued removing '_store' wouldn't break anyone using this interface.
But I can see it both ways though, so whichever you prefer. At the very least, though, I need to update Documentation's sysfs-block, so I'll do that in the v2.
Jens Axboe
maintainerQuoted 44 lines · Keith Busch
Quoted 34 lines · Jens Axboe
Quoted 34 lines
block/blk-sysfs.c +0
-26@@ -408,36 +408,7 @@ queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count)static ssize_t queue_poll_delay_show (struct request_queue *q,char *page) { -int val; - -if (q->poll_nsec ==BLK_MQ_POLL_CLASSIC ) - val =BLK_MQ_POLL_CLASSIC ; -else - val = q->poll_nsec /1000 ; - -return sprintf (page,"%d\n" , val); -} - -static ssize_t queue_poll_delay_store (struct request_queue *q,const char *page, -size_t count) -{ -int err, val; - -if (!q->mq_ops || !q->mq_ops->poll) -return -EINVAL ; - - err =kstrtoint (page,10 , &val); -if (err <0 ) -return err; - -if (val ==BLK_MQ_POLL_CLASSIC ) - q->poll_nsec =BLK_MQ_POLL_CLASSIC ; -else if (val >=0 ) - q->poll_nsec = val *1000 ;Quoted 8 lines
block/blk-sysfs.c queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count) · line 412
Quoted 6 lines
block/blk-sysfs.c +1
-4-else -return -EINVAL ; - -return count; +return sprintf (page,"%d\n" ,-1 ); }Do we want to retain the
_storesetting here to avoid breaking anything?
Quoted 8 lines
I was thinking users would want to know the kernel isn't going to honor the requested value. Errors can already happen if you're using a stacked device, so I assmued removing '
_store' wouldn't break anyone using this interface.But I can see it both ways though, so whichever you prefer. At the very least, though, I need to update Documentation's sysfs-block, so I'll do that in the v2.
Users knowing == things breaking. Because it isn't a person looking at that thing, it's some script or application. So I do think it's better to just pretend we did something, and just not do anything. Because it won't change anything in terms of the application working. If you did you use hybrid polling, it'll still work fine with classic.
Arguably not a high risk thing, but I'd prefer decoupling the two changes and then we can yank the store method at some later point in time.
Signature · 1 line
Jens Axboe