Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3972997pxb; Tue, 2 Mar 2021 03:32:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJyG3Yr7/IXupXVH8BFYRnwqBHvR+Ksl5Ff9kONO9gxaJh3CFa4QMRq82PR0x+iRycQXQUNN X-Received: by 2002:a17:906:7c43:: with SMTP id g3mr20220355ejp.210.1614684723192; Tue, 02 Mar 2021 03:32:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614684723; cv=none; d=google.com; s=arc-20160816; b=YUj32bY5JIoH6lF5+nd0Uyy1J7TXBfADwAzRTKj3O0+w5AZU6Tu0DDrSnLOHdH8k8H 2GwJ2BQmJV8QuryhFp30Rb7CDkdZENWDGBhSk0VGEyuywtdQtaEMKxSGjuy12jA3uR9C zQQ8jkIdCWIIG0YYnZqOb3a2QcPfSl/aciPAvqX3HgVxkHVbCCYNM/OQBQtQr1Yl1gOB lFGIwe+ANr/NwU9nL/d1M0fZbbrmSNdEJv0X7UnnmHZwygJCVD+oHufjtveqbW7Kv+rn B+csy8TDVADnFAKL0PqBcheY/hYOJnN+eXySsFiDVob46AOHJwz7k7Btw7CjmGlbcp/h i+cQ== 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=hukwEieUfQWuMlzXTjlb7qCj1e+gCYH3nSy2f/R8cgg=; b=IxUxJKjTB5ayyXwWNnVNrNLTuZyteC0/EpP54tQ5TDm0hBQ3Z0LMswl1pLXsbkNrJO pdv+WH7fNjYo2rExG4YFwAgkcZUnbTKeDm45u2UFa+CBxEEEVcfk64cYIKdxLL4vbKMx dDVomWTBIsrNiVagU/fanmPk/NcmEzcJf5qhdNxPDFWIexVk3gY5uMTFrbrrGpjsDAsM niSMtD1Hp+s7GlSG+kKEmJh2EB7RaJJe81dc23vlFLqHht6tiZM7OJ+uBCkfNsxx0sLQ 2Z5FmhhDks3jVNoCg6z4bnX2Esv6Gl95sLE3CnC9AaWt0jLxEFn1udw7h0i7kNV/wpvi TCHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1oyZt2DY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 z12si12912858edc.34.2021.03.02.03.31.38; Tue, 02 Mar 2021 03:32:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=1oyZt2DY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1380805AbhCBBzo (ORCPT + 99 others); Mon, 1 Mar 2021 20:55:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:48602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241944AbhCAT36 (ORCPT ); Mon, 1 Mar 2021 14:29:58 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8437465134; Mon, 1 Mar 2021 17:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614618230; bh=LhcZVeNCRJS1Z6vXuuq/RF6MV1TwjipyFenDsbvlGMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1oyZt2DY80zawgMOGjRSzNlHlW0jpS/aWXYtGHRuYzJsnZ1Bw87ZvSfG1dMBaoBhJ uiJoQrsKUnKMBf0+y5m12rXPC3j18mOUM+a1I8A7/bocFWkx9Y3Xk3n6KRcpEKKTdw vIFHP3zUjdxqnBYqOiGtnr7uS0KiQVqV9cikdnOk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kara , Paolo Valente , Jens Axboe Subject: [PATCH 5.10 012/663] bfq: Avoid false bfq queue merging Date: Mon, 1 Mar 2021 17:04:20 +0100 Message-Id: <20210301161142.393649916@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kara commit 41e76c85660c022c6bf5713bfb6c21e64a487cec upstream. bfq_setup_cooperator() uses bfqd->in_serv_last_pos so detect whether it makes sense to merge current bfq queue with the in-service queue. However if the in-service queue is freshly scheduled and didn't dispatch any requests yet, bfqd->in_serv_last_pos is stale and contains value from the previously scheduled bfq queue which can thus result in a bogus decision that the two queues should be merged. This bug can be observed for example with the following fio jobfile: [global] direct=0 ioengine=sync invalidate=1 size=1g rw=read [reader] numjobs=4 directory=/mnt where the 4 processes will end up in the one shared bfq queue although they do IO to physically very distant files (for some reason I was able to observe this only with slice_idle=1ms setting). Fix the problem by invalidating bfqd->in_serv_last_pos when switching in-service queue. Fixes: 058fdecc6de7 ("block, bfq: fix in-service-queue check for queue merging") CC: stable@vger.kernel.org Signed-off-by: Jan Kara Acked-by: Paolo Valente Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/bfq-iosched.c | 1 + 1 file changed, 1 insertion(+) --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -2937,6 +2937,7 @@ static void __bfq_set_in_service_queue(s } bfqd->in_service_queue = bfqq; + bfqd->in_serv_last_pos = 0; } /*