Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp3801123rwj; Tue, 20 Dec 2022 02:00:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf6DKai2J5pLnQruq+CD09YpqcGKib95k3Xz1QkQnpCAucoUk4ULYNLDWLZA6z5FsW9rmlze X-Received: by 2002:a05:6402:5489:b0:45c:b772:5f41 with SMTP id fg9-20020a056402548900b0045cb7725f41mr24371607edb.6.1671530433417; Tue, 20 Dec 2022 02:00:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671530433; cv=none; d=google.com; s=arc-20160816; b=xkcNod+AgfsFO3zjo3GqszKvyfvo2VEfW68OtXdAVlBWnEPnIVOLfIQdRsqddMEqPC nC4Wzj9Ez7pLiabfWldur/vPcY1DejL5cr/qeI8y10hsU27ZTzo0qK88HHbCUtihmPUx 4yklj33FcatJppftUMdpyqN/XQaGLp/gr1IeYzsLz5fzJ/eeAUj3WOAW/OUQ+6TIHKcP zyYfyZf+M9nUHUudhOjBJu7kqYvPTAzyUfTm0IRXJ7K15FbCIs5QjqNTETeVag02LRY0 kRO9fvbOIlAsm5t1IT01IPQW04+LjaMfabtiBVjJ1qMf5fC5uPlOYOCjXvcFeFCRSLp/ 6uIg== 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=a6f73+YHTJQykJufXIjZA/+0gS/Nfl6E3ZObMwo3qtk=; b=ERWqG3YoP3GUIoAYYDw4wiioImXu+EgX+UMwf9Mw4hGU+Fyn5DqeCVUfyhm3MR0EjJ oH78UFBvWDUnF4BbRIBWPYdXvDl5ZMOj900ZCbJdrsjioqzghwriAGt/8WHE81zMNO+b YNaU22xg9+j9y1OOxXtTIhhNjH5CKAIvR8fEXd632XBpA3sXpDoXbMrXQLsrH7lm2pb7 4lTydeM+t6M6rH8WlxnEcnLt5Jgg2PhGKREz9XB0CmMfVT+r3fIviW4CxCts5ZC+sBSo hnzlAn6qwGhiEu4hM4qhYrf6Ekbx3R29qiMTB7uNdU8qZW9PvMgf17/m9Jxb1Me8g7a+ W1dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F1uMrTgx; 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 dy28-20020a05640231fc00b0045938ab7129si10103178edb.330.2022.12.20.02.00.16; Tue, 20 Dec 2022 02:00:33 -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=F1uMrTgx; 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 S233669AbiLTJvP (ORCPT + 70 others); Tue, 20 Dec 2022 04:51:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233496AbiLTJub (ORCPT ); Tue, 20 Dec 2022 04:50:31 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69EA616491 for ; Tue, 20 Dec 2022 01:50:29 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id t17so27960439eju.1 for ; Tue, 20 Dec 2022 01:50:29 -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=a6f73+YHTJQykJufXIjZA/+0gS/Nfl6E3ZObMwo3qtk=; b=F1uMrTgxRRMp2xyZg0nhUleuH6jq8e0xlB/88+md9uJBG1C7mm74KNiWy+eipB1s+J It3d+7w2J0GcxY2iJ97ioGgUZUHXZQo5+6pWB5Vo6Yoqw+04mNBk5+3GkECRVrwfH/Ue la+DLsE7cCaleYyTd1oLFr5U9gRpGLZobWx4WrSeTNKq3RFSqB3W4M0/Uz784YhpRq8E KakK4gTsHQzx5LueRPoD3hCEA0PJjBWqhJEZ9DN1761RcSqu4PQfES0qgeQTpo2d5ugr 4lTiNtowHY6zx+GYqKfdfQIQFs1rh9wI7TuJglAxShzs0USsFRHOkkJLIem6cnNsncXn pfZQ== 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=a6f73+YHTJQykJufXIjZA/+0gS/Nfl6E3ZObMwo3qtk=; b=e+eBwpzoP8Czu0yRe5dT/GpoSTx/uRMJeDRc23O13+3jPoPsk5NWG60nNrlEfsI4+k msJNATx8P/uti47LpgzSNiwZIm+Ed9mlBOUX7UvDHuI0ktyyzHDHLkOJ+dzywkkyJKKB YgPsFCG9OMfKzZG0ezDfDIsZMhkxu1eRUv6mgHA1oE9tqzMX9rFIh2ad6EgBkYGpIux2 4Kta5pKZPn+HL2JGYr3YxlfuQzPBnWQhcMle9DRruMI7y40Co8itZYDXv1UqxBy/15e/ GYpFcopsPSHuwORKM5QSjrECRBx9XVn2eVj/4yPSu2mKsesQhK1VBGV/ESzPNTXDJG+a FB2Q== X-Gm-Message-State: AFqh2kqKySalMxYiZu53LvNbvX3DFrCtt/T38WwiiADVBmB219Am1AJW Vbqs1UWCHtCqihWja7dFCCJ9JQ== X-Received: by 2002:a17:907:c688:b0:7bb:af66:f38c with SMTP id ue8-20020a170907c68800b007bbaf66f38cmr8667138ejc.10.1671529827958; Tue, 20 Dec 2022 01:50:27 -0800 (PST) Received: from MBP-di-Paolo.station (net-93-70-85-0.cust.vodafonedsl.it. [93.70.85.0]) by smtp.gmail.com with ESMTPSA id c2-20020a17090618a200b0082ea03c395esm1669207ejf.74.2022.12.20.01.50.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Dec 2022 01:50:27 -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 , Damien Le Moal , Paolo Valente Subject: [PATCH V11 6/8] block, bfq: retrieve independent access ranges from request queue Date: Tue, 20 Dec 2022 10:50:11 +0100 Message-Id: <20221220095013.55803-7-paolo.valente@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20221220095013.55803-1-paolo.valente@linaro.org> References: <20221220095013.55803-1-paolo.valente@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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. Reviewed-by: Damien Le Moal Co-developed-by: Rory Chen Signed-off-by: Rory Chen Signed-off-by: Federico Gavioli Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 59 +++++++++++++++++++++++++++++++++++++++------ block/bfq-iosched.h | 8 +++++- 2 files changed, 58 insertions(+), 9 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 06078ad78835..2774e96c73d2 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1787,10 +1787,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; } @@ -7100,6 +7115,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) @@ -7142,12 +7159,38 @@ 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; + } + } + } + + /* Otherwise use single-actuator dev info */ + if (bfqd->num_actuators == 1) { + bfqd->sector[0] = 0; + bfqd->nr_sectors[0] = get_capacity(q->disk); + } + spin_unlock_irq(&q->queue_lock); INIT_LIST_HEAD(&bfqd->dispatch); diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index 72bf69af239b..fbc6f63a62e1 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