summaryrefslogtreecommitdiffstats
path: root/block/bfq-iosched.c
diff options
context:
space:
mode:
authorAngelo Ruocco <angeloruocco90@gmail.com>2017-12-20 06:38:34 -0500
committerJens Axboe <axboe@kernel.dk>2018-01-05 11:26:11 -0500
commit4403e4e467c365b4189e3e3d3ad35cf67b8c36ed (patch)
tree6bc388cb660f4673aacbbcc705030c589c4748e5 /block/bfq-iosched.c
parent7b8fa3b900a087bc03b11329a92398fde563ba37 (diff)
block, bfq: remove superfluous check in queue-merging setup
When two or more processes do I/O in a way that the their requests are sequential in respect to one another, BFQ merges the bfq_queues associated with the processes. This way the overall I/O pattern becomes sequential, and thus there is a boost in througput. These cooperating processes usually start or restart to do I/O shortly after each other. So, in order to avoid merging non-cooperating processes, BFQ ensures that none of these queues has been in weight raising for too long. In this respect, from commit "block, bfq-sq, bfq-mq: let a queue be merged only shortly after being created", BFQ checks whether any queue (and not only weight-raised ones) is doing I/O continuously from too long to be merged. This new additional check makes the first one useless: a queue doing I/O from long enough, if being weight-raised, is also a queue in weight raising for too long to be merged. Accordingly, this commit removes the first check. Signed-off-by: Angelo Ruocco <angeloruocco90@gmail.com> Signed-off-by: Paolo Valente <paolo.valente@linaro.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/bfq-iosched.c')
-rw-r--r--block/bfq-iosched.c36
1 files changed, 5 insertions, 31 deletions
diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index 7066d90f09df..9625550b2f85 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -1991,20 +1991,6 @@ static bool bfq_may_be_close_cooperator(struct bfq_queue *bfqq,
1991} 1991}
1992 1992
1993/* 1993/*
1994 * If this function returns true, then bfqq cannot be merged. The idea
1995 * is that true cooperation happens very early after processes start
1996 * to do I/O. Usually, late cooperations are just accidental false
1997 * positives. In case bfqq is weight-raised, such false positives
1998 * would evidently degrade latency guarantees for bfqq.
1999 */
2000static bool wr_from_too_long(struct bfq_queue *bfqq)
2001{
2002 return bfqq->wr_coeff > 1 &&
2003 time_is_before_jiffies(bfqq->last_wr_start_finish +
2004 msecs_to_jiffies(100));
2005}
2006
2007/*
2008 * Attempt to schedule a merge of bfqq with the currently in-service 1994 * Attempt to schedule a merge of bfqq with the currently in-service
2009 * queue or with a close queue among the scheduled queues. Return 1995 * queue or with a close queue among the scheduled queues. Return
2010 * NULL if no merge was scheduled, a pointer to the shared bfq_queue 1996 * NULL if no merge was scheduled, a pointer to the shared bfq_queue
@@ -2017,11 +2003,6 @@ static bool wr_from_too_long(struct bfq_queue *bfqq)
2017 * to maintain. Besides, in such a critical condition as an out of memory, 2003 * to maintain. Besides, in such a critical condition as an out of memory,
2018 * the benefits of queue merging may be little relevant, or even negligible. 2004 * the benefits of queue merging may be little relevant, or even negligible.
2019 * 2005 *
2020 * Weight-raised queues can be merged only if their weight-raising
2021 * period has just started. In fact cooperating processes are usually
2022 * started together. Thus, with this filter we avoid false positives
2023 * that would jeopardize low-latency guarantees.
2024 *
2025 * WARNING: queue merging may impair fairness among non-weight raised 2006 * WARNING: queue merging may impair fairness among non-weight raised
2026 * queues, for at least two reasons: 1) the original weight of a 2007 * queues, for at least two reasons: 1) the original weight of a
2027 * merged queue may change during the merged state, 2) even being the 2008 * merged queue may change during the merged state, 2) even being the
@@ -2052,9 +2033,7 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq,
2052 if (bfqq->new_bfqq) 2033 if (bfqq->new_bfqq)
2053 return bfqq->new_bfqq; 2034 return bfqq->new_bfqq;
2054 2035
2055 if (!io_struct || 2036 if (!io_struct || unlikely(bfqq == &bfqd->oom_bfqq))
2056 wr_from_too_long(bfqq) ||
2057 unlikely(bfqq == &bfqd->oom_bfqq))
2058 return NULL; 2037 return NULL;
2059 2038
2060 /* If there is only one backlogged queue, don't search. */ 2039 /* If there is only one backlogged queue, don't search. */
@@ -2063,12 +2042,9 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq,
2063 2042
2064 in_service_bfqq = bfqd->in_service_queue; 2043 in_service_bfqq = bfqd->in_service_queue;
2065 2044
2066 if (!in_service_bfqq || in_service_bfqq == bfqq 2045 if (in_service_bfqq && in_service_bfqq != bfqq &&
2067 || wr_from_too_long(in_service_bfqq) || 2046 likely(in_service_bfqq != &bfqd->oom_bfqq) &&
2068 unlikely(in_service_bfqq == &bfqd->oom_bfqq)) 2047 bfq_rq_close_to_sector(io_struct, request, bfqd->last_position) &&
2069 goto check_scheduled;
2070
2071 if (bfq_rq_close_to_sector(io_struct, request, bfqd->last_position) &&
2072 bfqq->entity.parent == in_service_bfqq->entity.parent && 2048 bfqq->entity.parent == in_service_bfqq->entity.parent &&
2073 bfq_may_be_close_cooperator(bfqq, in_service_bfqq)) { 2049 bfq_may_be_close_cooperator(bfqq, in_service_bfqq)) {
2074 new_bfqq = bfq_setup_merge(bfqq, in_service_bfqq); 2050 new_bfqq = bfq_setup_merge(bfqq, in_service_bfqq);
@@ -2080,12 +2056,10 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq,
2080 * queues. The only thing we need is that the bio/request is not 2056 * queues. The only thing we need is that the bio/request is not
2081 * NULL, as we need it to establish whether a cooperator exists. 2057 * NULL, as we need it to establish whether a cooperator exists.
2082 */ 2058 */
2083check_scheduled:
2084 new_bfqq = bfq_find_close_cooperator(bfqd, bfqq, 2059 new_bfqq = bfq_find_close_cooperator(bfqd, bfqq,
2085 bfq_io_struct_pos(io_struct, request)); 2060 bfq_io_struct_pos(io_struct, request));
2086 2061
2087 if (new_bfqq && !wr_from_too_long(new_bfqq) && 2062 if (new_bfqq && likely(new_bfqq != &bfqd->oom_bfqq) &&
2088 likely(new_bfqq != &bfqd->oom_bfqq) &&
2089 bfq_may_be_close_cooperator(bfqq, new_bfqq)) 2063 bfq_may_be_close_cooperator(bfqq, new_bfqq))
2090 return bfq_setup_merge(bfqq, new_bfqq); 2064 return bfq_setup_merge(bfqq, new_bfqq);
2091 2065