Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1639535ybv; Fri, 21 Feb 2020 00:48:44 -0800 (PST) X-Google-Smtp-Source: APXvYqybrmvQF4SH1kJdqx43SWebnU5xxfHhCMrwKE+FWiHkqML78ot+AZuYNnD7S5MNYZ/fTWbD X-Received: by 2002:aca:f0b:: with SMTP id 11mr1138877oip.34.1582274924040; Fri, 21 Feb 2020 00:48:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582274924; cv=none; d=google.com; s=arc-20160816; b=QnfkVJ0PKch+j5tMNzv/xWW9XpcfOj4aj2URpnf3WPtHipIHLiRBT4lwsnftaYTvYI YsmE2olnnyjrKfgoYgCMaE5ZV674XlwBh/yIaQCLxKIyvUTsGpR9nBMnNFupr4hxtAVj HNaWflS3z/GlsyFeWrRdef4SF4JpKbSoh5WBFs5giABuUDH4tOEUo3WlGiofVpbcmN94 fkWKEbwqyaYCZE9zKv19yP2dO3Xb+i/32lgdE0dAVzCmec0CkJfO2yBQfdQOvqLxtRMC hodqyk+RQQqd4R2Obn2ZbkI3d9rvY6oB7kIKhv7e1WMIXLNLFAj50uMdEgAG7eRkfzSP g+/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9waI9RA0j6zZU+z7xA0k90TZVKh1KVFjX33J9+jNTwM=; b=INiz2HdwOscOBmmcNfSzq/NoIK6O3l4u3a+BvNYCpvV6zCb6WiR6mjPX4x6xyJWzYS pBHeX55suWQ0UuLFiTjT9X44kT/7q4RnqJqjvojxeRUQJsS5SD67boY6A1AKH0hECApk X0nacTBsrJZcUdaP1S6Ywy1+rZ0YEoX8N89cIPLNHwPj6ciBBrjt5QYWiyaqLuBD5uLC qq7AxKDvG/8e30wgqb8V+jtUobc4SMXecT3WbDBzyLtJZYlxFQoe4lvsunMlK7AtLjOb BNGVDp2IQiE36k88mrhkTfknSqBUHWgOmc0XmHkxGBa6SKWowxikRXFqxmTlDsTNzjCv F5OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q3iGfMW5; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si1162591otq.31.2020.02.21.00.48.32; Fri, 21 Feb 2020 00:48:44 -0800 (PST) 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=@kernel.org header.s=default header.b=q3iGfMW5; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728348AbgBUHrk (ORCPT + 99 others); Fri, 21 Feb 2020 02:47:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:43548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728951AbgBUHri (ORCPT ); Fri, 21 Feb 2020 02:47:38 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0B660208C4; Fri, 21 Feb 2020 07:47:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582271257; bh=hhHJKlpWN495uh2vdO0TDhEHxnvrpn3GndEc5iHu2kc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q3iGfMW5cl3w4TlHD0NOB0cCwMrSaRIpeVbiigz9kTSygSeiPuIwt5kSL/cqeNwaB W7g7M731aRuVRduDTilFNWYRp2BfizytGM8ymqcFfbQ/X4sXJPzaGUtzNWcEuyD/gR JevL81HatMEuQW7pMxGQmrBmpyIDublpTauWZ6Uk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oleksandr Natalenko , Patrick Dung , Paolo Valente , Jens Axboe , Sasha Levin Subject: [PATCH 5.5 098/399] block, bfq: do not plug I/O for bfq_queues with no proc refs Date: Fri, 21 Feb 2020 08:37:03 +0100 Message-Id: <20200221072411.906324287@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072402.315346745@linuxfoundation.org> References: <20200221072402.315346745@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Valente [ Upstream commit f718b093277df582fbf8775548a4f163e664d282 ] Commit 478de3380c1c ("block, bfq: deschedule empty bfq_queues not referred by any process") fixed commit 3726112ec731 ("block, bfq: re-schedule empty queues if they deserve I/O plugging") by descheduling an empty bfq_queue when it remains with not process reference. Yet, this still left a case uncovered: an empty bfq_queue with not process reference that remains in service. This happens for an in-service sync bfq_queue that is deemed to deserve I/O-dispatch plugging when it remains empty. Yet no new requests will arrive for such a bfq_queue if no process sends requests to it any longer. Even worse, the bfq_queue may happen to be prematurely freed while still in service (because there may remain no reference to it any longer). This commit solves this problem by preventing I/O dispatch from being plugged for the in-service bfq_queue, if the latter has no process reference (the bfq_queue is then prevented from remaining in service). Fixes: 3726112ec731 ("block, bfq: re-schedule empty queues if they deserve I/O plugging") Tested-by: Oleksandr Natalenko Reported-by: Patrick Dung Tested-by: Patrick Dung Signed-off-by: Paolo Valente Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bfq-iosched.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index ad4af4aaf2ced..5c239c540c47a 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -3444,6 +3444,10 @@ static void bfq_dispatch_remove(struct request_queue *q, struct request *rq) static bool idling_needed_for_service_guarantees(struct bfq_data *bfqd, struct bfq_queue *bfqq) { + /* No point in idling for bfqq if it won't get requests any longer */ + if (unlikely(!bfqq_process_refs(bfqq))) + return false; + return (bfqq->wr_coeff > 1 && (bfqd->wr_busy_queues < bfq_tot_busy_queues(bfqd) || @@ -4077,6 +4081,10 @@ static bool idling_boosts_thr_without_issues(struct bfq_data *bfqd, bfqq_sequential_and_IO_bound, idling_boosts_thr; + /* No point in idling for bfqq if it won't get requests any longer */ + if (unlikely(!bfqq_process_refs(bfqq))) + return false; + bfqq_sequential_and_IO_bound = !BFQQ_SEEKY(bfqq) && bfq_bfqq_IO_bound(bfqq) && bfq_bfqq_has_short_ttime(bfqq); @@ -4170,6 +4178,10 @@ static bool bfq_better_to_idle(struct bfq_queue *bfqq) struct bfq_data *bfqd = bfqq->bfqd; bool idling_boosts_thr_with_no_issue, idling_needed_for_service_guar; + /* No point in idling for bfqq if it won't get requests any longer */ + if (unlikely(!bfqq_process_refs(bfqq))) + return false; + if (unlikely(bfqd->strict_guarantees)) return true; -- 2.20.1