Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp377919pxb; Wed, 3 Mar 2021 05:43:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/p3DbcYpHbOuJSgKpmF+wJ+5Xc1g9aCBpRyqitJ3kj+EdyKcTDT2pJ3gkglAhOXHHNBa3 X-Received: by 2002:a05:6402:3049:: with SMTP id bu9mr19250933edb.104.1614778984586; Wed, 03 Mar 2021 05:43:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614778984; cv=none; d=google.com; s=arc-20160816; b=gT9jjf0+9AFBgbFAM8EAONPjiVJozGIKdh6y5Ijb+c3hSbG23cXX6Ds3Wizw/6rjmh kCcJRQQqMFYFdO/Sd4Kgx/qmrUDfkf8PUM4Z+QzoeRIGx7P2psQbqZppVgExaL/TJ/eW gjybJwaBE5gpc+o2beCLw4hjkG67AIgXsb8nVnPJ2sVY4GHX9RVAbmtMoQ/L58S5n17s 6cAfPIQLjWGUNeXRmGQg7aBW9kZreolEY7Rx6QTze4c1FFo2iASPDMxusdJZ0x6ClhVL FMkA/6d0upCLFGfjAp7+pUz690xxlTkYYjlJ5pi6Djxw/snatANMmsxdWQ9WTT4lf6KN 4WgQ== 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=oT0CIHr1FpJb/ss6iv977BpLUEEotLtZzNsMhR43QBo=; b=weytECX8p8LkvtTD0PMuUGhep9qaXIUVSvXGOgA4DjWkuefRWiuHzFPe9peiB0S0rE mObLLq1PseaCQ5WPyN8poy/VkVtMBCZsa8l97j32GHup/XDkLuh6mtvBsNtpMJ8aRRTO gt7PblPNXTsbflugEV/p+fJkiOMyLM4M0tI246KKsO65csfJsRA372PIdgMiXdtkhx/K c9WNZRhQCgDO4CZzpiZ5brXrG+JT6x/Q9k/8nhEyd9mMXu935IcX2GOeMKBjckT6LQNh egb4rt9PDTI014I5scLi4EsajsDfSPLZWGu2VBB/P4i+fMIfdmDNkCOdqnFhNxGzmnva QiFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="10MoDf/K"; 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 u13si13935106ejc.243.2021.03.03.05.42.26; Wed, 03 Mar 2021 05:43:04 -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="10MoDf/K"; 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 S241634AbhCATts (ORCPT + 99 others); Mon, 1 Mar 2021 14:49:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:55906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236498AbhCAQ4X (ORCPT ); Mon, 1 Mar 2021 11:56:23 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5406864F67; Mon, 1 Mar 2021 16:36:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614616570; bh=wa5WwL4ujE9xMBQs3s+u53yRlpctXDv311lft8wVMn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=10MoDf/K8wnJc8HMiZvA4HqcM/gqdwURRIaInsHU16MDgK7EjI1k1jg1qcyOdCPTP IQsG9L4HsKVyhXhKRyaT6IU56jzhSfbT1KVQjrxXf4tuyNnaPJ39rjlr0r7z4VB/uT /Hewwp65VKH7uJxq8wFo4UOd3LkAXJH6r54ANXBs= 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 4.19 020/247] bfq: Avoid false bfq queue merging Date: Mon, 1 Mar 2021 17:10:40 +0100 Message-Id: <20210301161032.688648140@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@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 @@ -2478,6 +2478,7 @@ static void __bfq_set_in_service_queue(s } bfqd->in_service_queue = bfqq; + bfqd->in_serv_last_pos = 0; } /*