From patchwork Mon Jul 12 06:06:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 473018 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2701994jao; Mon, 12 Jul 2021 00:53:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFZVr6o1wMyXmPff4m/UO46wq+hci9jUMdTKjS+6kz1hcv+ZvyXiRi15hSnKfUKTysPCTQ X-Received: by 2002:a17:906:3658:: with SMTP id r24mr30737494ejb.179.1626076428338; Mon, 12 Jul 2021 00:53:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626076428; cv=none; d=google.com; s=arc-20160816; b=K9zBMMcFxtfFn8xy3Ke+OvxNxyf1sewe8h67p+mYmFcwkBcz1FiYk021o65SfG2EG5 whFDaOh1KnzCzLq+x+hvQondOu1SCm0BmmjWp3BhAD1LjxtrX+2aCdpIptjDf6Bl/pOU PmsZ9I6G/4WFQmstzdLUn4d1NpG7QwB2WqRvVzRE2DQ6BmT6d5N2tBtO93OgUoeOaZiE gXZbT/VCbf/rOcm8XffW9zxdGvpmprLQEat6n+iAul53xqBa4ZKOUI4Iq33tqljs+XVL YRapmUV6aDvNVH9WpMJ+zth4IZzBNEyI1JEptbbMYBYvrOf7+B/VpjVyZIr3+QiTY/wV dqWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=d76i/U74znf/1X6N132zE/qLtw2AVx2ICgu1s/TsCjk=; b=peME96bYBYbkBPa9/8Qa2dTTDfiNhw8iB+NaJFcg1Fm5F5njLHXMxxJ4IIAAGFgPJi 3XjH0tgR9MXltnVyXAhGffUYhzrTfpwPS4vW3fM/LAHxhZvo6SM7IVhkwyMh6vjZ41TP /jwGGzZyslZ8LEnQo8/T/QWMrFLIeh/lADmzZpD53K5vusKfyB2yASuFW3XsHsR7rt6x v53Ti8Ki8o0oM84ChxStt2BlaFa9KTzYWrPBkvr4oOoJuo4X7g7Vpi4WmjlNPHKO3NpP zBFCobEpSB8AUuyEMUnyeL8DG5BEo3zdh9LP90MO2zFt7V0xMdKWyFNWEwlooFexWA9b k2oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DXYXD466; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n21si13642925eda.13.2021.07.12.00.53.48; Mon, 12 Jul 2021 00:53:48 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DXYXD466; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352256AbhGLHy0 (ORCPT + 12 others); Mon, 12 Jul 2021 03:54:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:35416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349332AbhGLHuL (ORCPT ); Mon, 12 Jul 2021 03:50:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8C80261574; Mon, 12 Jul 2021 07:43:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626075812; bh=e2L0I2VZaiXf+U9hDNswEpWhZU5XEmsDz2GSAHxB1PU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DXYXD466tg2XywLPOKQ50oXOdsggL7HYsEq/w3w/VJD/JTkIk7Htmt9fj/gTkb9IX EpaxIKsepuPBD7piSuu9LjTUJuQX91Bsg3YzjMKXb/zcu+9EFaPRWRtbUqBjJGrlJU LGJV7OWAwbN9c8bP8baQELdopmfGR6Tg2lFRVN2g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?Holger_Hoffst=C3=A4tte?= , Paolo Valente , Jens Axboe , Sasha Levin Subject: [PATCH 5.13 373/800] block, bfq: avoid delayed merge of async queues Date: Mon, 12 Jul 2021 08:06:36 +0200 Message-Id: <20210712061006.756343654@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060912.995381202@linuxfoundation.org> References: <20210712060912.995381202@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Paolo Valente [ Upstream commit bd3664b362381c4c1473753ebedf0ab242a60d1d ] Since commit 430a67f9d616 ("block, bfq: merge bursts of newly-created queues"), BFQ may schedule a merge between a newly created sync bfq_queue, say Q2, and the last sync bfq_queue created, say Q1. To this goal, BFQ stores the address of Q1 in the field bic->stable_merge_bfqq of the bic associated with Q2. So, when the time for the possible merge arrives, BFQ knows which bfq_queue to merge Q2 with. In particular, BFQ checks for possible merges on request arrivals. Yet the same bic may also be associated with an async bfq_queue, say Q3. So, if a request for Q3 arrives, then the above check may happen to be executed while the bfq_queue at hand is Q3, instead of Q2. In this case, Q1 happens to be merged with an async bfq_queue. This is not only a conceptual mistake, because async queues are to be kept out of queue merging, but also a bug that leads to inconsistent states. This commits simply filters async queues out of delayed merges. Fixes: 430a67f9d616 ("block, bfq: merge bursts of newly-created queues") Tested-by: Holger Hoffstätte Signed-off-by: Paolo Valente Link: https://lore.kernel.org/r/20210619140948.98712-6-paolo.valente@linaro.org Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bfq-iosched.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.30.2 diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index d00c89f6ba59..7c62bf093199 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -2703,7 +2703,13 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq, * costly and complicated. */ if (unlikely(!bfqd->nonrot_with_queueing)) { - if (bic->stable_merge_bfqq && + /* + * Make sure also that bfqq is sync, because + * bic->stable_merge_bfqq may point to some queue (for + * stable merging) also if bic is associated with a + * sync queue, but this bfqq is async + */ + if (bfq_bfqq_sync(bfqq) && bic->stable_merge_bfqq && !bfq_bfqq_just_created(bfqq) && time_is_before_jiffies(bfqq->split_time + msecs_to_jiffies(200))) {