From patchwork Mon Jun 25 19:48:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 139881 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4372768lji; Mon, 25 Jun 2018 12:49:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIPDLkupI2PKuGFMq2GR+u1EprLGdK1x9/GqSltpx7al5Sz8yo5CA3dV+qi4n5J20wYds5w X-Received: by 2002:a63:6944:: with SMTP id e65-v6mr11741996pgc.436.1529956140220; Mon, 25 Jun 2018 12:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529956140; cv=none; d=google.com; s=arc-20160816; b=KzgHOR0M7uYzcHTIgGbqkm9GGSYo331xz44siKavnWLN1F92da7EWBJTEvQBrstuRB uld5jR0KRjMQeLYD1uz+rWjw6Fh5fKY69T+CoaiuJew/ihk3jF6R07khCBeMXSMawbmC jUqxOY+JXOFmw03ncvt0JOLXowx2Q83cVrK6W6G6aTHSVipNMqR36BP/fl1jCB47YUuz c6YzpCHE4J/OkRljjJkr4J4pO/eVFEoovElPvSi7fgNFRrQnJrLQi2Mk3voJWG1HgLqw X18Hsijdgtr/JuA1xKxtH/3WzAAnSI5ixUcna2DZkdKzQPuwDQ6BppDSOSp0bDY8eIaT fZVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=iLVhnU7LLoCaW4lOc7bzsWA0oIfhsKCR8yo/rG/4vtQ=; b=pW+3MYjcHaSOHnQHaYJ3/DO4AqSdKIL4xhV4sYPPoHXKD4D4du4VsBPBc5w4yDz4n7 bNhxm40XVChx95lVqq8fUgbJooA4J+hcaoxr3xwDhfyRHiPK+jgeyCy4HRCZgFpdcS/f IfrLBaCvAw6lxY/MKetgjXvSUHYGNDdVQ4IkxtOydmEK2Qgno8B6IQmBOWsPvjYGMAsq WeXHkeBgkW8M8cvPxbvudyndeEbEqpCt4rug9DRbFmSNd2/4YtQgLKtgnObCb8/3tZBm SdG4djoUNq6cEs6sk2Bmp/5UjElyI0uwswidmfVUHogEZqleRaseAw6QbNuPo4ZWKtH+ 2Lmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jRzh8Rl3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5-v6si11683865pgr.436.2018.06.25.12.48.59; Mon, 25 Jun 2018 12:49:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jRzh8Rl3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935140AbeFYTs5 (ORCPT + 31 others); Mon, 25 Jun 2018 15:48:57 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:38347 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755652AbeFYTsW (ORCPT ); Mon, 25 Jun 2018 15:48:22 -0400 Received: by mail-ed1-f66.google.com with SMTP id a5-v6so6154027edt.5 for ; Mon, 25 Jun 2018 12:48:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iLVhnU7LLoCaW4lOc7bzsWA0oIfhsKCR8yo/rG/4vtQ=; b=jRzh8Rl354+2+iZbrVEHzLsd1duus/ZS5O6jIQ+p1pxzC9wHX+zuj+94kLUJpY1yrm QKHL7b+HP248NHwrZNO8xoyz5VJ2BIkET+81pbCDsdIfbRxaW5TGOKXQwu+wtfMNKs+A mtOrBdtKl78Omr5rkKAedrxrDDwx7qzzXGFI8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iLVhnU7LLoCaW4lOc7bzsWA0oIfhsKCR8yo/rG/4vtQ=; b=iHeJ46PR5dhEHGeXjgEBt5DC73QwYgEGNLaeuL1tM8CIapA/ppn8WhvGTh4zIMGAdJ AK9hBzhOKnntyJuEHO1m/M6OWKFcHPhXdPCFzyF02pvAaCMLNSO6Hf/I1zXgErDbG3P/ HXY+rhlI9e798gyKu6L+iOaPwXAOnlXNt27Ayg6JN5gT/o7nqPDtMZjeXVMhH1mi4aWn /kRuTl+HBcWzW43Q2NnWsP579KjfQ0QFvznEXvOq1vZXUuyapYwxM2d5dhfl/AxoLFIY RaXlW820mDCJI2JJ47Wc/mKelhehAa8i+mhnfZa1vhAHknWnibBsuMF3+Qsv7wAYKgPP bpSA== X-Gm-Message-State: APt69E0qk6XcdJbSXNnQX6w3yPKLTeILR5jAWkaV0jng70WDlD667oG/ NxMOBwk4mFmXjeqfLZ5OEw/TKw== X-Received: by 2002:a50:a985:: with SMTP id n5-v6mr12610487edc.263.1529956101299; Mon, 25 Jun 2018 12:48:21 -0700 (PDT) Received: from localhost.localdomain (146-241-36-97.dyn.eolo.it. [146.241.36.97]) by smtp.gmail.com with ESMTPSA id d11-v6sm17553edh.61.2018.06.25.12.48.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 12:48:20 -0700 (PDT) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, broonie@kernel.org, linus.walleij@linaro.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, Paolo Valente Subject: [PATCH BUGFIX 1/4] block, bfq: add/remove entity weights correctly Date: Mon, 25 Jun 2018 21:48:03 +0200 Message-Id: <20180625194806.7619-2-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180625194806.7619-1-paolo.valente@linaro.org> References: <20180625194806.7619-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To keep I/O throughput high as often as possible, BFQ performs I/O-dispatch plugging (aka device idling) only when beneficial exactly for throughput, or when needed for service guarantees (low latency, fairness). An important case where the latter condition holds is when the scenario is 'asymmetric' in terms of weights: i.e., when some bfq_queue or whole group of queues has a higher weight, and thus has to receive more service, than other queues or groups. Without dispatch plugging, lower-weight queues/groups may unjustly steal bandwidth to higher-weight queues/groups. To detect asymmetric scenarios, BFQ checks some sufficient conditions. One of these conditions is that active groups have different weights. BFQ controls this condition by maintaining a special set of unique weights of active groups (group_weights_tree). To this purpose, in the function bfq_active_insert/bfq_active_extract BFQ adds/removes the weight of a group to/from this set. Unfortunately, the function bfq_active_extract may happen to be invoked also for a group that is still active (to preserve the correct update of the next queue to serve, see comments in function bfq_no_longer_next_in_service() for details). In this case, removing the weight of the group makes the set group_weights_tree inconsistent. Service-guarantee violations follow. This commit addresses this issue by moving group_weights_tree insertions from their previous location (in bfq_active_insert) into the function __bfq_activate_entity, and by moving group_weights_tree extractions from bfq_active_extract to when the entity that represents a group remains throughly idle, i.e., with no request either enqueued or dispatched. Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 45 +++++++++++++++++++++++++++++++++++++++++---- block/bfq-iosched.h | 7 +++++-- block/bfq-wf2q.c | 24 +++++++++++++----------- 3 files changed, 59 insertions(+), 17 deletions(-) -- 2.16.1 diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 495b9ddb3355..3f32e88c7e9b 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -742,8 +742,9 @@ void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_entity *entity, * See the comments to the function bfq_weights_tree_add() for considerations * about overhead. */ -void bfq_weights_tree_remove(struct bfq_data *bfqd, struct bfq_entity *entity, - struct rb_root *root) +void __bfq_weights_tree_remove(struct bfq_data *bfqd, + struct bfq_entity *entity, + struct rb_root *root) { if (!entity->weight_counter) return; @@ -759,6 +760,43 @@ void bfq_weights_tree_remove(struct bfq_data *bfqd, struct bfq_entity *entity, entity->weight_counter = NULL; } +/* + * Invoke __bfq_weights_tree_remove on bfqq and all its inactive + * parent entities. + */ +void bfq_weights_tree_remove(struct bfq_data *bfqd, + struct bfq_queue *bfqq) +{ + struct bfq_entity *entity = bfqq->entity.parent; + + __bfq_weights_tree_remove(bfqd, &bfqq->entity, + &bfqd->queue_weights_tree); + + for_each_entity(entity) { + struct bfq_sched_data *sd = entity->my_sched_data; + + if (sd->next_in_service || sd->in_service_entity) { + /* + * entity is still active, because either + * next_in_service or in_service_entity is not + * NULL (see the comments on the definition of + * next_in_service for details on why + * in_service_entity must be checked too). + * + * As a consequence, the weight of entity is + * not to be removed. In addition, if entity + * is active, then its parent entities are + * active as well, and thus their weights are + * not to be removed either. In the end, this + * loop must stop here. + */ + break; + } + __bfq_weights_tree_remove(bfqd, entity, + &bfqd->group_weights_tree); + } +} + /* * Return expired entry, or NULL to just start from scratch in rbtree. */ @@ -4582,8 +4620,7 @@ static void bfq_completed_request(struct bfq_queue *bfqq, struct bfq_data *bfqd) */ bfqq->budget_timeout = jiffies; - bfq_weights_tree_remove(bfqd, &bfqq->entity, - &bfqd->queue_weights_tree); + bfq_weights_tree_remove(bfqd, bfqq); } now_ns = ktime_get_ns(); diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index 0f712e03b035..a8a2e5aca4d4 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -827,8 +827,11 @@ struct bfq_data *bic_to_bfqd(struct bfq_io_cq *bic); void bfq_pos_tree_add_move(struct bfq_data *bfqd, struct bfq_queue *bfqq); void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_entity *entity, struct rb_root *root); -void bfq_weights_tree_remove(struct bfq_data *bfqd, struct bfq_entity *entity, - struct rb_root *root); +void __bfq_weights_tree_remove(struct bfq_data *bfqd, + struct bfq_entity *entity, + struct rb_root *root); +void bfq_weights_tree_remove(struct bfq_data *bfqd, + struct bfq_queue *bfqq); void bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq, bool compensate, enum bfqq_expiration reason); void bfq_put_queue(struct bfq_queue *bfqq); diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 4498c43245e2..58cf38fcee05 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -499,9 +499,6 @@ static void bfq_active_insert(struct bfq_service_tree *st, if (bfqq) list_add(&bfqq->bfqq_list, &bfqq->bfqd->active_list); #ifdef CONFIG_BFQ_GROUP_IOSCHED - else /* bfq_group */ - bfq_weights_tree_add(bfqd, entity, &bfqd->group_weights_tree); - if (bfqg != bfqd->root_group) bfqg->active_entities++; #endif @@ -601,10 +598,6 @@ static void bfq_active_extract(struct bfq_service_tree *st, if (bfqq) list_del(&bfqq->bfqq_list); #ifdef CONFIG_BFQ_GROUP_IOSCHED - else /* bfq_group */ - bfq_weights_tree_remove(bfqd, entity, - &bfqd->group_weights_tree); - if (bfqg != bfqd->root_group) bfqg->active_entities--; #endif @@ -799,7 +792,7 @@ __bfq_entity_update_weight_prio(struct bfq_service_tree *old_st, if (prev_weight != new_weight) { root = bfqq ? &bfqd->queue_weights_tree : &bfqd->group_weights_tree; - bfq_weights_tree_remove(bfqd, entity, root); + __bfq_weights_tree_remove(bfqd, entity, root); } entity->weight = new_weight; /* @@ -971,7 +964,7 @@ static void bfq_update_fin_time_enqueue(struct bfq_entity *entity, * one of its children receives a new request. * * Basically, this function updates the timestamps of entity and - * inserts entity into its active tree, ater possibly extracting it + * inserts entity into its active tree, after possibly extracting it * from its idle tree. */ static void __bfq_activate_entity(struct bfq_entity *entity, @@ -1015,6 +1008,16 @@ static void __bfq_activate_entity(struct bfq_entity *entity, entity->on_st = true; } +#ifdef BFQ_GROUP_IOSCHED_ENABLED + if (!bfq_entity_to_bfqq(entity)) { /* bfq_group */ + struct bfq_group *bfqg = + container_of(entity, struct bfq_group, entity); + + bfq_weights_tree_add(bfqg->bfqd, entity, + &bfqd->group_weights_tree); + } +#endif + bfq_update_fin_time_enqueue(entity, st, backshifted); } @@ -1664,8 +1667,7 @@ void bfq_del_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq, bfqd->busy_queues--; if (!bfqq->dispatched) - bfq_weights_tree_remove(bfqd, &bfqq->entity, - &bfqd->queue_weights_tree); + bfq_weights_tree_remove(bfqd, bfqq); if (bfqq->wr_coeff > 1) bfqd->wr_busy_queues--; From patchwork Mon Jun 25 19:48:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 139882 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4372918lji; Mon, 25 Jun 2018 12:49:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKICFZleQALFwhrarLRXO7Ho4jO+I9XP5Ea1hLDQ4P4l73Jc10HBPLAsx3MejDbCeB5NMetg X-Received: by 2002:a17:902:8341:: with SMTP id z1-v6mr13888494pln.40.1529956151121; Mon, 25 Jun 2018 12:49:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529956151; cv=none; d=google.com; s=arc-20160816; b=VhResBRd+KqyK1h5nvsxnYtvRbgjrJ6YzbFYza5LQ5KpLe+K23SBWtl3jy0nVdck0B WmDAtJqrWSTDEYTn/fZIfu5v0VD0BsGTDjDV87RbFpVdFR6bipjr9yeSmBgyy3ShOBlN hqEiR+FnbUyx0oMhKUEr+2gyWDaSrL0BgBtcSv/EG/zB492PQDAmpYcoqty0nm/rrmpp LB+sd64Qj1RoyxzWg0dv71EE3d+hzDlPEcBn7wbZJnKu+G80ybUf/i/ajjRF2IzP5Clw PziNs2TkGBBvvFPemJlI8c7MSd76jsqWOY7IGmizcowVB3PQyT6tZ55sgaWMFqT5TJyA 44Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=j7GMIIGaIORm8b6LjrnaeSpizBl5u4j6T5VX4NtEKP0=; b=B4e1ZvYRios1c7izfd2cc8GPsgNwqwPfO+Fb9R//ryrrbANmb+aSTwkCbiWqiqMcY3 uGojrRdQ0KGG+w6jPLQIEvPDRjLBwUhZRUZMSvc/IhKGPPy1mdvKH0itvhmGzPNLSGtJ gxP5ptMnkkmMUiNCj9NrFyCkzH7CpdAkNX7o+ECaKrnsgNZCn9hEjj3GYf7f5xXgHtws scot26sAHlJwyy9MjCWm3GjsdQXV/fxXfLeeDTkycIH309cM3FanRTQgfs+WhFRb36e+ l23ji9HbCb5sA4kOTdRQ7r4ECdyCWwl+I7i/ZSQnVyl0k13e3rACk869bCTt3qmRsuAS ky1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ISXAMyz9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10-v6si12819578pgr.72.2018.06.25.12.49.10; Mon, 25 Jun 2018 12:49:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ISXAMyz9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935119AbeFYTsz (ORCPT + 31 others); Mon, 25 Jun 2018 15:48:55 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:39550 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934970AbeFYTsZ (ORCPT ); Mon, 25 Jun 2018 15:48:25 -0400 Received: by mail-ed1-f67.google.com with SMTP id w14-v6so6142283eds.6 for ; Mon, 25 Jun 2018 12:48:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j7GMIIGaIORm8b6LjrnaeSpizBl5u4j6T5VX4NtEKP0=; b=ISXAMyz9HG6X03+UdeNNU20+QgDeyaDqi+YBQBdK8+sHi72oOUZ/a02YoFUn1nlpYb 1xHA+/a6/qy7i6I/Is/IVe6y+g5hDKXgIIwDrByr/Xag9f0qFxLY+QOYQXdwaRA/wk3R nlIiR6W7//92ZEu1fsbsPx7G3HyBEmbNhzduo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=j7GMIIGaIORm8b6LjrnaeSpizBl5u4j6T5VX4NtEKP0=; b=Qx0sVmAbwWG9PWU2v9Bhf8/G99qbZruE9wKi2I/ofgZAOo//3dGUeKCFd2vYem+YfK 4qIEAhsvoImp7o7W4NJ1G5V6j/GRtTigT6RGE1Ao0KFYGD1jHVdVHQtT45dNYq0FoSgS +liHVYQTFdzFVTCAilqbj6qiobmQHDgsvIA3HHASImLWBieFLSwF687wQ4L2Gl4MqLC1 ix5g+JMNgFcj68UVQTN92842yVemak5Hds1lNL0N99idcpc3mWb3i7hCEIvpDylZt/Ca ZrhzDfCrTIAQtEFTPkI6+8y7et0JCqlQa04QdzUHPqX+qrD5dU0BmC9Rwsm7T/5FCqfZ 5MAg== X-Gm-Message-State: APt69E137PnwdJhf2aehc6uT9ESp1C0cFSihvm/GGhElplHymKaTvPnT 8ZpXO4CnhzDECHFCRzoJfcsuYg== X-Received: by 2002:aa7:d992:: with SMTP id u18-v6mr12610229eds.300.1529956102893; Mon, 25 Jun 2018 12:48:22 -0700 (PDT) Received: from localhost.localdomain (146-241-36-97.dyn.eolo.it. [146.241.36.97]) by smtp.gmail.com with ESMTPSA id d11-v6sm17553edh.61.2018.06.25.12.48.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 12:48:22 -0700 (PDT) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, broonie@kernel.org, linus.walleij@linaro.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, Paolo Valente Subject: [PATCH BUGFIX 2/4] block, bfq: do not expire a queue that will deserve dispatch plugging Date: Mon, 25 Jun 2018 21:48:04 +0200 Message-Id: <20180625194806.7619-3-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180625194806.7619-1-paolo.valente@linaro.org> References: <20180625194806.7619-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For some bfq_queues, BFQ plugs I/O dispatching when the queue becomes idle, and keeps the plug until a new request of the queue arrives, or a timeout fires. BFQ does so either to boost throughput or to preserve service guarantees for the queue. More precisely, for such a queue, plugging starts when the queue happens to have either no request enqueued, or no request in flight, that is, no request already dispatched but not yet completed. On the opposite end, BFQ may happen to expire a queue with no request enqueued, without doing any plugging, if the queue still has some request in flight. Unfortunately, such a premature expiration causes the queue to lose its chance to enjoy dispatch plugging a moment later, i.e., when its in-flight requests finally get completed. This breaks service guarantees for the queue. This commit prevents BFQ from expiring an empty queue if the latter still has in-flight requests. Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) -- 2.16.1 diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 3f32e88c7e9b..4fd4f1996498 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -3597,8 +3597,14 @@ static struct bfq_queue *bfq_select_queue(struct bfq_data *bfqd) bfq_log_bfqq(bfqd, bfqq, "select_queue: already in-service queue"); + /* + * Do not expire bfqq for budget timeout if bfqq may be about + * to enjoy device idling. The reason why, in this case, we + * prevent bfqq from expiring is the same as in the comments + * on the case where bfq_bfqq_must_idle() returns true, in + * bfq_completed_request(). + */ if (bfq_may_expire_for_budg_timeout(bfqq) && - !bfq_bfqq_wait_request(bfqq) && !bfq_bfqq_must_idle(bfqq)) goto expire; @@ -4674,8 +4680,32 @@ static void bfq_completed_request(struct bfq_queue *bfqq, struct bfq_data *bfqd) * or if we want to idle in case it has no pending requests. */ if (bfqd->in_service_queue == bfqq) { - if (bfqq->dispatched == 0 && bfq_bfqq_must_idle(bfqq)) { - bfq_arm_slice_timer(bfqd); + if (bfq_bfqq_must_idle(bfqq)) { + if (bfqq->dispatched == 0) + bfq_arm_slice_timer(bfqd); + /* + * If we get here, we do not expire bfqq, even + * if bfqq was in budget timeout or had no + * more requests (as controlled in the next + * conditional instructions). The reason for + * not expiring bfqq is as follows. + * + * Here bfqq->dispatched > 0 holds, but + * bfq_bfqq_must_idle() returned true. This + * implies that, even if no request arrives + * for bfqq before bfqq->dispatched reaches 0, + * bfqq will, however, not be expired on the + * completion event that causes bfqq->dispatch + * to reach zero. In contrast, on this event, + * bfqq will start enjoying device idling + * (I/O-dispatch plugging). + * + * But, if we expired bfqq here, bfqq would + * not have the chance to enjoy device idling + * when bfqq->dispatched finally reaches + * zero. This would expose bfqq to violation + * of its reserved service guarantees. + */ return; } else if (bfq_may_expire_for_budg_timeout(bfqq)) bfq_bfqq_expire(bfqd, bfqq, false, From patchwork Mon Jun 25 19:48:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 139880 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4372601lji; Mon, 25 Jun 2018 12:48:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKurykgVhg09EWLA/FdRsyX7Uue/+MBCgPyuzUwnnc+wkI5VVh6appQJGR6ch3J8SSVhtzj X-Received: by 2002:a63:8c51:: with SMTP id q17-v6mr12086722pgn.236.1529956126067; Mon, 25 Jun 2018 12:48:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529956126; cv=none; d=google.com; s=arc-20160816; b=wl0s7vopWsyzafqGfWbUlknG/F5n3d05qCg61pKDltvxRtl0n+ow4EyrTxsc9wTqwK 3S6gd/BJFqW80aZ7m64/chlCdr1fxmSnGpueqbvlB8hpLPf4unss+cN260Y/WLE2tixE AW8tXYjrYCVXB2hFx3TSdtdW0MHLOBiPM+8Yna6SVpTDKkHi77dFeimzFtvLmfFuV/H0 No1BUlvnrPJJVh5pPie3cLTXHegIfe/lcUuKZqMCzyibO3Le1I7i21XAtYJxsHn6NgEQ fAGpF0yHthFBpU7OSrUoiCScoelkFiWd6hoUhkHfhLN/NOVolMxh69Pwp0elLIUn8a8+ YIKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=LKtII1UD6euL+L9WiOdbqv9eZt0vnFL0OuzsmpLoWpw=; b=RECn/3DLVfCILDN+nVrXsEBMbCOeNVMkIhZkpA5ge8LDJMlT5ufDAP0gQZ0VeJLEUY 0/O+aZttHgJefq770cNtDPQl3QHrwjLpneJdUu/bFT7+MDxXXeG0nfLuq2vApTtG1DL1 cTLCzBK5y0/PlY8ez4yOI5C23rHPkwLlxQWCGZMVezbDkb1J0Czmg3VMDrw6QuhjVCl7 mXEwfGfFIEDtoLpnh5T7elrmEttpRN89icML70MCXZajCsIzNkKPlHa0NVG5sHl3f92O SP5N6GhIoe9QqlfpqGS6RpCm8YFeNbhaAeANiZYXI61XOaLRgPsaHmajhS1sxbMHXapT Bv8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="I7/n6jSE"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5-v6si11683865pgr.436.2018.06.25.12.48.45; Mon, 25 Jun 2018 12:48:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="I7/n6jSE"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935071AbeFYTs3 (ORCPT + 31 others); Mon, 25 Jun 2018 15:48:29 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:36704 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934996AbeFYTsZ (ORCPT ); Mon, 25 Jun 2018 15:48:25 -0400 Received: by mail-ed1-f68.google.com with SMTP id t3-v6so6149037eds.3 for ; Mon, 25 Jun 2018 12:48:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LKtII1UD6euL+L9WiOdbqv9eZt0vnFL0OuzsmpLoWpw=; b=I7/n6jSE+y7+oZY2VtrgxXNCT0d9NRee/fF54+roBwYsGHcmlW6VR8jLGF+tXAreV9 u955TZC6w4a8pT3EhNYNFo1R3iS0jvvQIut5xX+JbE1XRLr6Bj/Bl4eKIjzICEM/1l/U cCkSIPN5JYjBeZWQQ5fyzDxwWQ72vbG+QXnj0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LKtII1UD6euL+L9WiOdbqv9eZt0vnFL0OuzsmpLoWpw=; b=Yf+KecN7pMyFQbKmBD+KFA0FvHWT/Sng1X1s9cPeHHOhtX4zbWe3jdcjq4AG4YBUCg WQtkGtdkIRhoMwjTHASlAhIND7Ni4T9CgGAYLFyc8wrCwFrJf85qzgvFIlkva+s0MSHM CcqlbfwAVhKcU8ZvXcWeQxK/+l2x2wOLGCfujJY+RuqE9EJ90AOvvl3I2vne6vxd2+HY 1RhSTpcv8dwKW1JqoTt9oVMrp5Exhv15DKAlt1mlBStN5GvdBTNQl4yCpSgydbVNTNw/ 3COXvH4twTnL477g99RjukU2Zt/BEyB5V8r4ew6SZ0DongZWPnUFJt5aP5YJOSLgW9xa fbJQ== X-Gm-Message-State: APt69E2UKCsWqsSMQu2rpqxy5nVPOD9/78lc5169zBeQMimfJgq5SXDQ Z2LPXEsQRdBCCG3zrivOtpvHdw== X-Received: by 2002:a50:8876:: with SMTP id c51-v6mr12610295edc.146.1529956104500; Mon, 25 Jun 2018 12:48:24 -0700 (PDT) Received: from localhost.localdomain (146-241-36-97.dyn.eolo.it. [146.241.36.97]) by smtp.gmail.com with ESMTPSA id d11-v6sm17553edh.61.2018.06.25.12.48.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 12:48:23 -0700 (PDT) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, broonie@kernel.org, linus.walleij@linaro.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, Paolo Valente Subject: [PATCH BUGFIX 3/4] block, bfq: fix service being wrongly set to zero in case of preemption Date: Mon, 25 Jun 2018 21:48:05 +0200 Message-Id: <20180625194806.7619-4-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180625194806.7619-1-paolo.valente@linaro.org> References: <20180625194806.7619-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If - a bfq_queue Q preempts another queue, because one request of Q arrives in time, - but, after this preemption, Q is not the queue that is set in service, then Q->entity.service is set to 0 when Q is eventually set in service. But Q should have continued receiving service with its old budget (which is why preemption has occurred) and its old service. This commit addresses this issue by resetting service on queue real expiration. Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 34 ++++++++++++++++++++++++++++------ block/bfq-wf2q.c | 6 ------ 2 files changed, 28 insertions(+), 12 deletions(-) -- 2.16.1 diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 4fd4f1996498..d579cc8e0db6 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1382,18 +1382,30 @@ static bool bfq_bfqq_update_budg_for_activation(struct bfq_data *bfqd, * remain unchanged after such an expiration, and the * following statement therefore assigns to * entity->budget the remaining budget on such an - * expiration. For clarity, entity->service is not - * updated on expiration in any case, and, in normal - * operation, is reset only when bfqq is selected for - * service (see bfq_get_next_queue). + * expiration. */ entity->budget = min_t(unsigned long, bfq_bfqq_budget_left(bfqq), bfqq->max_budget); + /* + * At this point, we have used entity->service to get + * the budget left (needed for updating + * entity->budget). Thus we finally can, and have to, + * reset entity->service. The latter must be reset + * because bfqq would otherwise be charged again for + * the service it has received during its previous + * service slot(s). + */ + entity->service = 0; + return true; } + /* + * We can finally complete expiration, by setting service to 0. + */ + entity->service = 0; entity->budget = max_t(unsigned long, bfqq->max_budget, bfq_serv_to_charge(bfqq->next_rq, bfqq)); bfq_clear_bfqq_non_blocking_wait_rq(bfqq); @@ -3271,11 +3283,21 @@ void bfq_bfqq_expire(struct bfq_data *bfqd, ref = bfqq->ref; __bfq_bfqq_expire(bfqd, bfqq); + if (ref == 1) /* bfqq is gone, no more actions on it */ + return; + /* mark bfqq as waiting a request only if a bic still points to it */ - if (ref > 1 && !bfq_bfqq_busy(bfqq) && + if (!bfq_bfqq_busy(bfqq) && reason != BFQQE_BUDGET_TIMEOUT && - reason != BFQQE_BUDGET_EXHAUSTED) + reason != BFQQE_BUDGET_EXHAUSTED) { bfq_mark_bfqq_non_blocking_wait_rq(bfqq); + /* + * Not setting service to 0, because, if the next rq + * arrives in time, the queue will go on receiving + * service with this same budget (as if it never expired) + */ + } else + entity->service = 0; } /* diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 58cf38fcee05..dbc07b456059 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -1544,12 +1544,6 @@ struct bfq_queue *bfq_get_next_queue(struct bfq_data *bfqd) entity = sd->next_in_service; sd->in_service_entity = entity; - /* - * Reset the accumulator of the amount of service that - * the entity is about to receive. - */ - entity->service = 0; - /* * If entity is no longer a candidate for next * service, then it must be extracted from its active From patchwork Mon Jun 25 19:48:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 139879 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4372453lji; Mon, 25 Jun 2018 12:48:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ6wFlvs8JBSs6QFchQeMUcoFczWWgfm3SAXqbvNROi4isj3hzUNO5AsTOcPhc7ice2Mve7 X-Received: by 2002:a17:902:e00a:: with SMTP id ca10-v6mr13740440plb.224.1529956113550; Mon, 25 Jun 2018 12:48:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529956113; cv=none; d=google.com; s=arc-20160816; b=ieWayKY/TxhpiS4gdLlwmHiv5m8Nn5aFeuqmJENm0RIBePrSFRs3qRT8cjQMEFga8q 8ev9IShuLt88eaws506RHukwAvfuwegYeMHfOOIKl/46OORd+0MZJOZfQP8YuwOJDMHV VvaLhuwhoV+SHa0Z4jKdmnJaPHlkuvA1kISKPbM+jmaCtApC+kRGdpHK96aXilJFdGxm IIZVEUEhS/hDWa0hr3sHUjWq9Bx9+WMyOBB/ZVfOIhzHJUMgwZ77L3RFxDBL2fRbn5kL YI3Aaia+gONcmDQfd5YIBZJaRJ0MT0QHq3NssS8OsC1/HcVhNT11d0v+1aG/RlOJIm9B odAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=etSldo+TTaIxyBqdR+aXwM2wiHco5+65A1h2yeD17QE=; b=HGMc+H/GIBLk+pikH1NWIXdIJF6R0BIICTBiqxTBCff6PXnIG/kODofA4EoiKL+kUx ysw3E0CfsWJ0DnhsS6z2WnpiBP7l6QbaxGOvysXkfWT5aFOwX49GyVUIXGSggHWti2Qw lnef9k0Y66BFa21mlABL1dkq08czdJQkXVzDAFem3Zx2FpDmt/YnBwDEhIvN+CU6FoDC jdVntG0duCWptLBPa0afCWRv4lG9zDBfdNZPV4P6/qkmi/n4sH4tUy3iUqI5WfwfP9ik vlAAtpkZWyvFrEj+NUrAOYXR5ij/xubez369jxlFFI62Kj96WemdhScf9OSJuhJDUAX3 YxPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cw1zWgVi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13-v6si14760740pll.72.2018.06.25.12.48.33; Mon, 25 Jun 2018 12:48:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cw1zWgVi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935098AbeFYTsb (ORCPT + 31 others); Mon, 25 Jun 2018 15:48:31 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:45200 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935028AbeFYTs1 (ORCPT ); Mon, 25 Jun 2018 15:48:27 -0400 Received: by mail-ed1-f68.google.com with SMTP id x22-v6so1837769edq.12 for ; Mon, 25 Jun 2018 12:48:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=etSldo+TTaIxyBqdR+aXwM2wiHco5+65A1h2yeD17QE=; b=cw1zWgViqVMuvVISxzbNCQo8gBMCS2YOG+H3FbHu2G1DRAdyq847wPvR2qcqDXbnaM wKmfSeXd4QAEzCUj3YtjL6otUSB3cALB7nKXXvRNuLic7cwZlet3F7KYtZjHKCqrRC6+ KCDA/1fXnwWDSjJwKIRyeekejTgAoxRZI/vac= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=etSldo+TTaIxyBqdR+aXwM2wiHco5+65A1h2yeD17QE=; b=qvUiJKKE5pqzJM9xsohMG7u/dfvF/ojb1QW/Fgm2XxQa5THoXvguqMYgWWAYZCmt5+ GKj9ut1OL7ue+Rfkn1/vTucD2vFupKbxFYm0mmMvwhFVgkGEX3IFgqPd3pe7HLPNqKtx MYhfCvxmDonQGsZTphlB85SnUaNGk3pb2nBqMVTppAIqSL9p5ZixxjavmnXLiVOHiARb MewVbhNt89eNhc5fXflW3HPKAy+Rcu9pY8BUq7l9rzLEuSmMSiBV4bUYkfHFz8MFU9sM Z71+kGc/47P7Fs71ep/kWz/P614QsGE+7Pbri/VWt19f5WpRfmd8Jk3NQLe3cX2mP2AH n3Jw== X-Gm-Message-State: APt69E2WGVDMuewgh29xnuNYIAEyszeVL4SvvpTFdQYO9Wm67hRAMaXq BiRp70ypHyAcpzVyN2kdMoBkvQ== X-Received: by 2002:a50:b761:: with SMTP id g88-v6mr12542608ede.129.1529956105838; Mon, 25 Jun 2018 12:48:25 -0700 (PDT) Received: from localhost.localdomain (146-241-36-97.dyn.eolo.it. [146.241.36.97]) by smtp.gmail.com with ESMTPSA id d11-v6sm17553edh.61.2018.06.25.12.48.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 12:48:25 -0700 (PDT) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, broonie@kernel.org, linus.walleij@linaro.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, Paolo Valente Subject: [PATCH BUGFIX 4/4] block, bfq: fix service being wrongly set to zero in case of preemption Date: Mon, 25 Jun 2018 21:48:06 +0200 Message-Id: <20180625194806.7619-5-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180625194806.7619-1-paolo.valente@linaro.org> References: <20180625194806.7619-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If - a bfq_queue Q preempts another queue, because one request of Q arrives in time, - but, after this preemption, Q is not the queue that is set in service, then Q->entity.service is set to 0 when Q is eventually set in service. But Q should have continued receiving service with its old budget (which is why preemption has occurred) and its old service. This commit addresses this issue by resetting service on queue real expiration. Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) -- 2.16.1 diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index d579cc8e0db6..41d9036b1822 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -634,7 +634,7 @@ static bool bfq_differentiated_weights(struct bfq_data *bfqd) * The following function returns true if every queue must receive the * same share of the throughput (this condition is used when deciding * whether idling may be disabled, see the comments in the function - * bfq_bfqq_may_idle()). + * bfq_better_to_idle()). * * Such a scenario occurs when: * 1) all active queues have the same weight, @@ -3355,7 +3355,7 @@ static bool bfq_may_expire_for_budg_timeout(struct bfq_queue *bfqq) * issues taken into account are not trivial. We discuss these issues * individually while introducing the variables. */ -static bool bfq_bfqq_may_idle(struct bfq_queue *bfqq) +static bool bfq_better_to_idle(struct bfq_queue *bfqq) { struct bfq_data *bfqd = bfqq->bfqd; bool rot_without_queueing = @@ -3588,19 +3588,19 @@ static bool bfq_bfqq_may_idle(struct bfq_queue *bfqq) } /* - * If the in-service queue is empty but the function bfq_bfqq_may_idle + * If the in-service queue is empty but the function bfq_better_to_idle * returns true, then: * 1) the queue must remain in service and cannot be expired, and * 2) the device must be idled to wait for the possible arrival of a new * request for the queue. - * See the comments on the function bfq_bfqq_may_idle for the reasons + * See the comments on the function bfq_better_to_idle for the reasons * why performing device idling is the best choice to boost the throughput - * and preserve service guarantees when bfq_bfqq_may_idle itself + * and preserve service guarantees when bfq_better_to_idle itself * returns true. */ static bool bfq_bfqq_must_idle(struct bfq_queue *bfqq) { - return RB_EMPTY_ROOT(&bfqq->sort_list) && bfq_bfqq_may_idle(bfqq); + return RB_EMPTY_ROOT(&bfqq->sort_list) && bfq_better_to_idle(bfqq); } /* @@ -3686,7 +3686,7 @@ static struct bfq_queue *bfq_select_queue(struct bfq_data *bfqd) * may idle after their completion, then keep it anyway. */ if (bfq_bfqq_wait_request(bfqq) || - (bfqq->dispatched != 0 && bfq_bfqq_may_idle(bfqq))) { + (bfqq->dispatched != 0 && bfq_better_to_idle(bfqq))) { bfqq = NULL; goto keep_queue; } @@ -4734,7 +4734,7 @@ static void bfq_completed_request(struct bfq_queue *bfqq, struct bfq_data *bfqd) BFQQE_BUDGET_TIMEOUT); else if (RB_EMPTY_ROOT(&bfqq->sort_list) && (bfqq->dispatched == 0 || - !bfq_bfqq_may_idle(bfqq))) + !bfq_better_to_idle(bfqq))) bfq_bfqq_expire(bfqd, bfqq, false, BFQQE_NO_MORE_REQUESTS); }