Message ID | 20210324121927.362525-4-ming.lei@redhat.com (mailing list archive) |
---|---|
State | Superseded, archived |
Delegated to: | Mike Snitzer |
Headers | show |
Series | block: support bio based io polling | expand |
On 3/24/21 1:19 PM, Ming Lei wrote: > Add one helper for creating io context and prepare for supporting > efficient bio based io poll. > > Meantime move the code of creating io_context before checking bio's > REQ_HIPRI flag because the following patch may change to clear REQ_HIPRI > if io_context can't be created. > > Signed-off-by: Ming Lei <ming.lei@redhat.com> > --- > block/blk-core.c | 23 ++++++++++++++--------- > 1 file changed, 14 insertions(+), 9 deletions(-) > Reviewed-by: Hannes Reinecke <hare@suse.de> Cheers, Hannes
On Wed, Mar 24, 2021 at 08:19:17PM +0800, Ming Lei wrote: > +static inline void blk_create_io_context(struct request_queue *q) > +{ > + /* > + * Various block parts want %current->io_context, so allocate it up > + * front rather than dealing with lots of pain to allocate it only > + * where needed. This may fail and the block layer knows how to live > + * with it. > + */ I think this comment would make more sense if it were placed above the caller rather than within this function. > + if (unlikely(!current->io_context)) > + create_task_io_context(current, GFP_ATOMIC, q->node); > +} > + > static noinline_for_stack bool submit_bio_checks(struct bio *bio) > { > struct block_device *bdev = bio->bi_bdev; > @@ -836,6 +848,8 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio) > } > } > > + blk_create_io_context(q); > + > if (!blk_queue_poll(q)) > bio->bi_opf &= ~REQ_HIPRI; > > @@ -876,15 +890,6 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio) > break; > } > > - /* > - * Various block parts want %current->io_context, so allocate it up > - * front rather than dealing with lots of pain to allocate it only > - * where needed. This may fail and the block layer knows how to live > - * with it. > - */ > - if (unlikely(!current->io_context)) > - create_task_io_context(current, GFP_ATOMIC, q->node); > - > if (blk_throtl_bio(bio)) { > blkcg_bio_issue_init(bio); > return false; > -- > 2.29.2 -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel
On Wed, Mar 24, 2021 at 08:19:17PM +0800, Ming Lei wrote: > Add one helper for creating io context and prepare for supporting > efficient bio based io poll. Looking at what gets added later here I do not think this helper is a good idea. Having a separate one for creating any needed poll-only context is a lot more clear. -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel
On Wed, Mar 24, 2021 at 07:17:02PM +0100, Christoph Hellwig wrote: > On Wed, Mar 24, 2021 at 08:19:17PM +0800, Ming Lei wrote: > > Add one helper for creating io context and prepare for supporting > > efficient bio based io poll. > > Looking at what gets added later here I do not think this helper is > a good idea. Having a separate one for creating any needed poll-only > context is a lot more clear. The poll context actually depends on io_context, that is why I put them all into one single helper. thanks, Ming -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel
diff --git a/block/blk-core.c b/block/blk-core.c index a31371d55b9d..d58f8a0c80de 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -792,6 +792,18 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q, return BLK_STS_OK; } +static inline void blk_create_io_context(struct request_queue *q) +{ + /* + * Various block parts want %current->io_context, so allocate it up + * front rather than dealing with lots of pain to allocate it only + * where needed. This may fail and the block layer knows how to live + * with it. + */ + if (unlikely(!current->io_context)) + create_task_io_context(current, GFP_ATOMIC, q->node); +} + static noinline_for_stack bool submit_bio_checks(struct bio *bio) { struct block_device *bdev = bio->bi_bdev; @@ -836,6 +848,8 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio) } } + blk_create_io_context(q); + if (!blk_queue_poll(q)) bio->bi_opf &= ~REQ_HIPRI; @@ -876,15 +890,6 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio) break; } - /* - * Various block parts want %current->io_context, so allocate it up - * front rather than dealing with lots of pain to allocate it only - * where needed. This may fail and the block layer knows how to live - * with it. - */ - if (unlikely(!current->io_context)) - create_task_io_context(current, GFP_ATOMIC, q->node); - if (blk_throtl_bio(bio)) { blkcg_bio_issue_init(bio); return false;
Add one helper for creating io context and prepare for supporting efficient bio based io poll. Meantime move the code of creating io_context before checking bio's REQ_HIPRI flag because the following patch may change to clear REQ_HIPRI if io_context can't be created. Signed-off-by: Ming Lei <ming.lei@redhat.com> --- block/blk-core.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)