Commit e21b7a0b authored by Arianna Avanzini's avatar Arianna Avanzini Committed by Jens Axboe

block, bfq: add full hierarchical scheduling and cgroups support

Add complete support for full hierarchical scheduling, with a cgroups
interface. Full hierarchical scheduling is implemented through the
'entity' abstraction: both bfq_queues, i.e., the internal BFQ queues
associated with processes, and groups are represented in general by
entities. Given the bfq_queues associated with the processes belonging
to a given group, the entities representing these queues are sons of
the entity representing the group. At higher levels, if a group, say
G, contains other groups, then the entity representing G is the parent
entity of the entities representing the groups in G.

Hierarchical scheduling is performed as follows: if the timestamps of
a leaf entity (i.e., of a bfq_queue) change, and such a change lets
the entity become the next-to-serve entity for its parent entity, then
the timestamps of the parent entity are recomputed as a function of
the budget of its new next-to-serve leaf entity. If the parent entity
belongs, in its turn, to a group, and its new timestamps let it become
the next-to-serve for its parent entity, then the timestamps of the
latter parent entity are recomputed as well, and so on. When a new
bfq_queue must be set in service, the reverse path is followed: the
next-to-serve highest-level entity is chosen, then its next-to-serve
child entity, and so on, until the next-to-serve leaf entity is
reached, and the bfq_queue that this entity represents is set in
service.

Writeback is accounted for on a per-group basis, i.e., for each group,
the async I/O requests of the processes of the group are enqueued in a
distinct bfq_queue, and the entity associated with this queue is a
child of the entity associated with the group.

Weights can be assigned explicitly to groups and processes through the
cgroups interface, differently from what happens, for single
processes, if the cgroups interface is not used (as explained in the
description of the previous patch). In particular, since each node has
a full scheduler, each group can be assigned its own weight.
Signed-off-by: default avatarFabio Checconi <fchecconi@gmail.com>
Signed-off-by: default avatarPaolo Valente <paolo.valente@linaro.org>
Signed-off-by: default avatarArianna Avanzini <avanzini.arianna@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent aee69d78
...@@ -253,9 +253,14 @@ of slice_idle are copied from CFQ too. ...@@ -253,9 +253,14 @@ of slice_idle are copied from CFQ too.
per-process ioprio and weight per-process ioprio and weight
----------------------------- -----------------------------
Unless the cgroups interface is used, weights can be assigned to Unless the cgroups interface is used (see "4. BFQ group scheduling"),
processes only indirectly, through I/O priorities, and according to weights can be assigned to processes only indirectly, through I/O
the relation: weight = (IOPRIO_BE_NR - ioprio) * 10. priorities, and according to the relation:
weight = (IOPRIO_BE_NR - ioprio) * 10.
Beware that, if low-latency is set, then BFQ automatically raises the
weight of the queues associated with interactive and soft real-time
applications. Unset this tunable if you need/want to control weights.
slice_idle slice_idle
---------- ----------
...@@ -450,9 +455,9 @@ may be reactivated for an already busy async queue (in ms). ...@@ -450,9 +455,9 @@ may be reactivated for an already busy async queue (in ms).
4. Group scheduling with BFQ 4. Group scheduling with BFQ
============================ ============================
BFQ supports both cgroup-v1 and cgroup-v2 io controllers, namely blkio BFQ supports both cgroups-v1 and cgroups-v2 io controllers, namely
and io. In particular, BFQ supports weight-based proportional blkio and io. In particular, BFQ supports weight-based proportional
share. share. To activate cgroups support, set BFQ_GROUP_IOSCHED.
4-1 Service guarantees provided 4-1 Service guarantees provided
------------------------------- -------------------------------
......
...@@ -40,6 +40,7 @@ config CFQ_GROUP_IOSCHED ...@@ -40,6 +40,7 @@ config CFQ_GROUP_IOSCHED
Enable group IO scheduling in CFQ. Enable group IO scheduling in CFQ.
choice choice
prompt "Default I/O scheduler" prompt "Default I/O scheduler"
default DEFAULT_CFQ default DEFAULT_CFQ
help help
...@@ -89,6 +90,15 @@ config IOSCHED_BFQ ...@@ -89,6 +90,15 @@ config IOSCHED_BFQ
real-time applications. Details in real-time applications. Details in
Documentation/block/bfq-iosched.txt Documentation/block/bfq-iosched.txt
config BFQ_GROUP_IOSCHED
bool "BFQ hierarchical scheduling support"
depends on IOSCHED_BFQ && BLK_CGROUP
default n
---help---
Enable hierarchical scheduling in BFQ, using the blkio
(cgroups-v1) or io (cgroups-v2) controller.
endmenu endmenu
endif endif
This diff is collapsed.
...@@ -50,7 +50,7 @@ struct blk_stat_callback; ...@@ -50,7 +50,7 @@ struct blk_stat_callback;
* Maximum number of blkcg policies allowed to be registered concurrently. * Maximum number of blkcg policies allowed to be registered concurrently.
* Defined here to simplify include dependency. * Defined here to simplify include dependency.
*/ */
#define BLKCG_MAX_POLS 2 #define BLKCG_MAX_POLS 3
typedef void (rq_end_io_fn)(struct request *, int); typedef void (rq_end_io_fn)(struct request *, int);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment