Re: [RFC PATCH v2] blk-mq: Introduce per sw queue time-slice
On Wed, Feb 10, 2016 at 08:47:15PM +0100, Markus Trippelsdorf wrote: > On 2016.02.10 at 20:34 +0100, Andreas Herrmann wrote: > > On Tue, Feb 09, 2016 at 06:41:56PM +0100, Markus Trippelsdorf wrote: > > > > Recently Johannes sent a patch to enable scsi-mq per driver, see > > > > http://marc.info/?l=linux-scsi&m=145347009631192&w=2 > > > > > > > > Probably that is a good solution (at least in the short term) to allow > > > > users to switch to blk-mq for some host adapters (with fast storage > > > > attached) but to stick to legacy stuff on other host adapters with > > > > rotary devices. > > > > > > I don't think that Johannes' patch is a good solution. > > > > Why? Because it's not per device? > > Yes. Like Christoph said in his reply to the patch: »The host is simply > the wrong place to decide these things.« > > > > The best solution for the user would be if blk-mq could be toggled > > > per drive (or even automatically enabled if queue/rotational == 0). > > > > Yes, I aggree, but ... > > > > > Is there a fundamental reason why this is not feasible? > > > > ... it's not possible (*) with the current implementation. > > > > Tag handling/command allocation differs. Respective functions are set > > per host. > > > > (*) Or maybe it's possible but just hard to achieve and I didn't look > > long enough into relevant code to get an idea how to do it. > > > > > Your solution is better than nothing, but it requires that the user > > > finds out the drive <=> host mapping by hand and then runs something > > > like: > > > echo "250" > > > > /sys/devices/pci:00/:00:11.0/ata2/host1/target1:0:0/1:0:0:0/block/sdb/mq/0/time_slice_us > > > during boot for spinning rust drives... > > > > Or it could automatically be set in case of rotational device. > > (Once we know for sure that it doesn't cause performance degradation.) > > Yes, this sound like a good idea. > > But, if I understand things correctly, your patch is only an interim > solution until proper I/O scheduler support gets implemented for blk-mq, no? That's to be discussed. (Hence the RFC) My (potentially wrong) claims are - I don't think that fast storage (e.g. SSDs) requires I/O scheduler support with blk-mq. blk-mq is very good at pushing a large number of requests from per CPU sw queues to hw queue(s). Why then introduce any overhead for I/O scheduler support? - Slow storage (e.g. spinning drives) is fine with the old code which provides scheduler support and I doubt that there is any benefit for those devices when switching to blk-mq. - The big hammer (scsi_mod.use_blk_mq) for the entire scsi stack to decide what to use is suboptimal. You can't have optimal performance when you have both slow and fast storage devices in your system. I doubt that it is possible to add I/O scheduling support to blk-mq which can be on par with what CFQ is able to achieve for slow devices at the moment. Requests are scattered among per-CPU software queues (and almost instantly passed to hardware queue(s)). Due to CPU scheduling, requests initiated from one process might come down via different software queues. What is an efficient way to sort/merge requests from all the software queues in such a way that the result is comparable to what CFQ does (assuming that CFQ provides optimal performance)? So far I didn't find a solution to this problem. (I just have this patch which adds not too much overhead and improves the situation a little bit.) Maybe the solution is to avoid per-CPU queues for slow storage and fall back to a set of queues comparable to what CFQ uses. One way to do this is by falling back to non-blk-mq code and direct use of CFQ. Code that allows to select blk-mq per host would help to some extent. But when you have both device types connected to the same host adapter it doesn't help either. Andreas -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH v2] blk-mq: Introduce per sw queue time-slice
On 2016.02.10 at 20:34 +0100, Andreas Herrmann wrote: > On Tue, Feb 09, 2016 at 06:41:56PM +0100, Markus Trippelsdorf wrote: > > > Recently Johannes sent a patch to enable scsi-mq per driver, see > > > http://marc.info/?l=linux-scsi&m=145347009631192&w=2 > > > > > > Probably that is a good solution (at least in the short term) to allow > > > users to switch to blk-mq for some host adapters (with fast storage > > > attached) but to stick to legacy stuff on other host adapters with > > > rotary devices. > > > > I don't think that Johannes' patch is a good solution. > > Why? Because it's not per device? Yes. Like Christoph said in his reply to the patch: »The host is simply the wrong place to decide these things.« > > The best solution for the user would be if blk-mq could be toggled > > per drive (or even automatically enabled if queue/rotational == 0). > > Yes, I aggree, but ... > > > Is there a fundamental reason why this is not feasible? > > ... it's not possible (*) with the current implementation. > > Tag handling/command allocation differs. Respective functions are set > per host. > > (*) Or maybe it's possible but just hard to achieve and I didn't look > long enough into relevant code to get an idea how to do it. > > > Your solution is better than nothing, but it requires that the user > > finds out the drive <=> host mapping by hand and then runs something > > like: > > echo "250" > > > /sys/devices/pci:00/:00:11.0/ata2/host1/target1:0:0/1:0:0:0/block/sdb/mq/0/time_slice_us > > during boot for spinning rust drives... > > Or it could automatically be set in case of rotational device. > (Once we know for sure that it doesn't cause performance degradation.) Yes, this sound like a good idea. But, if I understand things correctly, your patch is only an interim solution until proper I/O scheduler support gets implemented for blk-mq, no? -- Markus -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH v2] blk-mq: Introduce per sw queue time-slice
On Tue, Feb 09, 2016 at 06:41:56PM +0100, Markus Trippelsdorf wrote: > On 2016.02.09 at 18:12 +0100, Andreas Herrmann wrote: > > [CC-ing linux-block and linux-scsi and adding some comments] > > > > On Mon, Feb 01, 2016 at 11:43:40PM +0100, Andreas Herrmann wrote: > > > This introduces a new blk_mq hw attribute time_slice_us which allows > > > to specify a time slice in usecs. > > > > > > Fio test results are sent in a separate mail to this. > > > > See http://marc.info/?l=linux-kernel&m=145436682607949&w=2 > > > > In short it shows significant performance gains in some tests, > > e.g. sequential read iops up by >40% with 8 jobs. But it's never on > > par with CFQ when more than 1 job was used during the test. > > > > > Results for fio improved to some extent with this patch. But in > > > reality the picture is quite mixed. Performance is highly dependend on > > > task scheduling. There is no guarantee that the requests originated > > > from one CPU belong to the same process. > > > > > > I think for rotary devices CFQ is by far the best choice. A simple > > > illustration is: > > > > > > Copying two files (750MB in this case) in parallel on a rotary > > > device. The elapsed wall clock time (seconds) for this is > > >meanstdev > > >cfq, slice_idle=8 16.18 4.95 > > >cfq, slice_idle=0 23.74 2.82 > > >blk-mq, time_slice_usec=0 24.37 2.05 > > >blk-mq, time_slice_usec=250 25.58 3.16 > > > > This illustrates that although their was performance gain with fio > > tests, the patch can cause higher variance and lower performance in > > comparison to unmodified blk-mq with other tests. And it underscores > > superiority of CFQ for rotary disks. > > > > Meanwhile my opinion is that it's not really worth to look further > > into introduction of I/O scheduling support in blk-mq. I don't see the > > need for scheduling support (deadline or something else) for fast > > storage devices. And rotary devices should really avoid usage of blk-mq > > and stick to CFQ. > > > > Thus I think that introducing some coexistence of blk-mq and the > > legacy block with CFQ is the best option. > > > > Recently Johannes sent a patch to enable scsi-mq per driver, see > > http://marc.info/?l=linux-scsi&m=145347009631192&w=2 > > > > Probably that is a good solution (at least in the short term) to allow > > users to switch to blk-mq for some host adapters (with fast storage > > attached) but to stick to legacy stuff on other host adapters with > > rotary devices. > > I don't think that Johannes' patch is a good solution. Why? Because it's not per device? > The best solution for the user would be if blk-mq could be toggled > per drive (or even automatically enabled if queue/rotational == 0). Yes, I aggree, but ... > Is there a fundamental reason why this is not feasible? ... it's not possible (*) with the current implementation. Tag handling/command allocation differs. Respective functions are set per host. (*) Or maybe it's possible but just hard to achieve and I didn't look long enough into relevant code to get an idea how to do it. > Your solution is better than nothing, but it requires that the user > finds out the drive <=> host mapping by hand and then runs something > like: > echo "250" > > /sys/devices/pci:00/:00:11.0/ata2/host1/target1:0:0/1:0:0:0/block/sdb/mq/0/time_slice_us > during boot for spinning rust drives... Or it could automatically be set in case of rotational device. (Once we know for sure that it doesn't cause performance degradation.) > -- > Markus Andreas -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH v2] blk-mq: Introduce per sw queue time-slice
On 2016.02.09 at 18:12 +0100, Andreas Herrmann wrote: > [CC-ing linux-block and linux-scsi and adding some comments] > > On Mon, Feb 01, 2016 at 11:43:40PM +0100, Andreas Herrmann wrote: > > This introduces a new blk_mq hw attribute time_slice_us which allows > > to specify a time slice in usecs. > > > > Fio test results are sent in a separate mail to this. > > See http://marc.info/?l=linux-kernel&m=145436682607949&w=2 > > In short it shows significant performance gains in some tests, > e.g. sequential read iops up by >40% with 8 jobs. But it's never on > par with CFQ when more than 1 job was used during the test. > > > Results for fio improved to some extent with this patch. But in > > reality the picture is quite mixed. Performance is highly dependend on > > task scheduling. There is no guarantee that the requests originated > > from one CPU belong to the same process. > > > > I think for rotary devices CFQ is by far the best choice. A simple > > illustration is: > > > > Copying two files (750MB in this case) in parallel on a rotary > > device. The elapsed wall clock time (seconds) for this is > >meanstdev > >cfq, slice_idle=8 16.18 4.95 > >cfq, slice_idle=0 23.74 2.82 > >blk-mq, time_slice_usec=0 24.37 2.05 > >blk-mq, time_slice_usec=250 25.58 3.16 > > This illustrates that although their was performance gain with fio > tests, the patch can cause higher variance and lower performance in > comparison to unmodified blk-mq with other tests. And it underscores > superiority of CFQ for rotary disks. > > Meanwhile my opinion is that it's not really worth to look further > into introduction of I/O scheduling support in blk-mq. I don't see the > need for scheduling support (deadline or something else) for fast > storage devices. And rotary devices should really avoid usage of blk-mq > and stick to CFQ. > > Thus I think that introducing some coexistence of blk-mq and the > legacy block with CFQ is the best option. > > Recently Johannes sent a patch to enable scsi-mq per driver, see > http://marc.info/?l=linux-scsi&m=145347009631192&w=2 > > Probably that is a good solution (at least in the short term) to allow > users to switch to blk-mq for some host adapters (with fast storage > attached) but to stick to legacy stuff on other host adapters with > rotary devices. I don't think that Johannes' patch is a good solution. The best solution for the user would be if blk-mq could be toggled per drive (or even automatically enabled if queue/rotational == 0). Is there a fundamental reason why this is not feasible? Your solution is better than nothing, but it requires that the user finds out the drive <=> host mapping by hand and then runs something like: echo "250" > /sys/devices/pci:00/:00:11.0/ata2/host1/target1:0:0/1:0:0:0/block/sdb/mq/0/time_slice_us during boot for spinning rust drives... -- Markus -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH v2] blk-mq: Introduce per sw queue time-slice
[CC-ing linux-block and linux-scsi and adding some comments] On Mon, Feb 01, 2016 at 11:43:40PM +0100, Andreas Herrmann wrote: > This introduces a new blk_mq hw attribute time_slice_us which allows > to specify a time slice in usecs. > > Default value is 0 and implies no modification to blk-mq behaviour. > > A positive value changes blk-mq to service only one software queue > within this time slice until it expires or the software queue is > empty. Then the next software queue with pending requests is selected. > > Signed-off-by: Andreas Herrmann > --- > block/blk-mq-sysfs.c | 27 +++ > block/blk-mq.c | 208 > + > include/linux/blk-mq.h | 9 +++ > 3 files changed, 211 insertions(+), 33 deletions(-) > > Hi, > > This update is long overdue (sorry for the delay). > > Change to v1: > - time slice is now specified in usecs instead of msecs. > - time slice is extended (up to 3 times the initial value) when there > was actually a request to be serviced for the software queue > > Fio test results are sent in a separate mail to this. See http://marc.info/?l=linux-kernel&m=145436682607949&w=2 In short it shows significant performance gains in some tests, e.g. sequential read iops up by >40% with 8 jobs. But it's never on par with CFQ when more than 1 job was used during the test. > Results for fio improved to some extent with this patch. But in > reality the picture is quite mixed. Performance is highly dependend on > task scheduling. There is no guarantee that the requests originated > from one CPU belong to the same process. > > I think for rotary devices CFQ is by far the best choice. A simple > illustration is: > > Copying two files (750MB in this case) in parallel on a rotary > device. The elapsed wall clock time (seconds) for this is >meanstdev >cfq, slice_idle=8 16.18 4.95 >cfq, slice_idle=0 23.74 2.82 >blk-mq, time_slice_usec=0 24.37 2.05 >blk-mq, time_slice_usec=250 25.58 3.16 This illustrates that although their was performance gain with fio tests, the patch can cause higher variance and lower performance in comparison to unmodified blk-mq with other tests. And it underscores superiority of CFQ for rotary disks. Meanwhile my opinion is that it's not really worth to look further into introduction of I/O scheduling support in blk-mq. I don't see the need for scheduling support (deadline or something else) for fast storage devices. And rotary devices should really avoid usage of blk-mq and stick to CFQ. Thus I think that introducing some coexistence of blk-mq and the legacy block with CFQ is the best option. Recently Johannes sent a patch to enable scsi-mq per driver, see http://marc.info/?l=linux-scsi&m=145347009631192&w=2 Probably that is a good solution (at least in the short term) to allow users to switch to blk-mq for some host adapters (with fast storage attached) but to stick to legacy stuff on other host adapters with rotary devices. What do others think? Thanks, Andreas > Regards, > > Andreas > > diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c > index 1cf1878..77c875c 100644 > --- a/block/blk-mq-sysfs.c > +++ b/block/blk-mq-sysfs.c > @@ -247,6 +247,26 @@ static ssize_t blk_mq_hw_sysfs_cpus_show(struct > blk_mq_hw_ctx *hctx, char *page) > return ret; > } > > +static ssize_t blk_mq_hw_sysfs_tslice_show(struct blk_mq_hw_ctx *hctx, > + char *page) > +{ > + return sprintf(page, "%u\n", hctx->tslice_us); > +} > + > +static ssize_t blk_mq_hw_sysfs_tslice_store(struct blk_mq_hw_ctx *hctx, > + const char *page, size_t length) > +{ > + unsigned long long store; > + int err; > + > + err = kstrtoull(page, 10, &store); > + if (err) > + return -EINVAL; > + > + hctx->tslice_us = (unsigned)store; > + return length; > +} > + > static struct blk_mq_ctx_sysfs_entry blk_mq_sysfs_dispatched = { > .attr = {.name = "dispatched", .mode = S_IRUGO }, > .show = blk_mq_sysfs_dispatched_show, > @@ -305,6 +325,12 @@ static struct blk_mq_hw_ctx_sysfs_entry > blk_mq_hw_sysfs_poll = { > .show = blk_mq_hw_sysfs_poll_show, > }; > > +static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_tslice = { > + .attr = {.name = "time_slice_us", .mode = S_IRUGO | S_IWUSR }, > + .show = blk_mq_hw_sysfs_tslice_show, > + .store = blk_mq_hw_sysfs_tslice_store, > +}; > + > static struct attribute *default_hw_ctx_attrs[] = { > &blk_mq_hw_sysfs_queued.attr, > &blk_mq_hw_sysfs_run.attr, > @@ -314,6 +340,7 @@ static struct attribute *default_hw_ctx_attrs[] = { > &blk_mq_hw_sysfs_cpus.attr, > &blk_mq_hw_sysfs_active.attr, > &blk_mq_hw_sysfs_poll.attr, > + &blk_mq_hw_sysfs_tslice.attr, > NULL, > }; > > diff --git a/block/blk-mq.c b/block/blk-mq.c > index 4c0622f..97d32