Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7687342rwb; Tue, 6 Dec 2022 08:40:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf6e81sOCRJyEPVDQD5zyTOev/Xsw5wo8rkIg4wk8Bfw0NPisdAZYwHZrw37pnufvpRo9Xpn X-Received: by 2002:a05:6402:28c9:b0:469:ba7c:bc75 with SMTP id ef9-20020a05640228c900b00469ba7cbc75mr4418645edb.286.1670344802520; Tue, 06 Dec 2022 08:40:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670344802; cv=none; d=google.com; s=arc-20160816; b=aTNWPgkbCpv9P37SjQ2k6a+tQF1K+zSJGwkJmP0BicpRYxYSDl4BIa7PrqeqPFKkGf DVqMBXTDAPr/Hg1orUmYbKi0pnXmmwk2V59zeOV+WxIf3W0m1Bl22iDkNkhebs0+ED8k sGARyOlMHAWYhf3BbCRycq43aKwmD3wDHOAw+3T3CM7FvTi4IThc/x2B3012jx7GZbGF CuU1rqpZfaMaVxnhy5+whUF+8nX8otBbIvAm6tRww1BwosJd1wOxn40EUawe8lwBua0r sE+TaHlBUfOgoM3nCERpioKR3UDr5MzEEq3EakwsrZXkBgfW5/3GoQyfKPHbaFFwQsB0 /02Q== 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=ZY/PyYvl5yef9dzUBwOoFODLyiHOEVf2zJot7jAU88w=; b=mTlr16cfUwAgl5QYRoCQaFA7LDnomCqg1zg/ht7/LqJsPMNLK2/IpMH3oFrgpIqwyF jkwOYJPyQIeKHIha2hTmfNRXEUJNyfeRDmBhoGGzu7jJZIIlETBMdY0gYQEuVNbihZm/ vTzNe67sVS0S6Sh2EoKmgnsfXt3Z8QQ2FJk/fDHFeWt6vzl7JgeGaTNz2sc2l0MH/Dmq vGUbJbWs2kW9b57IXCxa3UnnYu3YRk4GHx04nFr/xWlrsg0jjopCSs1DnXr70r6Chtgq njHnhCQpeYVxyd66jZdTu/2coZ7Qg3Ex2yz0OHq1LKg5OxCumUYHZUgUIuEd45SrJn4U A1jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DSKhn7CI; 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 e17-20020a50d4d1000000b004623028c586si2276318edj.141.2022.12.06.08.39.43; Tue, 06 Dec 2022 08:40:02 -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=DSKhn7CI; 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 S235481AbiLFQcj (ORCPT + 77 others); Tue, 6 Dec 2022 11:32:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235264AbiLFQcT (ORCPT ); Tue, 6 Dec 2022 11:32:19 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D94972F002 for ; Tue, 6 Dec 2022 08:32:17 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id n20so7657880ejh.0 for ; Tue, 06 Dec 2022 08:32:17 -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=ZY/PyYvl5yef9dzUBwOoFODLyiHOEVf2zJot7jAU88w=; b=DSKhn7CIMJB3E1zujAn8BZChULAiSzolcGsUHfl4zoMFGsNHAn3KYkSFAa/o+1gRBI OXovq2jiPdKVZbdIYL4vDCcSQT69md8e2Y2TOcXdNqct45reVYw8oXOGEhhOdJWUkxQF 3XenC6+47ubOOakXAI1nw50YvkdUB5u8FU+k7MszNAeUYeze+ZP4EXnx1MQlI/aKzU/u NDoMPENA4hCCnzKI7eevMAtuCffWBoyMcqoWHcj8HiDTAgP7JDiDkQ5G1U3z9QlazkFw RmK3VCEXq5yzYcP5hn376MNUHVckSKrgygSFGNM5oCqOPfh3ngh+TSCeLwm6S7Vh0cMg Mwyg== 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=ZY/PyYvl5yef9dzUBwOoFODLyiHOEVf2zJot7jAU88w=; b=JnUjZWB0rDzAvsgLOZumRRx8ZwrQMVKHWwhTxdtg0O34UsacCe294t7GN0p0se9vPN EeWoEIddtBTZlvzeOY886VaZysbU1ZL81zHSxM4Sj86AcNyWST44c1D6zeQk1FUcqcpJ xOsCeLlE+lf6LLNQHUAcw7mAxAc8Zg40UJm0uGSMY41CcSwVsBvAw7iymrR3EKeZMgSZ AEPaXnOu4MIbRcLgeIhUyfu9X/4pq8JkHRMBiVgaeI0BNhRVSCRfYhsEQJRWpSIsiBpz wMBOHGoyLIsV430cV3LmnhIQSU8+sRO3czm9CqXV+E814lU/xSJyDS0BR7GnH4rCNSTF 9pcg== X-Gm-Message-State: ANoB5pkw+bCoR2bb5rjlMDEGYLJ1yznhbSBMSXOBnLf6MO92wgutZcPp t14XBbs5+qC3JXBRDHREa/wM7g== X-Received: by 2002:a17:906:1713:b0:7a3:fc74:7fb4 with SMTP id c19-20020a170906171300b007a3fc747fb4mr77082586eje.17.1670344336430; Tue, 06 Dec 2022 08:32:16 -0800 (PST) Received: from MBP-di-Paolo.station (net-2-35-55-161.cust.vodafonedsl.it. [2.35.55.161]) by smtp.gmail.com with ESMTPSA id t5-20020a056402020500b0046ac460da13sm1170104edv.53.2022.12.06.08.32.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Dec 2022 08:32:16 -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, Federico Gavioli , Paolo Valente Subject: [PATCH V8 6/8] block, bfq: retrieve independent access ranges from request queue Date: Tue, 6 Dec 2022 17:32:01 +0100 Message-Id: <20221206163203.30071-7-paolo.valente@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20221206163203.30071-1-paolo.valente@linaro.org> References: <20221206163203.30071-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=ham 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: Federico Gavioli This patch implements the code to gather the content of the independent_access_ranges structure from the request_queue and copy it into the queue's bfq_data. This copy is done at queue initialization. We copy the access ranges into the bfq_data to avoid taking the queue lock each time we access the ranges. This implementation, however, puts a limit to the maximum independent ranges supported by the scheduler. Such a limit is equal to the constant BFQ_MAX_ACTUATORS. This limit was placed to avoid the allocation of dynamic memory. Co-developed-by: Rory Chen Signed-off-by: Rory Chen Signed-off-by: Federico Gavioli Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 53 ++++++++++++++++++++++++++++++++++++++------- block/bfq-iosched.h | 8 ++++++- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index dcecba3c6e23..a5361c287657 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1839,10 +1839,25 @@ static bool bfq_bfqq_higher_class_or_weight(struct bfq_queue *bfqq, */ static unsigned int bfq_actuator_index(struct bfq_data *bfqd, struct bio *bio) { - /* - * Multi-actuator support not complete yet, so always return 0 - * for the moment (to keep incomplete mechanisms off). - */ + unsigned int i; + sector_t end; + + /* no search needed if one or zero ranges present */ + if (bfqd->num_actuators == 1) + return 0; + + /* bio_end_sector(bio) gives the sector after the last one */ + end = bio_end_sector(bio) - 1; + + for (i = 0; i < bfqd->num_actuators; i++) { + if (end >= bfqd->sector[i] && + end < bfqd->sector[i] + bfqd->nr_sectors[i]) + return i; + } + + WARN_ONCE(true, + "bfq_actuator_index: bio sector out of ranges: end=%llu\n", + end); return 0; } @@ -7160,6 +7175,8 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e) { struct bfq_data *bfqd; struct elevator_queue *eq; + unsigned int i; + struct blk_independent_access_ranges *ia_ranges = q->disk->ia_ranges; eq = elevator_alloc(q, e); if (!eq) @@ -7202,12 +7219,32 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e) bfqd->queue = q; + bfqd->num_actuators = 1; /* - * Multi-actuator support not complete yet, unconditionally - * set to only one actuator for the moment (to keep incomplete - * mechanisms off). + * If the disk supports multiple actuators, copy independent + * access ranges from the request queue structure. */ - bfqd->num_actuators = 1; + spin_lock_irq(&q->queue_lock); + if (ia_ranges) { + /* + * Check if the disk ia_ranges size exceeds the current bfq + * actuator limit. + */ + if (ia_ranges->nr_ia_ranges > BFQ_MAX_ACTUATORS) { + pr_crit("nr_ia_ranges higher than act limit: iars=%d, max=%d.\n", + ia_ranges->nr_ia_ranges, BFQ_MAX_ACTUATORS); + pr_crit("Falling back to single actuator mode.\n"); + } else { + bfqd->num_actuators = ia_ranges->nr_ia_ranges; + + for (i = 0; i < bfqd->num_actuators; i++) { + bfqd->sector[i] = ia_ranges->ia_range[i].sector; + bfqd->nr_sectors[i] = + ia_ranges->ia_range[i].nr_sectors; + } + } + } + spin_unlock_irq(&q->queue_lock); INIT_LIST_HEAD(&bfqd->dispatch); diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index 1450990dba32..953980de6b4b 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -810,7 +810,13 @@ struct bfq_data { * case of single-actuator drives. */ unsigned int num_actuators; - + /* + * Disk independent access ranges for each actuator + * in this device. + */ + sector_t sector[BFQ_MAX_ACTUATORS]; + sector_t nr_sectors[BFQ_MAX_ACTUATORS]; + struct blk_independent_access_range ia_ranges[BFQ_MAX_ACTUATORS]; }; enum bfqq_state_flags { -- 2.20.1