Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6442760rwl; Thu, 29 Dec 2022 13:00:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXuY/HcRFLuEaUJtuYlf0habmORBO5OLhSMRKvh3tbmg/7IYEc8bC5J3ZYrstckpX/Qwmj3A X-Received: by 2002:a17:906:380e:b0:7c0:be5d:59a9 with SMTP id v14-20020a170906380e00b007c0be5d59a9mr28621500ejc.20.1672347654644; Thu, 29 Dec 2022 13:00:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672347654; cv=none; d=google.com; s=arc-20160816; b=WKuJiDlIddf4VPmM4NFnxR6F0/usB1104o3TQRTimpF59yvrZCDx90x71Cp2DdNX3L eDDMf9eXACylsk9/VOWRZrob4M0MuGZF7vKsOE0QQVki1qIQPenHXDsKr7V9dsJ6XDvk lFxhAurla+Y1ovuKX1xPecxYnQyNV1jC0XZ8VzzL9z5AIvxGLNTxDBwS50M4Mp/PhWER NRiLI3D+/I4b75V45AEb7rwMzvQnknnFDyJeuwCnECocjXGcPnxDIbTrHSFe15McCZlu Eu5t7sqLlV/rngbbN+cxqJeARzHs52RRLFhyu3hboH28o7J3mFvbKB/PLP79mzWwMKz+ hWug== 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=9zlPY0Un+v49wAp4Agod/FVz6SE5LhUB8HuWcFquXnc=; b=pbAQJaOMZXDY8bC9yH0j62jdBQ0UADK6R0EiaF5aA0RZ6kq93xLHxtRxgsjxz5J95t fZbYT0Ca6q70SZywiNOhXkWhvHLZRnRKDyetl7P4tXcgCG3lt8TBIv/CjLQg7tpphd/8 y0F+tvjseTQd//LI0TvoDqr553z89um28gu5zrw+xVwB/X16fQZHQHZL+Bmworz6YrSR ht4eFtYR5X1ZaWQduBhmDbVvP1MzCYks15RdxRw5Lnstd3tTwjHQI/ygB6mBccO9t6Ex jCtCY7XVZHqbzzPnqlfqGkunjHnuXkWxTo/2pqP9bi9KKGzHAoca2BMoQVQmcgvQKra9 yjkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sdpJY2+N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb30-20020a170907161e00b00730a4246dd0si17435680ejc.593.2022.12.29.13.00.38; Thu, 29 Dec 2022 13:00:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sdpJY2+N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S234057AbiL2UiY (ORCPT + 61 others); Thu, 29 Dec 2022 15:38:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234063AbiL2Uhw (ORCPT ); Thu, 29 Dec 2022 15:37:52 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24E1B167FB for ; Thu, 29 Dec 2022 12:37:51 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id u19so47361323ejm.8 for ; Thu, 29 Dec 2022 12:37:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9zlPY0Un+v49wAp4Agod/FVz6SE5LhUB8HuWcFquXnc=; b=sdpJY2+NyUmLkfu+69Bgwa7d+tcwQGa4x1nj/LQ5dFbmRDTboBYdKioPr/sVUeIltu BnYk3KOvv6XfK9pMHkcsWdKAFwrS16GabcsrkUj++Os0adepdMfqThdiWJq+5j2G6p4p r7lEaCONi81KIIQAYX6QfVrMQp2NUQuKjpON+wA7Gco1Xj2/wSwzpE2IGm1zndSlI54U QAMofPprAxaBIE5Ei0ccCoinDXYE/w9FbQXsVrYNXUsr9mt6mfEctD5x9sb1XWAH1sbd ij1ROss27WN+HRInA3raMHsx/RqQd/QPgh6XLSFb8mqnVNjmxXK15/NVh9yFyDN1MZHX uEwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9zlPY0Un+v49wAp4Agod/FVz6SE5LhUB8HuWcFquXnc=; b=TRaZjq6xLwDt8AVuF/301Tuqk4/mPzME7dtdPabXG8H7y7gjrjtaYmDOd+u4jhm8rF MVA22GRUO6P3juF0MEsfPV6R3oq5Y3Sug0Wm4+q/JN0+x9NKxMiP1EfAcPW7vXa1VSzs zpoYK1oYhuoQ+WSguLLVRUEKaEZWCA1V3GcEXUcLEFxVtDfsaWbHpqvzOq6xhIa6a4Fu oWnwxcSqih2e9epdw4wxs/Q88tNg+JJvL9FCzWM2ruf65KTkP2oTosBpAd5qXeXBZnRH cHiRwGCWM0UuczQ642iUS4KpEUDPaOncekqcHd9giFkXTyYYfu5RuuyPyj/a5qllvrnK J7Sw== X-Gm-Message-State: AFqh2kpJgZ/wVErxZr+uqQsjr5DlDjz/wXsxFBVj34FSv8dySZa8hFaF poi2DR+GlqC49W7UXsXPUaZ0yQ== X-Received: by 2002:a17:906:8517:b0:7c0:a48b:2dff with SMTP id i23-20020a170906851700b007c0a48b2dffmr30315702ejx.43.1672346269647; Thu, 29 Dec 2022 12:37:49 -0800 (PST) Received: from localhost.localdomain (mob-109-118-160-216.net.vodafone.it. [109.118.160.216]) by smtp.gmail.com with ESMTPSA id d16-20020a170906371000b0073d7b876621sm8872814ejc.205.2022.12.29.12.37.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Dec 2022 12:37:49 -0800 (PST) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, arie.vanderhoeven@seagate.com, rory.c.chen@seagate.com, glen.valante@linaro.org, damien.lemoal@opensource.wdc.com, Davide Zini , Paolo Valente Subject: [PATCH V13 8/8] block, bfq: balance I/O injection among underutilized actuators Date: Thu, 29 Dec 2022 21:37:07 +0100 Message-Id: <20221229203707.68458-9-paolo.valente@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20221229203707.68458-1-paolo.valente@linaro.org> References: <20221229203707.68458-1-paolo.valente@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Davide Zini Upon the invocation of its dispatch function, BFQ returns the next I/O request of the in-service bfq_queue, unless some exception holds. One such exception is that there is some underutilized actuator, different from the actuator for which the in-service queue contains I/O, and that some other bfq_queue happens to contain I/O for such an actuator. In this case, the next I/O request of the latter bfq_queue, and not of the in-service bfq_queue, is returned (I/O is injected from that bfq_queue). To find such an actuator, a linear scan, in increasing index order, is performed among actuators. Performing a linear scan entails a prioritization among actuators: an underutilized actuator may be considered for injection only if all actuators with a lower index are currently fully utilized, or if there is no pending I/O for any lower-index actuator that happens to be underutilized. This commits breaks this prioritization and tends to distribute injection uniformly across actuators. This is obtained by adding the following condition to the linear scan: even if an actuator A is underutilized, A is however skipped if its load is higher than that of the next actuator. Reviewed-by: Damien Le Moal Signed-off-by: Paolo Valente Signed-off-by: Davide Zini --- block/bfq-iosched.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 6ebcd94bf3b3..f729f51fd383 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -4767,10 +4767,16 @@ bfq_find_active_bfqq_for_actuator(struct bfq_data *bfqd, int idx) /* * Perform a linear scan of each actuator, until an actuator is found - * for which the following two conditions hold: the load of the - * actuator is below the threshold (see comments on actuator_load_threshold - * for details), and there is a queue that contains I/O for that - * actuator. On success, return that queue. + * for which the following three conditions hold: the load of the + * actuator is below the threshold (see comments on + * actuator_load_threshold for details) and lower than that of the + * next actuator (comments on this extra condition below), and there + * is a queue that contains I/O for that actuator. On success, return + * that queue. + * + * Performing a plain linear scan entails a prioritization among + * actuators. The extra condition above breaks this prioritization and + * tends to distribute injection uniformly across actuators. */ static struct bfq_queue * bfq_find_bfqq_for_underused_actuator(struct bfq_data *bfqd) @@ -4778,7 +4784,9 @@ bfq_find_bfqq_for_underused_actuator(struct bfq_data *bfqd) int i; for (i = 0 ; i < bfqd->num_actuators; i++) { - if (bfqd->rq_in_driver[i] < bfqd->actuator_load_threshold) { + if (bfqd->rq_in_driver[i] < bfqd->actuator_load_threshold && + (i == bfqd->num_actuators - 1 || + bfqd->rq_in_driver[i] < bfqd->rq_in_driver[i+1])) { struct bfq_queue *bfqq = bfq_find_active_bfqq_for_actuator(bfqd, i); -- 2.20.1