Followup merge window block fixes/changes
Subsystems (2)
Jens Axboe
maintainerHi Linus,
A followup pull request, with some parts that either needed a bit more testing before going in, merge sync, or just later arriving fixes. This pull request contains:
- Timer related updates from Kees. These were purposefully delayed since I didn't want to pull in a later v4.14-rc tag to my block tree.
- ide-cd prep sense buffer fix from Bart. Also delayed, as not to clash with the late fix we put into 4.14-rc.
- Small BFQ updates series from Luca and Paolo.
- Single nvmet fix from James, fixing a non-functional case there.
- Bio fast clone fix from Michael, which made bcache return the wrong data for some cases.
- Legacy IO path regression hang fix from Ming.
Please pull!
git://git.kernel.dk/linux-block.git for-linus
----------------------------------------------------------------
Bart Van Assche (1):
ide: Make ide_cdrom_prep_fs() initialize the sense buffer pointer
James Smart (1):
nvmet_fc: fix better length checking
Jens Axboe (1):
Merge branch 'for-4.15/timer' into for-linus
Kees Cook (5):
block/floppy: Convert callback to pass timer_list
amifloppy: Convert timers to use timer_setup() block/aoe: Convert timers to use timer_setup()
block: swim3: Convert timers to use timer_setup()
md: Convert timers to use timer_setup()
Luca Miccio (2):
block, bfq: add missing invocations of bfqg_stats_update_io_add/remove block, bfq: move debug blkio stats behind CONFIG_DEBUG_BLK_CGROUP
Michael Lyle (1):
bio: ensure __bio_clone_fast copies bi_partno
Ming Lei (1):
block: wake up all tasks blocked in get_request()
Paolo Valente (2):
doc, block, bfq: update max IOPS sustainable with BFQ block, bfq: update blkio stats outside the scheduler lock
Documentation/block/bfq-iosched.txt | 43 +++++++++-- block/bfq-cgroup.c | 148 ++++++++++++++++++++---------------- block/bfq-iosched.c | 117 ++++++++++++++++++++++++++-- block/bfq-iosched.h | 4 +- block/bfq-wf2q.c | 1 - block/bio.c | 1 + block/blk-core.c | 4 +- drivers/block/amiflop.c | 57 +++++++------- drivers/block/aoe/aoecmd.c | 6 +- drivers/block/aoe/aoedev.c | 9 +-- drivers/block/floppy.c | 10 ++- drivers/block/swim3.c | 31 ++++---- drivers/ide/ide-cd.c | 3 +- drivers/md/bcache/stats.c | 8 +- drivers/md/dm-delay.c | 6 +- drivers/md/dm-integrity.c | 6 +- drivers/md/dm-raid1.c | 8 +- drivers/md/md.c | 9 +-- drivers/nvme/target/fc.c | 6 +- 19 files changed, 311 insertions(+), 166 deletions(-)
Signature · 1 line
Jens Axboe
Quoted 2 lines · Jens Axboe
- Small BFQ updates series from Luca and Paolo.
Honestly, this code is too ugly to live.
Seriously. That update should have been rejected on the grounds of being completely unmaintainable crap.
Why didn't you?
Why are you allowing code like that patch to bfq_dispatch_request() into the kernel source tree?
Yes, it improves performance. But it does so by adding random #iofdef's into the middle of some pretty crtitical code, with absolutely no attempt at having a sane maintainable code-base.
That function is literally *three* lines of code without the #ifdef case:
spin_lock_irq(&bfqd->lock);
rq = __bfq_dispatch_request(hctx);
spin_unlock_irq(&bfqd->lock);and you could actually see what it did.
But instead of trying to abstract it in some legible manner, that three-line obvious function got *three* copies of the same #if mess all enclosing rancom crap, and the end result is really hard to read.
For example, I just spent a couple of minutes trying to make sense of the code, and stop that unreadable mess. I came up with the appended patch.
It may not work for some reason I can't see, but that's not the point. The attached patch is not meant as a "apply this as-is".
It's meant as a "look, you can write legible code where the statistics just go away when they are compiled out".
Now that "obvious three-liner function" is not three lines any more, but it's at least *clear* straight-line code:
spin_lock_irq(&bfqd->lock);
in_serv_queue = bfqd->in_service_queue;
waiting_rq = in_serv_queue && bfq_bfqq_wait_request(in_serv_queue);
rq = __bfq_dispatch_request(hctx);
idle_timer_disabled =
waiting_rq && !bfq_bfqq_wait_request(in_serv_queue);
spin_unlock_irq(&bfqd->lock);
bfq_dispatch_statistics(hctx, rq, in_serv_queue, waiting_rq,idle_timer_disabled);
and I am hopeful that when bfq_dispatch_statistics() is disabled, the compiler will be smart enough to not generate extra code, certainly not noticeably so.
See? One is a mess of horrible ugly #ifdef's in the middle of the code that makes the end result completely illegible.
The other is actually somewhat legible, and has a clear separation of the statistics gathering. And that *statistics* gathering is clearly optionally enabled or not.
Not the mess of random code put together in random ways that are completely illegble.
Your job as maintainer is _literally_ to tell people "f*ck no, that code is too ugly, you need to write it so that it can be maintained".
And I'm doing my job.
"F*ck no, that code is too ugly, you need to write it so that it can be maintained".
Show some taste.
Linus
block/bfq-iosched.c | 55 ++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 26 deletions(-)
block/bfq-iosched.c +29 -26
@@ -3689,35 +3689,14 @@ static struct request *__bfq_dispatch_request(struct blk_mq_hw_ctx *hctx)return rq; } -static struct request *bfq_dispatch_request (struct blk_mq_hw_ctx *hctx) -{ -struct bfq_data *bfqd = hctx->queue->elevator->elevator_data; -struct request *rq; -#if defined(CONFIG_BFQ_GROUP_IOSCHED ) && defined(CONFIG_DEBUG_BLK_CGROUP ) -struct bfq_queue *in_serv_queue, *bfqq; -bool waiting_rq, idle_timer_disabled; -#endif - -spin_lock_irq (&bfqd->lock); -#if defined(CONFIG_BFQ_GROUP_IOSCHED ) && defined(CONFIG_DEBUG_BLK_CGROUP ) - in_serv_queue = bfqd->in_service_queue; - waiting_rq = in_serv_queue &&bfq_bfqq_wait_request (in_serv_queue); - - rq =__bfq_dispatch_request (hctx); - - idle_timer_disabled = - waiting_rq && !bfq_bfqq_wait_request (in_serv_queue); - -#else - rq =__bfq_dispatch_request (hctx); -#endif -spin_unlock_irq (&bfqd->lock); +static void bfq_dispatch_statistics (struct blk_mq_hw_ctx *hctx,struct request *rq, +struct bfq_queue *in_serv_queue,bool waiting_rq,bool idle_timer_disabled) +{ +struct bfq_queue *bfqq = rq ?RQ_BFQQ (rq) :NULL ; -#if defined(CONFIG_BFQ_GROUP_IOSCHED ) && defined(CONFIG_DEBUG_BLK_CGROUP ) - bfqq = rq ?RQ_BFQQ (rq) :NULL ;if (!idle_timer_disabled && !bfqq) -return rq; +return ;/* * rq and bfqq are guaranteed to exist until this function
@@ -3752,8 +3731,32 @@ static struct request *bfq_dispatch_request(struct blk_mq_hw_ctx *hctx) bfqg_stats_update_io_remove(bfqg, rq->cmd_flags); }spin_unlock_irq (hctx->queue->queue_lock); +} +#else +static inline void bfq_dispatch_statistics (struct blk_mq_hw_ctx *hctx,struct request *rq,struct bfq_queue *in_serv_queue,bool waiting_rq,bool idle_timer_disabled) {}#endif +static struct request *bfq_dispatch_request (struct blk_mq_hw_ctx *hctx) +{ +struct bfq_data *bfqd = hctx->queue->elevator->elevator_data; +struct request *rq; +struct bfq_queue *in_serv_queue; +bool waiting_rq, idle_timer_disabled; + +spin_lock_irq (&bfqd->lock); + + in_serv_queue = bfqd->in_service_queue; + waiting_rq = in_serv_queue &&bfq_bfqq_wait_request (in_serv_queue); + + rq =__bfq_dispatch_request (hctx); + + idle_timer_disabled = + waiting_rq && !bfq_bfqq_wait_request (in_serv_queue); + +spin_unlock_irq (&bfqd->lock); + +bfq_dispatch_statistics (hctx, rq, in_serv_queue, waiting_rq, idle_timer_disabled); +return rq; }
Quoted 3 lines · Linus Torvalds
"F*ck no, that code is too ugly, you need to write it so that it can be maintained".
Dammit, the rest of the pull looks ok, so I'll take it anyway.
But I really do expect you to
(a) clean up that mess - maybe with my patch as an example, but maybe
some entirely different way. The patch I sent is already deleted from my tree, it was purely meant as an example.
(b) really push back on people when they send you ugly code
It shouldn't have to always be me being upset and pushing back on the block pulls.
Linus
Quoted 2 lines
Il giorno 17 nov 2017, alle ore 20:29, Linus Torvalds =
<[email protected]> ha scritto:
Quoted 4 lines
=20
Quoted 2 lines · Jens Axboe
=20
- Small BFQ updates series from Luca and Paolo.
Quoted 16 lines
=20
Honestly, this code is too ugly to live.
=20
Seriously. That update should have been rejected on the grounds of being completely unmaintainable crap.
=20
Why didn't you?
=20
Why are you allowing code like that patch tobfq_dispatch_request()into the kernel source tree?
=20
Yes, it improves performance. But it does so by adding random #iofdef's into the middle of some pretty crtitical code, with absolutely no attempt at having a sane maintainable code-base. =20
That function is literally *three* lines of code without the #ifdef =
case:
Quoted 24 lines
=20
spin_lock_irq(&bfqd->lock); rq =3D __bfq_dispatch_request(hctx); spin_unlock_irq(&bfqd->lock);=20
and you could actually see what it did.
=20
But instead of trying to abstract it in some legible manner, that three-line obvious function got *three* copies of the same #if mess all enclosing rancom crap, and the end result is really hard to read. =20
For example, I just spent a couple of minutes trying to make sense of the code, and stop that unreadable mess. I came up with the appended patch.
=20
It may not work for some reason I can't see, but that's not the point. The attached patch is not meant as a "apply this as-is". =20
It's meant as a "look, you can write legible code where the statistics just go away when they are compiled out".
=20
Now that "obvious three-liner function" is not three lines any more, but it's at least *clear* straight-line code:
=20
Quoted 4 lines
spin_lock_irq(&bfqd->lock);
=20
in_serv_queue =3D bfqd->in_service_queue;
waiting_rq =3D in_serv_queue && =bfq_bfqq_wait_request(in_serv_queue);
Quoted 7 lines
=20
rq =3D __bfq_dispatch_request(hctx); =20 idle_timer_disabled =3D waiting_rq && !bfq_bfqq_wait_request(in_serv_queue); =20 spin_unlock_irq(&bfqd->lock);
Quoted 8 lines
=20
bfq_dispatch_statistics(hctx, rq,in_serv_queue,waiting_rq,idle_timer_disabled);
=20
and I am hopeful that whenbfq_dispatch_statistics()is disabled, the compiler will be smart enough to not generate extra code, certainly not noticeably so.
=20
Sorry for causing this problem. Yours was our first version, but then we feared that leaving useless instructions was worse than adding a burst of ifdefs. I'll try not to repeat this mistake.
Thanks,
Paolo
Quoted 22 lines
See? One is a mess of horrible ugly #ifdef's in the middle of the code that makes the end result completely illegible.
=20
The other is actually somewhat legible, and has a clear separation of the statistics gathering. And that *statistics* gathering is clearly optionally enabled or not.
=20
Not the mess of random code put together in random ways that are completely illegble.
=20
Your job as maintainer is _literally_ to tell people "f*ck no, that code is too ugly, you need to write it so that it can be maintained". =20
And I'm doing my job.
=20
"F*ck no, that code is too ugly, you need to write it so that it can be maintained".
=20
Show some taste.
=20
Linus
<patch.diff>
Quoted 4 lines · Paolo Valente
Sorry for causing this problem. Yours was our first version, but then we feared that leaving useless instructions was worse than adding a burst of ifdefs. I'll try not to repeat this mistake.
So I generally do not want people to depend on the compiler to do non-obvious conversions (so please do not write bad code that you just hope the compiler can sort out and make reasonable), but we do heavily rely on the compiler doing the obvious dead code removal particularly for when things end up not being used.
A lot of the time that's very much something you can and should depend on, because we have abstraction layers that involves a lot of code just becoming no-ops on many architectures, but other architectures need some particular sequence.
Another example is a lot of helper functions to do verification of various kernel rules that then are enabled by some debug option (eg CONFIG_DEBUG_ATOMIC_SLEEP etc), where we know that (and depend on) the compiler will do a reasonable job.
That's not so different from having "statistics gathering function that compiles to nothing".
And yes, sometimes the code might need to be written so that the compiler has an easier time _seeing_ that the core really goes away, so it's not necessarily a blind trust in the compiler.
So for example, the functions that can go away should obviously be inline functions so that you don't end up having the compiler generate the arguments and the call to an empty function body, and so that the compiler can see that "oh, those arguments aren't even used at all, so now I can remove all the code that generates them".
If you are comfy with assembler, it can actually be a great thing to occasionally just verify the actual generated code if it's some piece of code you care deeply about. Obviously for performance work, profiling happens, and then you see it that way.
Because sometimes you find some silly "Duh!" moments, where you didn't realize that the compiler wasn't able to really get rid of something for some reason that is usually very obvious in hindsight, but wasn't actually obvious at all until you looked at what the compiler generated.
Linus
Jens Axboe
maintainerQuoted 10 lines · Linus Torvalds
Quoted 3 lines · Linus Torvalds
"F*ck no, that code is too ugly, you need to write it so that it can be maintained".
Dammit, the rest of the pull looks ok, so I'll take it anyway.
But I really do expect you to
Quoted 8 lines
(a) clean up that mess - maybe with my patch as an example, but maybe
some entirely different way. The patch I sent is already deleted from my tree, it was purely meant as an example.(b) really push back on people when they send you ugly code
It shouldn't have to always be me being upset and pushing back on the block pulls.
My bad, I have probably given Paolo and Luca a bit more leeway than usual, since they are new to upstream development and the BFQ code does need some cleanups here and there. A huge part of that was completed as part of getting it merged, but it still needs a bit of love.
Now that they have received the Linus hazing, I guess the honey moon is over.
In all seriousness, I do push back on crap quite often. Sometimes I miss some too...
Signature · 1 line
Jens Axboe