From patchwork Thu Oct 20 15:26:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 6258 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp174140wrr; Thu, 20 Oct 2022 08:29:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM44kJwKpLNnk8tn22zjMBtOs15fhKkCZ4UaPH9Sj9lHkn3JNo7zz3Sl8XwupszbFMgVlNIg X-Received: by 2002:a17:907:2c4a:b0:78d:ee99:a06b with SMTP id hf10-20020a1709072c4a00b0078dee99a06bmr10986263ejc.578.1666279795952; Thu, 20 Oct 2022 08:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666279795; cv=none; d=google.com; s=arc-20160816; b=VpQKGYYInFfYbS7t4js6yAqABfMDT6Fw+eSyk35NeKn2lZ+J0r9EwScYm+ldAunuIM DD0wqGixWjEobYjuiCif6Is7k8IFI+gmXAf5IAXtdSIbGiIwClH1QF/WI1Fi1xBQeNr6 iCOtDHHMHN61nk+Kxphol1nA3eD1rpaBC5tzsOZ1MR12LYFoozshbjU1nT3+zNsAWTT8 Lc/W9RnY9NnZ9xNIJi81Za31JJ1kKiS64mQ+7Bv7elE3PMmeYc+cZGvP1Q/hosHIB8kq wtN8sAWRE2AqE5DkWDS/GKiYE0xwGQgObUlycGp+G/oGul84NJQXVgYaf9LuokjMb3eO NBAw== 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=VYfAQbFPbPuWxP8oBowD8Zx074eHcmT9s7z7LBjxk8g=; b=pq1/I9B2e8GPPanW0hq2T5q+DAIHuSFxf5RsYQXE3aBD7yl3r0cYMD8V3FXuc3G2Z4 QYKrkH4LO5oPe2vpJt5bhzgNeRYE4ozprqRF3NYI9OisaBZZuzhBGNq6sXPPPu7Wf76t bXJcv+agEw+Y10qyW31G2YcYagJAScuXuPjMwhUZxleFv7NUlmf3J9xX5sXhAoyAI0ga gHiyg1N5u5SDPwB0PqJ4ABmNXoCJYa5oycOyi3U872neo5EZyJXUTtJoRg1W8oBhlSdl kCYVO1aTrSQHbILKnOxWNrLT+4ws+rlPWDZ3FWZSmlZP1tdUcrNO5oEqqnM+JJ44KNnB OdwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x7nyCWzb; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f15-20020a056402068f00b004587df44110si14316592edy.151.2022.10.20.08.29.11; Thu, 20 Oct 2022 08:29:55 -0700 (PDT) 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=x7nyCWzb; 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 S230440AbiJTP1l (ORCPT + 99 others); Thu, 20 Oct 2022 11:27:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230010AbiJTP1U (ORCPT ); Thu, 20 Oct 2022 11:27:20 -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 AD2571C6BE1 for ; Thu, 20 Oct 2022 08:27:14 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id a10so35051049wrm.12 for ; Thu, 20 Oct 2022 08:27:14 -0700 (PDT) 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=VYfAQbFPbPuWxP8oBowD8Zx074eHcmT9s7z7LBjxk8g=; b=x7nyCWzb/g0xaRw8Sw4ioqnvViRmpZC5TFCaUE3mceNp8hrtqM72tSSnIhwfp4gYSS wMpWscagUxxB8ypNoJAX1zaEtPIbXnLAEpGtqU/w5TngbPsCyVJiuYlVFYOwT7EXYyY/ 9iQk8cpnwJFA//EPh7XEXiM7OPqyN4ZrKUx+50JpPCMvqB6Qlwrh+kvk2ALXQML52LlP HECkoxoM55g43K1iHzGt/nb/+sWPIH1ghUuVjPuuIVVaKmKbSZqBNa9QTIj7jBoaC5XP iTWrpyQdWAk/2JcwgeqHx9kfshE9sVCMc2A5qS3xJmbrIOe+HIT09IPmdTnMNAVqRWgr pPCg== 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=VYfAQbFPbPuWxP8oBowD8Zx074eHcmT9s7z7LBjxk8g=; b=VYQEAuVkj7znau4VgeajDpJmW0TPPs6VkSVFviURogx/7Cbl6YMsuujaA99uog0TeT b9Ke0BJ4EfFWY65J9Z/Ll9W+PxcmFLH5ArD84Bl8MKi1PES/NEu+S64giIdgTV7uNMpK 8venwEsG3B68rpyETMnw2JGNdlsqD1KJAyQBILIjjk4V7d/rV9GVmpEDJ0Qy71wGTC1E Avgl8O0ugcsmqrMAxvgpGTvnZHcLBX+ai3gdXfXUSuIAecwPCZNc7VmCtToAU4TyMPG/ DnNJccqYupp1ZlqbWg6njX3xVg2QqdhRu/sukXp0Q5kkNy3pURImMTeBYnz0bhx/fROn JoEw== X-Gm-Message-State: ACrzQf11yPj4th2sxLTqWK37Xxxo0nCZq+D3/LdNVCzjElNwLgghu0wC qvYMB8teZK1F6/eyGkEzlIuXbQ== X-Received: by 2002:a5d:584b:0:b0:232:b68c:9e6 with SMTP id i11-20020a5d584b000000b00232b68c09e6mr8755800wrf.111.1666279621326; Thu, 20 Oct 2022 08:27:01 -0700 (PDT) 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 l10-20020a1ced0a000000b003c409244bb0sm134337wmh.6.2022.10.20.08.26.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Oct 2022 08:27:00 -0700 (PDT) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, glen.valante@linaro.org, arie.vanderhoeven@seagate.com, rory.c.chen@seagate.com, Federico Gavioli , Paolo Valente Subject: [PATCH V4 6/8] block, bfq: retrieve independent access ranges from request queue Date: Thu, 20 Oct 2022 17:26:41 +0200 Message-Id: <20221020152643.21199-7-paolo.valente@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20221020152643.21199-1-paolo.valente@linaro.org> References: <20221020152643.21199-1-paolo.valente@linaro.org> MIME-Version: 1.0 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,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747221003198657348?= X-GMAIL-MSGID: =?utf-8?q?1747221003198657348?= 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 | 54 ++++++++++++++++++++++++++++++++++++++------- block/bfq-iosched.h | 5 +++++ 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 7c9b5cae05b5..d0109bfc2ed0 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1831,10 +1831,26 @@ static bool bfq_bfqq_higher_class_or_weight(struct bfq_queue *bfqq, /* get the index of the actuator that will serve bio */ 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. - */ + struct blk_independent_access_range *iar; + unsigned int i; + sector_t end; + + /* no search needed if one or zero ranges present */ + if (bfqd->num_actuators < 2) + 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++) { + iar = &(bfqd->ia_ranges[i]); + if (end >= iar->sector && end < iar->sector + iar->nr_sectors) + return i; + } + + WARN_ONCE(true, + "bfq_actuator_index: bio sector out of ranges: end=%llu\n", + end); return 0; } @@ -2479,7 +2495,6 @@ static void bfq_remove_request(struct request_queue *q, if (rq->cmd_flags & REQ_META) bfqq->meta_pending--; - } static bool bfq_bio_merge(struct request_queue *q, struct bio *bio, @@ -7137,6 +7152,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) @@ -7180,10 +7197,31 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e) bfqd->queue = q; /* - * Multi-actuator support not complete yet, default to single - * actuator for the moment. + * If the disk supports multiple actuators, we copy the 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"); + bfqd->num_actuators = 0; + } else { + bfqd->num_actuators = ia_ranges->nr_ia_ranges; + + for (i = 0; i < bfqd->num_actuators; i++) + bfqd->ia_ranges[i] = ia_ranges->ia_range[i]; + } + } else { + bfqd->num_actuators = 0; + } + + spin_unlock_irq(&q->queue_lock); INIT_LIST_HEAD(&bfqd->dispatch); diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index 5fca86a82411..326d68d65cc9 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -815,6 +815,11 @@ struct bfq_data { */ unsigned int num_actuators; + /* + * Disk independent access ranges for each actuator + * in this device. + */ + struct blk_independent_access_range ia_ranges[BFQ_MAX_ACTUATORS]; }; enum bfqq_state_flags {