From patchwork Thu May 31 13:23:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 137389 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp6599915lji; Thu, 31 May 2018 06:23:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLPu6rHiJcoiAl6F3JbUokFXsAx8PcDRPKnioGoDX7+oZkYLdFCn7a3hChGkAm5GttC67/Q X-Received: by 2002:a17:902:8685:: with SMTP id g5-v6mr6844233plo.302.1527773025683; Thu, 31 May 2018 06:23:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527773025; cv=none; d=google.com; s=arc-20160816; b=H4GrOAhEOECO1ErwR/WW0rgtHUfD9UJEFQG4POsYlwDIEjZR+dNLFL7f5GOWHo8VKJ AmoWpuV/C70k8uP3lfQhPcvIT2cb5wlUTCdiuEss76yiPxsVCtlSzJt+SfpTP6o0ZwEt EAYv8nqNCuqAUuMPbyoSRFO6flMvoZw2naVjqfMuSw47kDYVs0+dSIKEeRNLE04ALBNb 8apEzvs2FvaMrDv7NA1ik7Srq6Mi+iWaa+4JPkr4+oAwmQ9WpeNXDQhmm97/kZKPXTKP QFXQXxOl8X4bilTWv0h9GzKiunZDZJJ42GZX2IpfNFOd59KWjBse/+kelTSZKJ109GqO AiKA== 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=EDxxfeUlzKc3ZdpNXUqSJs2cf7e+TOKIjiRlTJbaC3c=; b=D0JEDurfPq4j4AXaTZo6oObKXSdgiNHRAlz/scKMdUz91VMJHA9aFm46qmlB2L/os7 ykpy7nOTiehln6M8e4EpSoV44zTLUe8Bjfk6Zbin42bAwLFTDLiWZT5cVwZUUjQoW67J QIVlulBg4ty4SSuNQ6QhCnfiOJGNzV3zjFHTWU05vVTWe+wKTWSvy0mNf38/6iZFqYBR 3mEPjTMPB79TODKE7MlZrQPuOXhm4hIQvs1KaBSXbNnw/VZai2dm4ys6hw04cMFCDbkJ z3+Ad3UQX8jw+F5uEaDRSL4K08qMVop/Z/H2C4ng3hQqI7xxvUQfvgYotV7ScpXgXDo/ GogA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ktD10YBc; 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 r17-v6si17558609pls.597.2018.05.31.06.23.45; Thu, 31 May 2018 06:23:45 -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=ktD10YBc; 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 S1755304AbeEaNXn (ORCPT + 30 others); Thu, 31 May 2018 09:23:43 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:41183 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755267AbeEaNXf (ORCPT ); Thu, 31 May 2018 09:23:35 -0400 Received: by mail-wr0-f194.google.com with SMTP id u12-v6so32975529wrn.8 for ; Thu, 31 May 2018 06:23:35 -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=EDxxfeUlzKc3ZdpNXUqSJs2cf7e+TOKIjiRlTJbaC3c=; b=ktD10YBcp5E8ciX+3S5pI3WjJnM6xxQXu0WgI6vyFWNTOYz5LV9GEoGHkXiwZoF0Ie 2cetWMyW/dOIkOlMop3xzbFkctPqT+igg8/RToL0AdTgjktbRERMJmW9iq6Th700/IUx TbIUHvZXagH9GYrUKGS29ldj4fsrzLNWHCs8s= 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=EDxxfeUlzKc3ZdpNXUqSJs2cf7e+TOKIjiRlTJbaC3c=; b=fwe/RKUinL9HjWaumhrYAD0GZydFYGNRRGmraZMvk/gPddgnrnDPXu+W+h/VPRnroM 3p+3jRyolbgbr+nVM99Z4yd6Sa4WOqh85HsBBN2T3ndIh7rbiwAoi0xvvpkbAQ84F+eX ZnCo1G1nI4ABPZY2Syt0FKWdy3rhwW2D1k7yz8WrGhzC3wkwJAyzU8suAUvqYvoMMGFy gANYc2e++hCD4pfEpUmov8nh0W6G1a/wUQsIDuD3HBv3tzfyX5lQ7z0zT40Ukh2wWHeI S/V7Moth+vrbJxOlpStt5pGmJPRgNphrdxoCZ5ZMZoxiOd3m2F5bfAVrR9kRmNDaLIM9 7Nfg== X-Gm-Message-State: ALKqPwdnvYTIXpeK21Skl3J2TbZGLSJvW2In46LcyA9bQQRSRtFGpRqn 1BCvNm5mNvddecL/JTV6W0+bVw== X-Received: by 2002:adf:8290:: with SMTP id 16-v6mr5346141wrc.38.1527773014580; Thu, 31 May 2018 06:23:34 -0700 (PDT) Received: from localhost.localdomain (146-241-12-84.dyn.eolo.it. [146.241.12.84]) by smtp.gmail.com with ESMTPSA id e133-v6sm1759478wma.38.2018.05.31.06.23.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 06:23:33 -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, filippo.muzzini@outlook.it, Paolo Valente Subject: [PATCH BUGFIX 2/3] block, bfq: remove wrong check in bfq_requests_merged Date: Thu, 31 May 2018 15:23:12 +0200 Message-Id: <20180531132313.2986-3-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180531132313.2986-1-paolo.valente@linaro.org> References: <20180531132313.2986-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The request rq passed to the function bfq_requests_merged is always in a bfq_queue, so the check !RB_EMPTY_NODE(&rq->rb_node) at the beginning of bfq_requests_merged always succeeds, and the control flow systematically skips to the end of the function. This implies that the body of the function is never executed, i.e., the repositioning of rq is never performed. On the opposite end, a control is missing in the body of the function: 'next' must be removed only if it is inside a bfq_queue. This commit removes the wrong check on rq, and adds the missing check on 'next'. In addition, this commit adds comments on bfq_requests_merged. Signed-off-by: Filippo Muzzini Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) -- 2.16.1 diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 1f0951d36424..df2a9633cf4a 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1891,14 +1891,27 @@ static void bfq_request_merged(struct request_queue *q, struct request *req, } } +/* + * This function is called to notify the scheduler that the requests + * rq and 'next' have been merged, with 'next' going away. BFQ + * exploits this hook to address the following issue: if 'next' has a + * fifo_time lower that rq, then the fifo_time of rq must be set to + * the value of 'next', to not forget the greater age of 'next'. + * Moreover 'next' may be in a bfq_queue, in this case it must be + * removed. + * + * NOTE: in this function we assume that rq is in a bfq_queue, basing + * on that rq is picked from the hash table q->elevator->hash, which, + * in its turn, is filled only with I/O requests present in + * bfq_queues, while BFQ is in use for the request queue q. In fact, + * the function that fills this hash table (elv_rqhash_add) is called + * only by bfq_insert_request. + */ static void bfq_requests_merged(struct request_queue *q, struct request *rq, struct request *next) { struct bfq_queue *bfqq = RQ_BFQQ(rq), *next_bfqq = RQ_BFQQ(next); - if (!RB_EMPTY_NODE(&rq->rb_node)) - goto end; - /* * If next and rq belong to the same bfq_queue and next is older * than rq, then reposition rq in the fifo (by substituting next @@ -1919,10 +1932,11 @@ static void bfq_requests_merged(struct request_queue *q, struct request *rq, if (bfqq->next_rq == next) bfqq->next_rq = rq; - bfq_remove_request(q, next); - bfqg_stats_update_io_remove(bfqq_group(bfqq), next->cmd_flags); + if (!RB_EMPTY_NODE(&next->rb_node)) { + bfq_remove_request(q, next); + bfqg_stats_update_io_remove(bfqq_group(bfqq), next->cmd_flags); + } -end: bfqg_stats_update_io_merged(bfqq_group(bfqq), next->cmd_flags); }