From patchwork Tue Oct 30 18:32:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10661403 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80D3E14DE for ; Tue, 30 Oct 2018 18:34:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C23F2986B for ; Tue, 30 Oct 2018 18:34:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8050C299B9; Tue, 30 Oct 2018 18:34:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 160362986B for ; Tue, 30 Oct 2018 18:34:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727020AbeJaD2q (ORCPT ); Tue, 30 Oct 2018 23:28:46 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:36385 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727684AbeJaD1w (ORCPT ); Tue, 30 Oct 2018 23:27:52 -0400 Received: by mail-it1-f194.google.com with SMTP id t4-v6so6645726itf.1 for ; Tue, 30 Oct 2018 11:33:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0pIeDFtEGtTWIpejvN1KlR+jipBFPqHKlbzzMp8RAQY=; b=wAOiowO/mVCgKdHWTOtZUTsYPXWoATSFFw+/LNkkogVvlewLcGOEWq0shwvXMoMTpE ckQy0rbhdUohZl8Tk8iD4HoukVnA7HIngPW+Sy2102zYCXNHiOqx1L13R1QMxSvq+Adh OVz+69aOLw4qH/Qh4D2bE9HBUaayZxfRIRzEk/YetvgT+FDFiujCCh9HDDKq2pDMTUvj hH6KACH6I83vsM5tO8tmzXCqF0ksepVae/MdeIm2kjrRr6lNsaHKPZn4spw6rLgH2iH0 j2aVNv4L5RCPDwQd8smE3xE2nh++zOjfJ7pMvG+Qpy7TuJz/5NmNxJ6xmsQKIvlG++db sNig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0pIeDFtEGtTWIpejvN1KlR+jipBFPqHKlbzzMp8RAQY=; b=oT03bTxhPAUSSCIYqI9LxkjtP+2UNcnh6hzFL7B3ZDMS/GYOumLMowY0cw8dt4CVU9 pKhIU5oF+8BZQRLrmJVqut5JJvAuNGoIH1MsJ5Pet6/w2cpTUoW54rw2ZQh4eGQBGFx7 k7hL3jnt43ktxXrmln2myxlby7pqLYFbVw/rIAEXMJ+ungWM7OXPixdQGAe18s8yhcgr FVgakpFx5CsqiFrErTwnAwBrnRCyAeFFoA9+B8u/Y9OUhgZYwxnZrhREiS92eTBUJR++ qK+DxBiF2u+ghNKqt3w5u8p5SzIOMqvVHxcAnQUFJ4nxYjStN/LlvdkaFG20V6I7dmfN 6u1g== X-Gm-Message-State: AGRZ1gKJdMsb4SK5MQHxuTeGR4frttTYCqW6dU96QVVWLUoWobVh8rGx wLlc2Gt979DXiWHTE+ZWs1xRtcypOfI= X-Google-Smtp-Source: AJdET5db2SrmMseFyQke7yKO2N3elXXI+IwJbhgyXv8e2+Il9RgMUvA2+kJwkUhi5rrRQ0/v/rz4rg== X-Received: by 2002:a02:a914:: with SMTP id n20-v6mr12774jam.90.1540924396163; Tue, 30 Oct 2018 11:33:16 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id o20-v6sm4895739itc.34.2018.10.30.11.33.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Oct 2018 11:33:14 -0700 (PDT) From: Jens Axboe To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 10/16] blk-mq: cleanup and improve list insertion Date: Tue, 30 Oct 2018 12:32:46 -0600 Message-Id: <20181030183252.17857-11-axboe@kernel.dk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181030183252.17857-1-axboe@kernel.dk> References: <20181030183252.17857-1-axboe@kernel.dk> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It's somewhat strange to have a list insertion function that relies on the fact that the caller has mapped things correctly. Pass in the hardware queue directly for insertion, which makes for a much cleaner interface and implementation. Signed-off-by: Jens Axboe Reviewed-by: Sagi Grimberg Reviewed-by: Hannes Reinecke --- block/blk-mq-sched.c | 8 +------- block/blk-mq-sched.h | 2 +- block/blk-mq.c | 25 ++++++++++++++----------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index 8bc1f37acca2..6e7375246e2f 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -396,17 +396,11 @@ void blk_mq_sched_insert_request(struct request *rq, bool at_head, blk_mq_run_hw_queue(hctx, async); } -void blk_mq_sched_insert_requests(struct request_queue *q, +void blk_mq_sched_insert_requests(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx, struct list_head *list, bool run_queue_async) { - struct blk_mq_hw_ctx *hctx; struct elevator_queue *e; - struct request *rq; - - /* For list inserts, requests better be on the same hw queue */ - rq = list_first_entry(list, struct request, queuelist); - hctx = rq->mq_hctx; e = hctx->queue->elevator; if (e && e->type->ops.mq.insert_requests) diff --git a/block/blk-mq-sched.h b/block/blk-mq-sched.h index 8a9544203173..ffd7b5989d63 100644 --- a/block/blk-mq-sched.h +++ b/block/blk-mq-sched.h @@ -19,7 +19,7 @@ void blk_mq_sched_restart(struct blk_mq_hw_ctx *hctx); void blk_mq_sched_insert_request(struct request *rq, bool at_head, bool run_queue, bool async); -void blk_mq_sched_insert_requests(struct request_queue *q, +void blk_mq_sched_insert_requests(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx, struct list_head *list, bool run_queue_async); diff --git a/block/blk-mq.c b/block/blk-mq.c index b86d725958d3..51b8166959b9 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1623,11 +1623,12 @@ static int plug_ctx_cmp(void *priv, struct list_head *a, struct list_head *b) void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule) { + struct blk_mq_hw_ctx *this_hctx; struct blk_mq_ctx *this_ctx; struct request_queue *this_q; struct request *rq; LIST_HEAD(list); - LIST_HEAD(ctx_list); + LIST_HEAD(rq_list); unsigned int depth; list_splice_init(&plug->mq_list, &list); @@ -1635,6 +1636,7 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule) list_sort(NULL, &list, plug_ctx_cmp); this_q = NULL; + this_hctx = NULL; this_ctx = NULL; depth = 0; @@ -1642,30 +1644,31 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule) rq = list_entry_rq(list.next); list_del_init(&rq->queuelist); BUG_ON(!rq->q); - if (rq->mq_ctx != this_ctx) { - if (this_ctx) { + if (rq->mq_hctx != this_hctx || rq->mq_ctx != this_ctx) { + if (this_hctx) { trace_block_unplug(this_q, depth, !from_schedule); - blk_mq_sched_insert_requests(this_q, this_ctx, - &ctx_list, + blk_mq_sched_insert_requests(this_hctx, this_ctx, + &rq_list, from_schedule); } - this_ctx = rq->mq_ctx; this_q = rq->q; + this_ctx = rq->mq_ctx; + this_hctx = rq->mq_hctx; depth = 0; } depth++; - list_add_tail(&rq->queuelist, &ctx_list); + list_add_tail(&rq->queuelist, &rq_list); } /* - * If 'this_ctx' is set, we know we have entries to complete - * on 'ctx_list'. Do those. + * If 'this_hctx' is set, we know we have entries to complete + * on 'rq_list'. Do those. */ - if (this_ctx) { + if (this_hctx) { trace_block_unplug(this_q, depth, !from_schedule); - blk_mq_sched_insert_requests(this_q, this_ctx, &ctx_list, + blk_mq_sched_insert_requests(this_hctx, this_ctx, &rq_list, from_schedule); } }