Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp438246iog; Mon, 13 Jun 2022 06:02:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVIUEGaKlFnRZzhLKMLTDGpWX0B5K2x6qoTKGgpXldcd4hB2SgouJ+nSPo0srVEW+gcGWm X-Received: by 2002:a17:902:d484:b0:167:770b:666 with SMTP id c4-20020a170902d48400b00167770b0666mr40640376plg.148.1655125350791; Mon, 13 Jun 2022 06:02:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125350; cv=none; d=google.com; s=arc-20160816; b=SFIEyWep1WKIJoHg4TndhE5pUTf52xnUpsH+jthWVpw2UmOGRZ72trGdkoijZ7yhjl X5Cndw5i6w/FJDKkV2lBM9kmkPuaMXARkO3zfUuWYQ+IeNR9/d3iw1yV5OPBtp/veKm8 cmPVTik9EMT1VpUijgABQIcLQNHYskEILKepvJvfjZF5I/YaM8FSaweArsIEamZZqkSt UyGqjmHUvmSxCdd99r0VmzHGRNW/LPUu965MXMF5Ff0mVflpEWHYBpuc/5dim5XbjXJu nVQ2xpm098mZ/ZoSRo6zyRzCNXIKhssMHhtxHTptDqUL2bJW8ns8zJ4LPW+C1qWbVpkL ajjQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NDqqFInj63f7GyvR5qswGqkJx7Pb1pD7ykBTS4Z6FV4=; b=zQea6Upt9v4PbMuajFzJtBQROX1BgU24cw6aWQT1Z/Lef9mtvik+A9Lz0rTFRvEfc7 z+VF4+knahTaMSW+2w0nD9Y66btfbNq+3WLbS6lP1vZOXoILebClA0F/RxT5MyQyhDwY 51snamSWyXb7ogC3NXPzl2s8nrYvzYfcQKkXSqZxIL78/qwKymTfL0i4wGcX7hDDtQ6p U8/ccMcEkFvCs1EqbPOx9dT7+60bdEZ+OFuXiSpZ6BB/mV3/ih3WIj04ho6nUMmWA84a 5wtTn7cm3H2KGuEkLFod3u/Ra7vm6d0Fib09nhO/YfFDw2DXR3G54WbnftdSQ+/JLTm/ s9Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sKPMXeyb; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k5-20020a17090a9d8500b001e0a2aed762si8419774pjp.126.2022.06.13.06.02.12; Mon, 13 Jun 2022 06:02:30 -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=@linuxfoundation.org header.s=korg header.b=sKPMXeyb; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355351AbiFMLew (ORCPT + 99 others); Mon, 13 Jun 2022 07:34:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354435AbiFML33 (ORCPT ); Mon, 13 Jun 2022 07:29:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACCAFDE9D; Mon, 13 Jun 2022 03:44:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4B57560FDB; Mon, 13 Jun 2022 10:44:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 540BCC34114; Mon, 13 Jun 2022 10:44:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117069; bh=7l6I+Zm5okScKV6T1RaxcInLWaYXcTcFqc4Ut2x5R8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sKPMXeybcd8rl3gJlS+jliXr2Ida/I1YU9OKc8aMIiM5+0jOrh45OzBUANEhUBr04 Y5zMq6opAZ4zG7dqDevcqxqp5BnwrHYU2c55G22T8YLlOffR5Ttw6qeI2NJOe/maD9 g2A8vuNQhp91qMA+cJV9V5Y37WsdUFvvJ4j8UQCo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , "yukuai (C)" , Jan Kara , Christoph Hellwig , Jens Axboe Subject: [PATCH 5.4 276/411] bfq: Remove pointless bfq_init_rq() calls Date: Mon, 13 Jun 2022 12:09:09 +0200 Message-Id: <20220613094937.034071926@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: Jan Kara commit 5f550ede5edf846ecc0067be1ba80514e6fe7f8e upstream. We call bfq_init_rq() from request merging functions where requests we get should have already gone through bfq_init_rq() during insert and anyway we want to do anything only if the request is already tracked by BFQ. So replace calls to bfq_init_rq() with RQ_BFQQ() instead to simply skip requests untracked by BFQ. We move bfq_init_rq() call in bfq_insert_request() a bit earlier to cover request merging and thus can transfer FIFO position in case of a merge. CC: stable@vger.kernel.org Tested-by: "yukuai (C)" Signed-off-by: Jan Kara Reviewed-by: Christoph Hellwig Link: https://lore.kernel.org/r/20220401102752.8599-6-jack@suse.cz Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/bfq-iosched.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -2267,8 +2267,6 @@ static int bfq_request_merge(struct requ return ELEVATOR_NO_MERGE; } -static struct bfq_queue *bfq_init_rq(struct request *rq); - static void bfq_request_merged(struct request_queue *q, struct request *req, enum elv_merge type) { @@ -2277,7 +2275,7 @@ static void bfq_request_merged(struct re blk_rq_pos(req) < blk_rq_pos(container_of(rb_prev(&req->rb_node), struct request, rb_node))) { - struct bfq_queue *bfqq = bfq_init_rq(req); + struct bfq_queue *bfqq = RQ_BFQQ(req); struct bfq_data *bfqd; struct request *prev, *next_rq; @@ -2329,8 +2327,8 @@ static void bfq_request_merged(struct re static void bfq_requests_merged(struct request_queue *q, struct request *rq, struct request *next) { - struct bfq_queue *bfqq = bfq_init_rq(rq), - *next_bfqq = bfq_init_rq(next); + struct bfq_queue *bfqq = RQ_BFQQ(rq), + *next_bfqq = RQ_BFQQ(next); if (!bfqq) return; @@ -5514,6 +5512,8 @@ static inline void bfq_update_insert_sta unsigned int cmd_flags) {} #endif /* CONFIG_BFQ_CGROUP_DEBUG */ +static struct bfq_queue *bfq_init_rq(struct request *rq); + static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, bool at_head) { @@ -5524,6 +5524,7 @@ static void bfq_insert_request(struct bl unsigned int cmd_flags; spin_lock_irq(&bfqd->lock); + bfqq = bfq_init_rq(rq); if (blk_mq_sched_try_insert_merge(q, rq)) { spin_unlock_irq(&bfqd->lock); return; @@ -5531,7 +5532,6 @@ static void bfq_insert_request(struct bl blk_mq_sched_request_inserted(rq); - bfqq = bfq_init_rq(rq); if (!bfqq || at_head || blk_rq_is_passthrough(rq)) { if (at_head) list_add(&rq->queuelist, &bfqd->dispatch);