From patchwork Thu Oct 14 14:03:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12558609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53F80C433F5 for ; Thu, 14 Oct 2021 14:04:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 184A1611B0 for ; Thu, 14 Oct 2021 14:04:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231736AbhJNOGY (ORCPT ); Thu, 14 Oct 2021 10:06:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231659AbhJNOGX (ORCPT ); Thu, 14 Oct 2021 10:06:23 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 991C7C061570; Thu, 14 Oct 2021 07:04:18 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id i12so19859043wrb.7; Thu, 14 Oct 2021 07:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RELB8TbEOZyrfIMN/HydYmqwGJs+ezWzETNaP5mv0f0=; b=Yc3JqziCBJ2sSIU2fcOdZJAIZyh4m6yQrdveft0Ajq97tL2j0mDh43NR4j36vuRkK2 giRn4LL+v36Hrv78VvZh81FiqynDIhALbioZVOr0qSRBHH5fys5vIQpU94QIuGOXFZGY Z/kZnps0Zzsz3SaE4xpYOP98UI7rXsdFcpyHvMgnWDQi5ajtlkpmXrIB63FhEDItENdL pcJBZJgUcqeA2xG0wlWy0PiznjxVmjLjheJ7Et3wyxgsoBg8dwrVCuMnoW3icaoOXyw9 Th/PHe6F8wxmlPs0+rj05T8lqHmaWuK/RgBDDN3WCMbCf5jmiHqaZI5YgLC3oezZset6 wFYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RELB8TbEOZyrfIMN/HydYmqwGJs+ezWzETNaP5mv0f0=; b=adojHoA/UM+8OMlIjHZ+2QMiy893oQKG1LP/dgskCkesjHMoQwhWGAF/gPeV0u8kK+ MkvdRNhUizsgDyLlnsLlmh2TDbBRTVD6IhEqJQ749oFeurlN3yEFN8TqU83D3b+03Ied lMIaeXoUVotf5M8HXEcCZy6LflNVhXWhFnjntZnTNzmUqEHVPNK8qEgwoNaUegnm3HC4 tRyU4voH35hMxsexcSS2j7J9audvoQewLcCSjdWArOy/El7XMYEK4efDrbbs8CmzaGLw xQEoB7+iLhLKGIwL3k4knRySfxiCUUqbXrjVKTsKyuazqCrqyGj9Wj/7kN7qcraMM6Ca ZEnQ== X-Gm-Message-State: AOAM532tg/JPSHd86qKZGhYN3x/UYkIB0nn8j8XxMbKkmOLxQ3/Bkqae UJqXLjk/339Bp/svWvf2iAE= X-Google-Smtp-Source: ABdhPJxbqShtNDOyBGiy0do8LoPUwVk18iZAJPKk/FGhny5uE4sb8+CDz1A8Q9a9rpGj2zIYSLSzGA== X-Received: by 2002:adf:a4ca:: with SMTP id h10mr6929979wrb.28.1634220257217; Thu, 14 Oct 2021 07:04:17 -0700 (PDT) Received: from localhost.localdomain ([185.69.145.214]) by smtp.gmail.com with ESMTPSA id p8sm2273461wmg.15.2021.10.14.07.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 07:04:16 -0700 (PDT) From: Pavel Begunkov To: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christoph Hellwig , asml.silence@gmail.com Subject: [PATCH 1/5] block: cache request queue in bdev Date: Thu, 14 Oct 2021 15:03:26 +0100 Message-Id: X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org There are tons of places where we need to get a request_queue only having bdev, which turns into bdev->bd_disk->queue. There are probably a hundred of such places considering inline helpers, and enough of them are in hot paths. Cache queue pointer in struct block_device and make use of it in bdev_get_queue(). Signed-off-by: Pavel Begunkov --- block/bdev.c | 1 + block/genhd.c | 4 +++- include/linux/blk_types.h | 1 + include/linux/blkdev.h | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index 567534c63f3d..30ae5b5d5f91 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -494,6 +494,7 @@ struct block_device *bdev_alloc(struct gendisk *disk, u8 partno) bdev->bd_disk = disk; bdev->bd_partno = partno; bdev->bd_inode = inode; + bdev->bd_queue = disk->queue; bdev->bd_stats = alloc_percpu(struct disk_stats); if (!bdev->bd_stats) { iput(inode); diff --git a/block/genhd.c b/block/genhd.c index 5e8aa0ab66c2..e11ee23a4401 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1244,6 +1244,9 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id, if (!disk->bdi) goto out_free_disk; + /* bdev_alloc() might need the queue, set before the first call */ + disk->queue = q; + disk->part0 = bdev_alloc(disk, 0); if (!disk->part0) goto out_free_bdi; @@ -1259,7 +1262,6 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id, disk_to_dev(disk)->type = &disk_type; device_initialize(disk_to_dev(disk)); inc_diskseq(disk); - disk->queue = q; q->disk = disk; lockdep_init_map(&disk->lockdep_map, "(bio completion)", lkclass, 0); #ifdef CONFIG_BLOCK_HOLDER_DEPRECATED diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 72736b4c057c..1e370929c89e 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -38,6 +38,7 @@ struct block_device { u8 bd_partno; spinlock_t bd_size_lock; /* for bd_inode->i_size updates */ struct gendisk * bd_disk; + struct request_queue * bd_queue; /* The counter of freeze processes */ int bd_fsfreeze_count; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 2a8689e949b4..d5b21fc8f49e 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -574,7 +574,7 @@ int iocb_bio_iopoll(struct kiocb *kiocb, unsigned int flags); static inline struct request_queue *bdev_get_queue(struct block_device *bdev) { - return bdev->bd_disk->queue; /* this is never NULL */ + return bdev->bd_queue; /* this is never NULL */ } /* From patchwork Thu Oct 14 14:03:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12558611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5978C433EF for ; Thu, 14 Oct 2021 14:04:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BEA86610E7 for ; Thu, 14 Oct 2021 14:04:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231749AbhJNOGZ (ORCPT ); Thu, 14 Oct 2021 10:06:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231741AbhJNOGY (ORCPT ); Thu, 14 Oct 2021 10:06:24 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80EDEC061570; Thu, 14 Oct 2021 07:04:19 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id r7so19904477wrc.10; Thu, 14 Oct 2021 07:04:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xMDSwcqMD4khSm3c9+/YMjtoelEIVc6ZxCpty49UuyU=; b=AxiIhFD4IfhliDORTe+QwUkODFNn2c4w4V550YqOchrB0VvuDHq4bp0zfGMywng0VO ytcIbMhk8GkDfDfdQwIRSyzzxvs/ObiOtimP4+Nhwkd/+belDjXXtJVn33zsgoHrasX/ Nz0orwzf1jtKSMbHS79S2KFMfa3kroOlD8QrWQrllyf93xpCglKxS1PAOe9/zYTIikaT jQVHE1P4NwY/VQjyi2MYmQ0vPkNYxjgRQkNgTu6PU2zhXeGviJ8aThj4LiuXVykD21Zt BRzc0t7prrH30pf4DHIkNTSN0gu2FNfQgn3QA1HEAIGprBPVNQU48SWZveBX1AwUqnYq ypZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xMDSwcqMD4khSm3c9+/YMjtoelEIVc6ZxCpty49UuyU=; b=swYkyTIz3fYI4AUafWBnzpbUjExu5+VuYNlepbxz7UKcqcomHPm7OIDn4OIFXgBWwA xJVItsUKYIgt1YzyDy9EPajt0nLHFmB/R7JkDNhd893lJNgHAaOcjS/E/KynqL/8fhAW 3eKopfaw6xrFkToBsxXkIV6DD2psNL4R7XDOVfbkPcq1VkNCtBasc1+xhqYZNWgHjvC1 GPsnPjYHsK6l/mN3dOTerdfo+1QcOwySKMq0n/YKfPpkeXvMIFYCh0T09ijNlwhxEm4B jnCPJlmBYJNLDYbKj3oCVuKc9yYvYzb5vz1K4pzUc0lGVtATE2ZKvIAAshc5Fnc9+3Rt GYEg== X-Gm-Message-State: AOAM532U9Stz7kdKj2sE9aFNyuLblSNd3FL7/G7PCYxozNFfeEQTVbKg lfSK/IZGUHL3c/dYjBoNMgg= X-Google-Smtp-Source: ABdhPJzrkk7jigfMVG5/daAjnzuaUl/cNSCh7B7Dz7rLgE88dqX88O4ynmQFt7yV3Gbvcq2Omfy6jw== X-Received: by 2002:a05:6000:1869:: with SMTP id d9mr6741492wri.161.1634220258116; Thu, 14 Oct 2021 07:04:18 -0700 (PDT) Received: from localhost.localdomain ([185.69.145.214]) by smtp.gmail.com with ESMTPSA id p8sm2273461wmg.15.2021.10.14.07.04.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 07:04:17 -0700 (PDT) From: Pavel Begunkov To: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christoph Hellwig , asml.silence@gmail.com Subject: [PATCH 2/5] block: use bdev_get_queue() in bdev.c Date: Thu, 14 Oct 2021 15:03:27 +0100 Message-Id: X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Convert bdev->bd_disk->queue to bdev_get_queue(), it's uses a cached queue pointer and so is fater. Signed-off-by: Pavel Begunkov --- block/bdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index 30ae5b5d5f91..384e5bf991d8 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -327,12 +327,12 @@ int bdev_read_page(struct block_device *bdev, sector_t sector, if (!ops->rw_page || bdev_get_integrity(bdev)) return result; - result = blk_queue_enter(bdev->bd_disk->queue, 0); + result = blk_queue_enter(bdev_get_queue(bdev), 0); if (result) return result; result = ops->rw_page(bdev, sector + get_start_sect(bdev), page, REQ_OP_READ); - blk_queue_exit(bdev->bd_disk->queue); + blk_queue_exit(bdev_get_queue(bdev)); return result; } @@ -363,7 +363,7 @@ int bdev_write_page(struct block_device *bdev, sector_t sector, if (!ops->rw_page || bdev_get_integrity(bdev)) return -EOPNOTSUPP; - result = blk_queue_enter(bdev->bd_disk->queue, 0); + result = blk_queue_enter(bdev_get_queue(bdev), 0); if (result) return result; @@ -376,7 +376,7 @@ int bdev_write_page(struct block_device *bdev, sector_t sector, clean_page_buffers(page); unlock_page(page); } - blk_queue_exit(bdev->bd_disk->queue); + blk_queue_exit(bdev_get_queue(bdev)); return result; } From patchwork Thu Oct 14 14:03:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12558613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB667C433FE for ; Thu, 14 Oct 2021 14:04:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC8F3610D0 for ; Thu, 14 Oct 2021 14:04:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231761AbhJNOG2 (ORCPT ); Thu, 14 Oct 2021 10:06:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231744AbhJNOGZ (ORCPT ); Thu, 14 Oct 2021 10:06:25 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D537C061570; Thu, 14 Oct 2021 07:04:20 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id i12so19859325wrb.7; Thu, 14 Oct 2021 07:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0qu3wfbcbDBRoEiFSBFw8GNfAxgn5icQsmAb4gNPUck=; b=NtF+pXe9D9jiV9qdP2lV6TFfAT0Qh/N+Ys7vjDDKXItwxpgTY/GppMkEpzY9F+HHhz 06bem6LC4L6M2QeU/7DoetBOmKhRwzzDjptKK2n8bCopcbg0SBGX6HJxbXkdsPdpJJ2N oWy+nJiHj9nlCXh3vP8xxVrdZPQAPpB/AQM3jU/nVLn4Ss5FhJ0n0E3pIUJ3oMhBSyH6 Gvfz15tQD8c5pxTLHFiAEo24pREqScIp3ZQjG6dA7wDIRU3r0NGRSt1eEjT55OgQ1FyD p7yh9Vm5URC5f59Qc6vXTUXjivYmjRGHETwUrxNAlqNMqnjpwRRz1Tr18XNyODOmcgdF k/aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0qu3wfbcbDBRoEiFSBFw8GNfAxgn5icQsmAb4gNPUck=; b=GwenpC3jbIjttCKfDWe0FzkuZFZIAB0xnWsMiFG/Rg5UBr+zhV1ftOY+vdyDZVGvJH Yr/cL64bRITdcag83ffdkIr1wSz//2m7gmiO6T9oSL6TZvvTzIhXh7WaGvPAYmppDL+c WS1WqwwM06V3Op2tHUFDI9v0FLmABiLEWCjFVWmKTtOZYnsUBVjjWiOlnc9l3U1p6laO pHT5u++/B1xRWY0zzkJYRUc3tJLYTavCRdXmvXdCQSv6xUL3FUOAwgWU0bOo9YVPXOhp fzu0Tn6XUljZbuSA4NzoTysXo5xuV6HTrwlEmMTr/Bafw4dVLM7LABMzy9NcCk67Ldkd 4NZw== X-Gm-Message-State: AOAM5317tqpMEhgZ/zDc/ICfnx78ZNGYIcoR/yDVqpSBk5/n6lr69dMS bWbfrYsmy6/DK1HND+aaP1WtIx4gsbI= X-Google-Smtp-Source: ABdhPJyZDmi78ck2x8xyMR/imlvRg/M//3eJTrZDeHDYFifeem5IYpO0NVHJOEEGtudeHtfuadpPZg== X-Received: by 2002:a5d:6dad:: with SMTP id u13mr6914930wrs.370.1634220259039; Thu, 14 Oct 2021 07:04:19 -0700 (PDT) Received: from localhost.localdomain ([185.69.145.214]) by smtp.gmail.com with ESMTPSA id p8sm2273461wmg.15.2021.10.14.07.04.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 07:04:18 -0700 (PDT) From: Pavel Begunkov To: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christoph Hellwig , asml.silence@gmail.com Subject: [PATCH 3/5] block: use bdev_get_queue() in bio.c Date: Thu, 14 Oct 2021 15:03:28 +0100 Message-Id: <85c36ea784d285a5075baa10049e6b59e15fb484.1634219547.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Convert bdev->bd_disk->queue to bdev_get_queue(), it's uses a cached queue pointer and so is fater. Signed-off-by: Pavel Begunkov --- block/bio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/block/bio.c b/block/bio.c index 7377fc93606a..fb3704a61e07 100644 --- a/block/bio.c +++ b/block/bio.c @@ -910,7 +910,7 @@ EXPORT_SYMBOL(bio_add_pc_page); int bio_add_zone_append_page(struct bio *bio, struct page *page, unsigned int len, unsigned int offset) { - struct request_queue *q = bio->bi_bdev->bd_disk->queue; + struct request_queue *q = bdev_get_queue(bio->bi_bdev); bool same_page = false; if (WARN_ON_ONCE(bio_op(bio) != REQ_OP_ZONE_APPEND)) @@ -1054,7 +1054,7 @@ static int bio_iov_bvec_set(struct bio *bio, struct iov_iter *iter) static int bio_iov_bvec_set_append(struct bio *bio, struct iov_iter *iter) { - struct request_queue *q = bio->bi_bdev->bd_disk->queue; + struct request_queue *q = bdev_get_queue(bio->bi_bdev); struct iov_iter i = *iter; iov_iter_truncate(&i, queue_max_zone_append_sectors(q) << 9); @@ -1132,7 +1132,7 @@ static int __bio_iov_append_get_pages(struct bio *bio, struct iov_iter *iter) { unsigned short nr_pages = bio->bi_max_vecs - bio->bi_vcnt; unsigned short entries_left = bio->bi_max_vecs - bio->bi_vcnt; - struct request_queue *q = bio->bi_bdev->bd_disk->queue; + struct request_queue *q = bdev_get_queue(bio->bi_bdev); unsigned int max_append_sectors = queue_max_zone_append_sectors(q); struct bio_vec *bv = bio->bi_io_vec + bio->bi_vcnt; struct page **pages = (struct page **)bv; @@ -1469,10 +1469,10 @@ void bio_endio(struct bio *bio) return; if (bio->bi_bdev && bio_flagged(bio, BIO_TRACKED)) - rq_qos_done_bio(bio->bi_bdev->bd_disk->queue, bio); + rq_qos_done_bio(bdev_get_queue(bio->bi_bdev), bio); if (bio->bi_bdev && bio_flagged(bio, BIO_TRACE_COMPLETION)) { - trace_block_bio_complete(bio->bi_bdev->bd_disk->queue, bio); + trace_block_bio_complete(bdev_get_queue(bio->bi_bdev), bio); bio_clear_flag(bio, BIO_TRACE_COMPLETION); } From patchwork Thu Oct 14 14:03:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12558615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFB87C433F5 for ; Thu, 14 Oct 2021 14:04:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 884F6610CC for ; Thu, 14 Oct 2021 14:04:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231754AbhJNOG3 (ORCPT ); Thu, 14 Oct 2021 10:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231758AbhJNOG2 (ORCPT ); Thu, 14 Oct 2021 10:06:28 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72DC2C061755; Thu, 14 Oct 2021 07:04:21 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id v17so19828980wrv.9; Thu, 14 Oct 2021 07:04:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xnpzWQz9uOiSJqamWPmVItt84eeZuw9zU3to8Fs7zAE=; b=dPPsuMaXAyife1zHD+SjQn16u+5fm+VTtR7m/utqBmX/m80NHI8uv/xTEXqk9PzHrk e0nC+lh4g9bakuUsJZZxuRFDpo0v4xdp4h1FE2evc4EiYJRshIEPatjGXm1EVhhRCkLZ zRRZb1U7alJNjbvljH7MzidBqmGNxAdh23fFeh6aIBmRYdaX93vpf5OQyR4UZfTxXHty 1ta6yeHRGvD7QwwfIFxVNdHKy1qKhaoI1u2jmNll/dlBDTP9VNA+podgDsPXiS0tnCMH iF8n6Q4cZr5zs8jfbnAySCp1SW1OmFHMI1LnllD9mahl372WHjDb3r+dZA8s2sdQ6nXx RGKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xnpzWQz9uOiSJqamWPmVItt84eeZuw9zU3to8Fs7zAE=; b=Jkm6PXO6OVGpu4QWWfual48vyfj2MXYJV//oRalTUpaqlFk/Y5kZisk2rz/EziF2Zs XdQ1wDRbZcX5fVfoFoiMqxS7Kca7k/v0qc4sYNW3aEyv0H8V8Uc6K/t+uyOMnHSDkSHh F4eBiFx3GelxrTwmCyKS+0iUHJBBOQtaw2LZ+mt1RI3WpwEnHa9Awy9s+lSpqg8B8iV2 3mPFtHNMkPCxpGG8DOkDrhM/U2vhMQ/yMxD00DFJfLTjRi7DssKUZkn8kIn9pdBDIpjF yfAkVoGmq2NNMbJf8AGmN+zz+nx+eixpRpAeofVEhycqJUfgDQq6G2W+UgRzaOxIOTJ7 l6Pg== X-Gm-Message-State: AOAM532mDzv+v1A7t8xRNcwz9arXIcZXcLuruxHOAdGVemCzmBO7wxrR gXg38G1zh0vnTD+mlX4mrbA= X-Google-Smtp-Source: ABdhPJzz3FvzU2fjQHWajbXSjOOMSPi99ea/Go43sBCjdu3/04plkt2lKsaJb7dIbaBPhz7TUePriw== X-Received: by 2002:a5d:4248:: with SMTP id s8mr6706803wrr.195.1634220260051; Thu, 14 Oct 2021 07:04:20 -0700 (PDT) Received: from localhost.localdomain ([185.69.145.214]) by smtp.gmail.com with ESMTPSA id p8sm2273461wmg.15.2021.10.14.07.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 07:04:19 -0700 (PDT) From: Pavel Begunkov To: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christoph Hellwig , asml.silence@gmail.com Subject: [PATCH 4/5] block: use bdev_get_queue() in blk-core.c Date: Thu, 14 Oct 2021 15:03:29 +0100 Message-Id: X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Convert bdev->bd_disk->queue to bdev_get_queue(), it's uses a cached queue pointer and so is fater. Signed-off-by: Pavel Begunkov --- block/blk-core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 1ad2528680ea..f928990a1341 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -472,7 +472,7 @@ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags) static inline int bio_queue_enter(struct bio *bio) { - struct request_queue *q = bio->bi_bdev->bd_disk->queue; + struct request_queue *q = bdev_get_queue(bio->bi_bdev); bool nowait = bio->bi_opf & REQ_NOWAIT; int ret; @@ -782,7 +782,7 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q, static noinline_for_stack bool submit_bio_checks(struct bio *bio) { struct block_device *bdev = bio->bi_bdev; - struct request_queue *q = bdev->bd_disk->queue; + struct request_queue *q = bdev_get_queue(bdev); blk_status_t status = BLK_STS_IOERR; struct blk_plug *plug; @@ -940,7 +940,7 @@ static void __submit_bio_noacct(struct bio *bio) current->bio_list = bio_list_on_stack; do { - struct request_queue *q = bio->bi_bdev->bd_disk->queue; + struct request_queue *q = bdev_get_queue(bio->bi_bdev); struct bio_list lower, same; if (unlikely(bio_queue_enter(bio) != 0)) @@ -961,7 +961,7 @@ static void __submit_bio_noacct(struct bio *bio) bio_list_init(&lower); bio_list_init(&same); while ((bio = bio_list_pop(&bio_list_on_stack[0])) != NULL) - if (q == bio->bi_bdev->bd_disk->queue) + if (q == bdev_get_queue(bio->bi_bdev)) bio_list_add(&same, bio); else bio_list_add(&lower, bio); @@ -1056,7 +1056,7 @@ void submit_bio(struct bio *bio) if (unlikely(bio_op(bio) == REQ_OP_WRITE_SAME)) count = queue_logical_block_size( - bio->bi_bdev->bd_disk->queue) >> 9; + bdev_get_queue(bio->bi_bdev)) >> 9; else count = bio_sectors(bio); From patchwork Thu Oct 14 14:03:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12558617 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5EFBC4332F for ; Thu, 14 Oct 2021 14:04:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA8C1610CC for ; Thu, 14 Oct 2021 14:04:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231753AbhJNOG3 (ORCPT ); Thu, 14 Oct 2021 10:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231464AbhJNOG2 (ORCPT ); Thu, 14 Oct 2021 10:06:28 -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 60E4CC061760; Thu, 14 Oct 2021 07:04:22 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id k7so19733206wrd.13; Thu, 14 Oct 2021 07:04:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6+p8OcENyUnzjvyDDBY5EaQ2YYrwg2RAAMB9eV7d4z0=; b=pG/ynoYkNoyvyDHOEIWiS8JNH6LaK7+mS27IKNUfOps/joF/YLxvy6vBkQpwAbzuM+ hOxCl4hSzFYIFTY8S5NKHbmY51M3TFCtU0C2491tHYYGWn3fLeyCItwqSwPW4y9vI3sI k4wTC0dea3B4FEjPVK81JBBT6BPcVo5N++2ESkWi+YucbgHTGfGXS8epNqMr5e154RKV fCdubKYLwZPlxKCdkLkQd+WFkZYs1+v1xYI7us7hQJydPeyALEYxtIWPJYZmBwdbr4Is LPgRa1DJpFyBr7f/znOso1iTsTsMiulCLv9hHhBumcdj2oHQEpjNbWwsZZtL7/rynxCf 9wyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6+p8OcENyUnzjvyDDBY5EaQ2YYrwg2RAAMB9eV7d4z0=; b=Qpjd7WImtw2XvfXcNtJ02js9AEIQoDWc5lnNTCOTWw/uhtJRwKw07+TfYOe0A/Gmc/ NGuPwovbMBC3wUXcSzoOhyD62QLNry9Yk9mXaR7hviX3I3KK3idM8EvpuN35c8IRO79I ZPr5M2nEatF1nnD6cUlAXu7883Pr4YDXPfSKjahKYyrBVbQWxm6MClJzIGu0Mko+wVfd /pYQL6qaOIe/8Mbtbevms087/el9eDMGG9By7295BvFDF6MP4gCsSuTQQhs4TIG9hYGk XwJWOsJP3nFXaV++8bPbH3IpPyhWc1kmkcHLX/qXLqw8bQFvxNfC0uEQ21dx3eLP4B3W Im6A== X-Gm-Message-State: AOAM533PZNMWtSTfnPFb5l/Pyj6CSDRw7WCY9xKp7IDZWTMtYnuP+w2B 89pl+21KrEU64dN+rma9AbE= X-Google-Smtp-Source: ABdhPJyP3idTTRxTBKCwIhHjRslFHsPoOwpr1fHnaf9hN9lq6dkOJWw2aGBmKgsfnfux2OOdbMVsYA== X-Received: by 2002:adf:b304:: with SMTP id j4mr7164576wrd.160.1634220261009; Thu, 14 Oct 2021 07:04:21 -0700 (PDT) Received: from localhost.localdomain ([185.69.145.214]) by smtp.gmail.com with ESMTPSA id p8sm2273461wmg.15.2021.10.14.07.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 07:04:20 -0700 (PDT) From: Pavel Begunkov To: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christoph Hellwig , asml.silence@gmail.com Subject: [PATCH 5/5] block: convert the rest of block to bdev_get_queue Date: Thu, 14 Oct 2021 15:03:30 +0100 Message-Id: X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Convert bdev->bd_disk->queue to bdev_get_queue(), it's uses a cached queue pointer and so is fater. Signed-off-by: Pavel Begunkov --- block/bio-integrity.c | 2 +- block/blk-cgroup.c | 16 ++++++++-------- block/blk-crypto.c | 2 +- block/blk-iocost.c | 12 ++++++------ block/blk-merge.c | 2 +- block/blk-mq.c | 2 +- block/blk-throttle.c | 2 +- block/genhd.c | 4 ++-- block/partitions/core.c | 4 ++-- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 21234ff966d9..d25114715459 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -134,7 +134,7 @@ int bio_integrity_add_page(struct bio *bio, struct page *page, iv = bip->bip_vec + bip->bip_vcnt; if (bip->bip_vcnt && - bvec_gap_to_prev(bio->bi_bdev->bd_disk->queue, + bvec_gap_to_prev(bdev_get_queue(bio->bi_bdev), &bip->bip_vec[bip->bip_vcnt - 1], offset)) return 0; diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index eb48090eefce..cec86a705c89 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -621,7 +621,7 @@ struct block_device *blkcg_conf_open_bdev(char **inputp) */ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, char *input, struct blkg_conf_ctx *ctx) - __acquires(rcu) __acquires(&bdev->bd_disk->queue->queue_lock) + __acquires(rcu) __acquires(&bdev->bd_queue->queue_lock) { struct block_device *bdev; struct request_queue *q; @@ -632,7 +632,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, if (IS_ERR(bdev)) return PTR_ERR(bdev); - q = bdev->bd_disk->queue; + q = bdev_get_queue(bdev); rcu_read_lock(); spin_lock_irq(&q->queue_lock); @@ -737,9 +737,9 @@ EXPORT_SYMBOL_GPL(blkg_conf_prep); * with blkg_conf_prep(). */ void blkg_conf_finish(struct blkg_conf_ctx *ctx) - __releases(&ctx->bdev->bd_disk->queue->queue_lock) __releases(rcu) + __releases(&ctx->bdev->bd_queue->queue_lock) __releases(rcu) { - spin_unlock_irq(&ctx->bdev->bd_disk->queue->queue_lock); + spin_unlock_irq(&bdev_get_queue(ctx->bdev)->queue_lock); rcu_read_unlock(); blkdev_put_no_open(ctx->bdev); } @@ -842,7 +842,7 @@ static void blkcg_fill_root_iostats(void) while ((dev = class_dev_iter_next(&iter))) { struct block_device *bdev = dev_to_bdev(dev); struct blkcg_gq *blkg = - blk_queue_root_blkg(bdev->bd_disk->queue); + blk_queue_root_blkg(bdev_get_queue(bdev)); struct blkg_iostat tmp; int cpu; @@ -1801,7 +1801,7 @@ static inline struct blkcg_gq *blkg_tryget_closest(struct bio *bio, rcu_read_lock(); blkg = blkg_lookup_create(css_to_blkcg(css), - bio->bi_bdev->bd_disk->queue); + bdev_get_queue(bio->bi_bdev)); while (blkg) { if (blkg_tryget(blkg)) { ret_blkg = blkg; @@ -1837,8 +1837,8 @@ void bio_associate_blkg_from_css(struct bio *bio, if (css && css->parent) { bio->bi_blkg = blkg_tryget_closest(bio, css); } else { - blkg_get(bio->bi_bdev->bd_disk->queue->root_blkg); - bio->bi_blkg = bio->bi_bdev->bd_disk->queue->root_blkg; + blkg_get(bdev_get_queue(bio->bi_bdev)->root_blkg); + bio->bi_blkg = bdev_get_queue(bio->bi_bdev)->root_blkg; } } EXPORT_SYMBOL_GPL(bio_associate_blkg_from_css); diff --git a/block/blk-crypto.c b/block/blk-crypto.c index 103c2e2d50d6..8f53f4a1f9e2 100644 --- a/block/blk-crypto.c +++ b/block/blk-crypto.c @@ -280,7 +280,7 @@ bool __blk_crypto_bio_prep(struct bio **bio_ptr) * Success if device supports the encryption context, or if we succeeded * in falling back to the crypto API. */ - if (blk_ksm_crypto_cfg_supported(bio->bi_bdev->bd_disk->queue->ksm, + if (blk_ksm_crypto_cfg_supported(bdev_get_queue(bio->bi_bdev)->ksm, &bc_key->crypto_cfg)) return true; diff --git a/block/blk-iocost.c b/block/blk-iocost.c index b3880e4ba22a..a5b37cc65b17 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -3165,12 +3165,12 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, if (IS_ERR(bdev)) return PTR_ERR(bdev); - ioc = q_to_ioc(bdev->bd_disk->queue); + ioc = q_to_ioc(bdev_get_queue(bdev)); if (!ioc) { - ret = blk_iocost_init(bdev->bd_disk->queue); + ret = blk_iocost_init(bdev_get_queue(bdev)); if (ret) goto err; - ioc = q_to_ioc(bdev->bd_disk->queue); + ioc = q_to_ioc(bdev_get_queue(bdev)); } spin_lock_irq(&ioc->lock); @@ -3332,12 +3332,12 @@ static ssize_t ioc_cost_model_write(struct kernfs_open_file *of, char *input, if (IS_ERR(bdev)) return PTR_ERR(bdev); - ioc = q_to_ioc(bdev->bd_disk->queue); + ioc = q_to_ioc(bdev_get_queue(bdev)); if (!ioc) { - ret = blk_iocost_init(bdev->bd_disk->queue); + ret = blk_iocost_init(bdev_get_queue(bdev)); if (ret) goto err; - ioc = q_to_ioc(bdev->bd_disk->queue); + ioc = q_to_ioc(bdev_get_queue(bdev)); } spin_lock_irq(&ioc->lock); diff --git a/block/blk-merge.c b/block/blk-merge.c index 762da71f9fde..c96f29f398fc 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -305,7 +305,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, */ void __blk_queue_split(struct bio **bio, unsigned int *nr_segs) { - struct request_queue *q = (*bio)->bi_bdev->bd_disk->queue; + struct request_queue *q = bdev_get_queue((*bio)->bi_bdev); struct bio *split = NULL; switch (bio_op(*bio)) { diff --git a/block/blk-mq.c b/block/blk-mq.c index f42cf615c527..5cb5dd81a1d5 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2223,7 +2223,7 @@ static inline unsigned short blk_plug_max_rq_count(struct blk_plug *plug) */ void blk_mq_submit_bio(struct bio *bio) { - struct request_queue *q = bio->bi_bdev->bd_disk->queue; + struct request_queue *q = bdev_get_queue(bio->bi_bdev); const int is_sync = op_is_sync(bio->bi_opf); const int is_flush_fua = op_is_flush(bio->bi_opf); struct request *rq; diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 8cefd14deed5..39bb6e68a9a2 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -2063,7 +2063,7 @@ void blk_throtl_charge_bio_split(struct bio *bio) bool __blk_throtl_bio(struct bio *bio) { - struct request_queue *q = bio->bi_bdev->bd_disk->queue; + struct request_queue *q = bdev_get_queue(bio->bi_bdev); struct blkcg_gq *blkg = bio->bi_blkg; struct throtl_qnode *qn = NULL; struct throtl_grp *tg = blkg_to_tg(blkg); diff --git a/block/genhd.c b/block/genhd.c index e11ee23a4401..901bef22f186 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -861,7 +861,7 @@ ssize_t part_stat_show(struct device *dev, struct device_attribute *attr, char *buf) { struct block_device *bdev = dev_to_bdev(dev); - struct request_queue *q = bdev->bd_disk->queue; + struct request_queue *q = bdev_get_queue(bdev); struct disk_stats stat; unsigned int inflight; @@ -905,7 +905,7 @@ ssize_t part_inflight_show(struct device *dev, struct device_attribute *attr, char *buf) { struct block_device *bdev = dev_to_bdev(dev); - struct request_queue *q = bdev->bd_disk->queue; + struct request_queue *q = bdev_get_queue(bdev); unsigned int inflight[2]; if (queue_is_mq(q)) diff --git a/block/partitions/core.c b/block/partitions/core.c index 3a4898433c43..9dbddc355b40 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -204,7 +204,7 @@ static ssize_t part_alignment_offset_show(struct device *dev, struct block_device *bdev = dev_to_bdev(dev); return sprintf(buf, "%u\n", - queue_limit_alignment_offset(&bdev->bd_disk->queue->limits, + queue_limit_alignment_offset(&bdev_get_queue(bdev)->limits, bdev->bd_start_sect)); } @@ -214,7 +214,7 @@ static ssize_t part_discard_alignment_show(struct device *dev, struct block_device *bdev = dev_to_bdev(dev); return sprintf(buf, "%u\n", - queue_limit_discard_alignment(&bdev->bd_disk->queue->limits, + queue_limit_discard_alignment(&bdev_get_queue(bdev)->limits, bdev->bd_start_sect)); }