Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2479889pxj; Sat, 19 Jun 2021 13:41:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpgAAdaYnBnEBv1KXz67aX07GxxEcvV47bhUnjQaSwnwy1mAs/icAZ2fMOUalbLj3dYcHW X-Received: by 2002:a17:906:128e:: with SMTP id k14mr16741384ejb.485.1624135297453; Sat, 19 Jun 2021 13:41:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624135297; cv=none; d=google.com; s=arc-20160816; b=wA72vjU8n1VZGDHcKM2A6/2RY3/JUl2i023sVkzwg/Jhk+7p6GlhRnaRmi/qRbJOkN RarHkkHMtWgURQQi2bF1FmMhN+O5uU18VHw60oKOtsJaoP+m4XLAjzu4yr5zi+cSELEK uXvcS+zMbABWCytte6Jg/OImAl5O5ad+61my+/j1lGIxDfa2Rmd+v7TpziLTzosqxfIo oCJ+pkFx7NJTIs3vmNabUYYzCXXqCjUE0vDNY58t1dAWh2TTke1e1mDSFKCMGDiEOG8o 2GYxTBK74b+nX6xCSuyZ75/LbEu7NbpISrN2F0eUmpzziP0htHEr8W3OwwJSNXAbdT8Y 9zHA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CUWJdjp8QRxQ/u+DTP4tjJp/xb4db7Dn4angKhvJAxI=; b=mg+s39TdwZ9FM/cePhwlMaGWbaxE8AJbNv7yt1PuIxUfuvch+RrmX8v3cnw7ckJKEp nYWWfBIP4Nu2QLBjTG9LCzaL6J4+4KZLChwxMzZnImMzHnMmBX9KFsY4JRCPRG2kzuXY GFC2h2K64xdNRKQWImnjRPETKquEXgbyK39MDPaIon+gPLKLP5cEzWXKFIfhwEWr6Gqq Ngotbbay2u97kpDpiD+0BS6tgh7MS1uKW302WilMkn0d7S3vfP/NqtK4qaPFXZdkYfLn Xc0J5eYu6kQkXJGkaYwQP0VGOQ/8t32Z3VHShdC0H8i9fycX8LagVZ3+1aNrDrtdxAUC y5WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vrWLuh4K; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bf28si11979841edb.224.2021.06.19.13.41.15; Sat, 19 Jun 2021 13:41:37 -0700 (PDT) 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=@linaro.org header.s=google header.b=vrWLuh4K; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234463AbhFSOMc (ORCPT + 99 others); Sat, 19 Jun 2021 10:12:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234275AbhFSOMV (ORCPT ); Sat, 19 Jun 2021 10:12:21 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A15F1C061756 for ; Sat, 19 Jun 2021 07:10:09 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id e22so10554972wrc.1 for ; Sat, 19 Jun 2021 07:10:09 -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 :mime-version:content-transfer-encoding; bh=CUWJdjp8QRxQ/u+DTP4tjJp/xb4db7Dn4angKhvJAxI=; b=vrWLuh4KzKECdtkDHypvz5aUkJHB2FxS7IccXvXbvXhnwl7wr9nEmx7dapAGxWXyOq POFNHr2tl3dK9ORgnPTsymDwYi8iFXRhxL43cezdIhFvuJkE4dVkO+NNgAMMooWcHwST Cdyjkbwz2XyPFthDYvPr2C8xtTM8Gsz7BYPht8+2eMemoQz365pJMEgmvtz0NEneDtsT Wqa++GYLzRNIAGYXEiymcfiPZDQkU/QHqKWMESTvT9HeLzgw/HOzz79ynvRuDoskygUm PsTLzVkm785MAEsuVWWeTg/chW9vYY/rBy9CFFrEcYcp+eriKGvrgV1KkFFcV45CJVGg /+Tg== 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:mime-version:content-transfer-encoding; bh=CUWJdjp8QRxQ/u+DTP4tjJp/xb4db7Dn4angKhvJAxI=; b=eGM24rie6Hoz6z6Ney8DsdD+vNg+Ma68Fl2KojQIZRUI5nY+k1sBQUkWwwFLV/YlWx Tkzun+2e+XV+V0TnrtTHZJdkYBvm9JDWF4BiWKyRFHyxfrGwBUJp7Km1vBQLb2EfLEPX 1w6AcsRfFmJ0qtYb298HARhuYgW+hD8ZkudtMiYIp8VfUGlnpe8I5D8Ppud4WQo8zb7W cXwBr7IBubAsfeR8IKKyp9uXXm7UWcw6jo8xcblnM9g+1WYJDT5Bs24sumWxsCQQGQim au++iLnx3VyyKVpx1VZMiHj8MtfBg0lwrUPnWYAAw4okXs039vYy+H9zuPVfJsSNBaUj sqwA== X-Gm-Message-State: AOAM530ZkbQRPd1aMkPmJ+g6DDfeHiR3AlsxuI30Sjjhlo5rFOc81NMi NtEjaCwJJYP45pmnaR+0J3B+jw== X-Received: by 2002:a5d:59a3:: with SMTP id p3mr18451225wrr.284.1624111808195; Sat, 19 Jun 2021 07:10:08 -0700 (PDT) Received: from localhost.localdomain ([83.216.184.132]) by smtp.gmail.com with ESMTPSA id y16sm8379350wrp.51.2021.06.19.07.10.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Jun 2021 07:10:07 -0700 (PDT) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, mariottiluca1@hotmail.it, holger@applied-asynchrony.com, pedroni.pietro.96@gmail.com, Paolo Valente Subject: [PATCH FIXES/IMPROVEMENTS 3/7] block, bfq: consider also creation time in delayed stable merge Date: Sat, 19 Jun 2021 16:09:44 +0200 Message-Id: <20210619140948.98712-4-paolo.valente@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210619140948.98712-1-paolo.valente@linaro.org> References: <20210619140948.98712-1-paolo.valente@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since commit 430a67f9d616 ("block, bfq: merge bursts of newly-created queues"), BFQ may schedule a merge between a newly created sync bfq_queue and the last sync bfq_queue created. Such a merging is not performed immediately, because BFQ needs first to find out whether the newly created queue actually reaches a higher throughput if not merged at all (and in that case BFQ will not perform any stable merging). To check that, a little time must be waited after the creation of the new queue, so that some I/O can flow in the queue, and statistics on such I/O can be computed. Yet, to evaluate the above waiting time, the last split time is considered as start time, instead of the creation time of the queue. This is a mistake, because considering the split time is correct only in the following scenario. The queue undergoes a non-stable merges on the arrival of its very first I/O request, due to close I/O with some other queue. While the queue is merged for close I/O, stable merging is not considered. Yet the queue may then happen to be split, if the close I/O finishes (or happens to be a false positive). From this time on, the queue can again be considered for stable merging. But, again, a little time must elapse, to let some new I/O flow in the queue and to get updated statistics. To wait for this time, the split time is to be taken into account. Yet, if the queue does not undergo a non-stable merge on the arrival of its very first request, then BFQ immediately checks whether the stable merge is to be performed. It happens because the split time for a queue is initialized to minus infinity when the queue is created. This commit fixes this mistake by adding the missing condition. Now the check for delayed stable-merge is performed after a little time is elapsed not only from the last queue split time, but also from the creation time of the queue. Fixes: 430a67f9d616 ("block, bfq: merge bursts of newly-created queues") Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index c5c0e74977d4..2a5c1a660f3b 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -2711,7 +2711,9 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq, if (bic->stable_merge_bfqq && !bfq_bfqq_just_created(bfqq) && time_is_before_jiffies(bfqq->split_time + - msecs_to_jiffies(200))) { + msecs_to_jiffies(200)) && + time_is_before_jiffies(bfqq->creation_time + + msecs_to_jiffies(200))) { struct bfq_queue *stable_merge_bfqq = bic->stable_merge_bfqq; int proc_ref = min(bfqq_process_refs(bfqq), -- 2.20.1