All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] distinguish foreground and background IOs in block throttle
@ 2017-12-25  2:44 xuejiufei
  2017-12-27 12:36 ` Paolo Valente
  0 siblings, 1 reply; 6+ messages in thread
From: xuejiufei @ 2017-12-25  2:44 UTC (permalink / raw)
  To: Tejun Heo, Jens Axboe, Shaohua Li; +Cc: linux-block, cgroups

Hi all,

Cgroup writeback is supported since v4.2. I found there exists a
problem in the following case.

A cgroup may send both buffer and direct/sync IOs. The foreground
thread will be stalled when periodic writeback IOs is flushed because
the service queue already has a plenty of writeback IOs, then
foreground IOs should be enqueued with its FIFO policy.

I wonder if we can distinguish foreground and background IOs in block
throttle to fix the above problem.

Any suggestion are always appreciated.


Thanks,
Jiufei

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC] distinguish foreground and background IOs in block throttle
  2017-12-25  2:44 [RFC] distinguish foreground and background IOs in block throttle xuejiufei
@ 2017-12-27 12:36 ` Paolo Valente
       [not found]   ` <A491ADB3-5487-4161-A526-E0C3AF416437-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Valente @ 2017-12-27 12:36 UTC (permalink / raw)
  To: xuejiufei
  Cc: Tejun Heo, Jens Axboe, Shaohua Li, linux-block, cgroups,
	Mark Brown, Ulf Hansson, Linus Walleij

[-- Attachment #1: Type: text/plain, Size: 1319 bytes --]



> Il giorno 25 dic 2017, alle ore 03:44, xuejiufei <xuejiufei@gmail.com> ha scritto:
> 
> Hi all,
> 
> Cgroup writeback is supported since v4.2. I found there exists a
> problem in the following case.
> 
> A cgroup may send both buffer and direct/sync IOs. The foreground
> thread will be stalled when periodic writeback IOs is flushed because
> the service queue already has a plenty of writeback IOs, then
> foreground IOs should be enqueued with its FIFO policy.
> 
> I wonder if we can distinguish foreground and background IOs in block
> throttle to fix the above problem.
> 
> Any suggestion are always appreciated.
> 

Hi,
to address similar issues, I have just sent a patch [1] for the BFQ
I/O scheduler.  If you want to give it a try, it might solve, or at
least mitigate, your problem (the patch does not involve groups,
though, at least for the moment).

There are still pending patches related to the low_latency mode of
BFQ, so I suggest you to try with low_latency disabled, i.e., as root:
echo bfq > /sys/block/<your-device>/queue/scheduler
echo 0 > /sys/block/<your-device>/queue/iosched/low_latency 

For your possible convenience, I have attached the patch, gzipped, to
this email too.

Thanks,
Paolo

[1] https://www.spinics.net/lists/kernel/msg2684463.html


[-- Attachment #2: 0001-block-bfq-limit-tags-for-writes-and-async-I-O.patch.gz --]
[-- Type: application/x-gzip, Size: 2413 bytes --]

[-- Attachment #3: Type: text/plain, Size: 25 bytes --]



> 
> Thanks,
> Jiufei


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC] distinguish foreground and background IOs in block throttle
  2017-12-27 12:36 ` Paolo Valente
@ 2017-12-28  1:51       ` Joseph Qi
  0 siblings, 0 replies; 6+ messages in thread
From: Joseph Qi @ 2017-12-28  1:51 UTC (permalink / raw)
  To: Paolo Valente, xuejiufei
  Cc: Tejun Heo, Jens Axboe, Shaohua Li, linux-block,
	cgroups-u79uwXL29TY76Z2rM5mHXA, Mark Brown, Ulf Hansson,
	Linus Walleij

Hi Paolo,

On 17/12/27 20:36, Paolo Valente wrote:
> 
> 
>> Il giorno 25 dic 2017, alle ore 03:44, xuejiufei <xuejiufei-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> ha scritto:
>>
>> Hi all,
>>
>> Cgroup writeback is supported since v4.2. I found there exists a
>> problem in the following case.
>>
>> A cgroup may send both buffer and direct/sync IOs. The foreground
>> thread will be stalled when periodic writeback IOs is flushed because
>> the service queue already has a plenty of writeback IOs, then
>> foreground IOs should be enqueued with its FIFO policy.
>>
>> I wonder if we can distinguish foreground and background IOs in block
>> throttle to fix the above problem.
>>
>> Any suggestion are always appreciated.
>>
> 
> Hi,
> to address similar issues, I have just sent a patch [1] for the BFQ
> I/O scheduler.  If you want to give it a try, it might solve, or at
> least mitigate, your problem (the patch does not involve groups,
> though, at least for the moment).
> 
> There are still pending patches related to the low_latency mode of
> BFQ, so I suggest you to try with low_latency disabled, i.e., as root:
> echo bfq > /sys/block/<your-device>/queue/scheduler
> echo 0 > /sys/block/<your-device>/queue/iosched/low_latency 
> 
> For your possible convenience, I have attached the patch, gzipped, to
> this email too.
> > Thanks,
> Paolo
> 
> [1] https://www.spinics.net/lists/kernel/msg2684463.html
> 
I don't get why the issue Jiufei described has relations with scheduler.

IMO, the core reason is current we only have read/write queues in block
throttle. That means all sync/async writes will go into the same queue.
Once writeback IOs flush out and throttle happens, sync write will also
have to be queued up. Since there are more async writes ahead of sync
writes in the queue, and the current policy is dispatching 6 reads and 2
writes during each round, sync writes will get significantly delay,
which we don't expect.

So like read/write queue design, we may add another queue in block
throttle to distinguish sync/async writes, and then we can dispatch more
sync writes than async writes.

Thanks,
Joseph

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC] distinguish foreground and background IOs in block throttle
@ 2017-12-28  1:51       ` Joseph Qi
  0 siblings, 0 replies; 6+ messages in thread
From: Joseph Qi @ 2017-12-28  1:51 UTC (permalink / raw)
  To: Paolo Valente, xuejiufei
  Cc: Tejun Heo, Jens Axboe, Shaohua Li, linux-block, cgroups,
	Mark Brown, Ulf Hansson, Linus Walleij

Hi Paolo,

On 17/12/27 20:36, Paolo Valente wrote:
> 
> 
>> Il giorno 25 dic 2017, alle ore 03:44, xuejiufei <xuejiufei@gmail.com> ha scritto:
>>
>> Hi all,
>>
>> Cgroup writeback is supported since v4.2. I found there exists a
>> problem in the following case.
>>
>> A cgroup may send both buffer and direct/sync IOs. The foreground
>> thread will be stalled when periodic writeback IOs is flushed because
>> the service queue already has a plenty of writeback IOs, then
>> foreground IOs should be enqueued with its FIFO policy.
>>
>> I wonder if we can distinguish foreground and background IOs in block
>> throttle to fix the above problem.
>>
>> Any suggestion are always appreciated.
>>
> 
> Hi,
> to address similar issues, I have just sent a patch [1] for the BFQ
> I/O scheduler.  If you want to give it a try, it might solve, or at
> least mitigate, your problem (the patch does not involve groups,
> though, at least for the moment).
> 
> There are still pending patches related to the low_latency mode of
> BFQ, so I suggest you to try with low_latency disabled, i.e., as root:
> echo bfq > /sys/block/<your-device>/queue/scheduler
> echo 0 > /sys/block/<your-device>/queue/iosched/low_latency 
> 
> For your possible convenience, I have attached the patch, gzipped, to
> this email too.
> > Thanks,
> Paolo
> 
> [1] https://www.spinics.net/lists/kernel/msg2684463.html
> 
I don't get why the issue Jiufei described has relations with scheduler.

IMO, the core reason is current we only have read/write queues in block
throttle. That means all sync/async writes will go into the same queue.
Once writeback IOs flush out and throttle happens, sync write will also
have to be queued up. Since there are more async writes ahead of sync
writes in the queue, and the current policy is dispatching 6 reads and 2
writes during each round, sync writes will get significantly delay,
which we don't expect.

So like read/write queue design, we may add another queue in block
throttle to distinguish sync/async writes, and then we can dispatch more
sync writes than async writes.

Thanks,
Joseph

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC] distinguish foreground and background IOs in block throttle
  2017-12-28  1:51       ` Joseph Qi
@ 2017-12-28  8:48         ` Paolo Valente
  -1 siblings, 0 replies; 6+ messages in thread
From: Paolo Valente @ 2017-12-28  8:48 UTC (permalink / raw)
  To: Joseph Qi
  Cc: xuejiufei, Tejun Heo, Jens Axboe, Shaohua Li, linux-block,
	cgroups, Mark Brown, Ulf Hansson, Linus Walleij



> Il giorno 28 dic 2017, alle ore 02:51, Joseph Qi <jiangqi903@gmail.com> ha scritto:
> 
> Hi Paolo,
> 
> On 17/12/27 20:36, Paolo Valente wrote:
>> 
>> 
>>> Il giorno 25 dic 2017, alle ore 03:44, xuejiufei <xuejiufei@gmail.com> ha scritto:
>>> 
>>> Hi all,
>>> 
>>> Cgroup writeback is supported since v4.2. I found there exists a
>>> problem in the following case.
>>> 
>>> A cgroup may send both buffer and direct/sync IOs. The foreground
>>> thread will be stalled when periodic writeback IOs is flushed because
>>> the service queue already has a plenty of writeback IOs, then
>>> foreground IOs should be enqueued with its FIFO policy.
>>> 
>>> I wonder if we can distinguish foreground and background IOs in block
>>> throttle to fix the above problem.
>>> 
>>> Any suggestion are always appreciated.
>>> 
>> 
>> Hi,
>> to address similar issues, I have just sent a patch [1] for the BFQ
>> I/O scheduler.  If you want to give it a try, it might solve, or at
>> least mitigate, your problem (the patch does not involve groups,
>> though, at least for the moment).
>> 
>> There are still pending patches related to the low_latency mode of
>> BFQ, so I suggest you to try with low_latency disabled, i.e., as root:
>> echo bfq > /sys/block/<your-device>/queue/scheduler
>> echo 0 > /sys/block/<your-device>/queue/iosched/low_latency 
>> 
>> For your possible convenience, I have attached the patch, gzipped, to
>> this email too.
>>> Thanks,
>> Paolo
>> 
>> [1] https://www.spinics.net/lists/kernel/msg2684463.html
>> 
> I don't get why the issue Jiufei described has relations with scheduler.
> 
> IMO, the core reason is current we only have read/write queues in block
> throttle. That means all sync/async writes will go into the same queue.
> Once writeback IOs flush out and throttle happens, sync write will also
> have to be queued up. Since there are more async writes ahead of sync
> writes in the queue, and the current policy is dispatching 6 reads and 2
> writes during each round, sync writes will get significantly delay,
> which we don't expect.
> 
> So like read/write queue design, we may add another queue in block
> throttle to distinguish sync/async writes, and then we can dispatch more
> sync writes than async writes.
> 

Hi Joseph,
your description of the problem would be complete *if* sync write
requests were issued as expected.  But the problem I have seen, and
tried to solve with my patch, is that async requests easily eat all
request tags (I'm referring to blk-mq of course).  So sync I/O has a
hard time finding free tags for its requests, and is then throttled
upstream.  Differentiating throttling downstream may not solve this
problem, because async requests will accumulate upstream as before.
The problem may even get worse, because downstream throttling may
increase the duration of upstream congestion.

My patch tries to solve this upstream problem.  BFQ then does the
rest, downstream, for me.  Things may change in your scenario, though:
you may not have this upstream problem at all, or you may have both
the upstream and the downstream problems.

Thanks,
Paolo

> Thanks,
> Joseph


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC] distinguish foreground and background IOs in block throttle
@ 2017-12-28  8:48         ` Paolo Valente
  0 siblings, 0 replies; 6+ messages in thread
From: Paolo Valente @ 2017-12-28  8:48 UTC (permalink / raw)
  To: Joseph Qi
  Cc: xuejiufei, Tejun Heo, Jens Axboe, Shaohua Li, linux-block,
	cgroups, Mark Brown, Ulf Hansson, Linus Walleij



> Il giorno 28 dic 2017, alle ore 02:51, Joseph Qi =
<jiangqi903@gmail.com> ha scritto:
>=20
> Hi Paolo,
>=20
> On 17/12/27 20:36, Paolo Valente wrote:
>>=20
>>=20
>>> Il giorno 25 dic 2017, alle ore 03:44, xuejiufei =
<xuejiufei@gmail.com> ha scritto:
>>>=20
>>> Hi all,
>>>=20
>>> Cgroup writeback is supported since v4.2. I found there exists a
>>> problem in the following case.
>>>=20
>>> A cgroup may send both buffer and direct/sync IOs. The foreground
>>> thread will be stalled when periodic writeback IOs is flushed =
because
>>> the service queue already has a plenty of writeback IOs, then
>>> foreground IOs should be enqueued with its FIFO policy.
>>>=20
>>> I wonder if we can distinguish foreground and background IOs in =
block
>>> throttle to fix the above problem.
>>>=20
>>> Any suggestion are always appreciated.
>>>=20
>>=20
>> Hi,
>> to address similar issues, I have just sent a patch [1] for the BFQ
>> I/O scheduler.  If you want to give it a try, it might solve, or at
>> least mitigate, your problem (the patch does not involve groups,
>> though, at least for the moment).
>>=20
>> There are still pending patches related to the low_latency mode of
>> BFQ, so I suggest you to try with low_latency disabled, i.e., as =
root:
>> echo bfq > /sys/block/<your-device>/queue/scheduler
>> echo 0 > /sys/block/<your-device>/queue/iosched/low_latency=20
>>=20
>> For your possible convenience, I have attached the patch, gzipped, to
>> this email too.
>>> Thanks,
>> Paolo
>>=20
>> [1] https://www.spinics.net/lists/kernel/msg2684463.html
>>=20
> I don't get why the issue Jiufei described has relations with =
scheduler.
>=20
> IMO, the core reason is current we only have read/write queues in =
block
> throttle. That means all sync/async writes will go into the same =
queue.
> Once writeback IOs flush out and throttle happens, sync write will =
also
> have to be queued up. Since there are more async writes ahead of sync
> writes in the queue, and the current policy is dispatching 6 reads and =
2
> writes during each round, sync writes will get significantly delay,
> which we don't expect.
>=20
> So like read/write queue design, we may add another queue in block
> throttle to distinguish sync/async writes, and then we can dispatch =
more
> sync writes than async writes.
>=20

Hi Joseph,
your description of the problem would be complete *if* sync write
requests were issued as expected.  But the problem I have seen, and
tried to solve with my patch, is that async requests easily eat all
request tags (I'm referring to blk-mq of course).  So sync I/O has a
hard time finding free tags for its requests, and is then throttled
upstream.  Differentiating throttling downstream may not solve this
problem, because async requests will accumulate upstream as before.
The problem may even get worse, because downstream throttling may
increase the duration of upstream congestion.

My patch tries to solve this upstream problem.  BFQ then does the
rest, downstream, for me.  Things may change in your scenario, though:
you may not have this upstream problem at all, or you may have both
the upstream and the downstream problems.

Thanks,
Paolo

> Thanks,
> Joseph

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-12-28  8:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-25  2:44 [RFC] distinguish foreground and background IOs in block throttle xuejiufei
2017-12-27 12:36 ` Paolo Valente
     [not found]   ` <A491ADB3-5487-4161-A526-E0C3AF416437-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-12-28  1:51     ` Joseph Qi
2017-12-28  1:51       ` Joseph Qi
2017-12-28  8:48       ` Paolo Valente
2017-12-28  8:48         ` Paolo Valente

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.