From patchwork Mon Sep 30 18:55:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 11167439 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 68B731599 for ; Mon, 30 Sep 2019 20:44:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 456C822500 for ; Mon, 30 Sep 2019 20:44:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dB7DFAoq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727884AbfI3UoB (ORCPT ); Mon, 30 Sep 2019 16:44:01 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:35265 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729833AbfI3UoB (ORCPT ); Mon, 30 Sep 2019 16:44:01 -0400 Received: by mail-wr1-f67.google.com with SMTP id v8so12886189wrt.2; Mon, 30 Sep 2019 13:43:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=teXekHXkibElMjuy/I4VdYi2D9nfW8tq92NFzmNTwQc=; b=dB7DFAoqTLYrUnIIMb7jp+RTLeMJmYC5aUWm96aflXizeCGha84H1r77ZG7+sNyqEw kwzDMIk69s0PN+8YLv24mpGt9jPF0mxOx+iaaxbmBfbLewg3WeIEf5SN3hZrCNQNFPvE SO+3XzcqY8TksKpLIkf0/7TsuQCl9+mG9eMSWIYvZPv+hy540djXZBxcgThmivm8xDse KW5lUswog/g8eSPOKKDHC6YOVCjKJxgXwTrUvCeVahJ1FMTuPdaD58yhFht00bnEJAH9 UhANQtm+w0kMbkOkrp8ipG/PIZbQooW240UXPbRhKE/grVT43kkc9lKnPZKrtRdF1fcv QKSw== 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:mime-version:content-transfer-encoding; bh=teXekHXkibElMjuy/I4VdYi2D9nfW8tq92NFzmNTwQc=; b=cHPi/aAglO9iRcwjWq2zEuT0svZ5wknHa2Ku+N5EKh8arf/hbiU3bVVbjMUaqqtv6X o72NfQroq/pBhve9pXxQhfwq0qGiy6T+guMuo6GqCesmt9kZsCxQ+6DQb7gNouV3UZZR svXCzNLG9IR4kQqo5LCHKHEOOP/kYWdo6OOTkH6Ye9PjwVQGrhos3ISXQsmf8L+0Otiy R2Ivxo2JBwfM+czmOZqzRby6Wc3QJSmjtBrdnDlZAvFZTykgVhCZXMvvu6oBKlYz9/8F +AhuATqWEk0gDYA1EpNSJTVhM6oorfuHqcrtX3iFu7uHBu+TrpsKNHnYw7R8SyXkcGb6 K7Mg== X-Gm-Message-State: APjAAAWa6hZ8/sLZYFzoOU8k+uf3CmvDtnLYzL3m8Z2z/8AADoVOPzpU bFW4LkzxJuJvpc5USIEn1jsoIMCCG5I= X-Google-Smtp-Source: APXvYqwqIZ5Y/V3nEsG58ppwE8WBexsMiSXHJ1gmDkZYpMXgTo2mPIGEnNWUFvkELYAUw5iJZ790aA== X-Received: by 2002:a5d:6049:: with SMTP id j9mr15261599wrt.213.1569869742513; Mon, 30 Sep 2019 11:55:42 -0700 (PDT) Received: from localhost.localdomain ([109.126.142.9]) by smtp.gmail.com with ESMTPSA id u83sm1131184wme.0.2019.09.30.11.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 11:55:42 -0700 (PDT) From: "Pavel Begunkov (Silence)" To: Jens Axboe , Christoph Hellwig , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pavel Begunkov Subject: [PATCH v2 1/2] blk-mq: Reuse callback in blk_mq_in_flight*() Date: Mon, 30 Sep 2019 21:55:33 +0300 Message-Id: <5ad78089aff5387a81e7655296ae326d4d96183d.1569868094.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Pavel Begunkov Reuse a more generic callback in both blk_mq_in_flight() and blk_mq_in_flight_rw(). Signed-off-by: Pavel Begunkov --- block/blk-mq.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index c4e5070c2ecd..3359a0b6c398 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -102,11 +102,8 @@ static bool blk_mq_check_inflight(struct blk_mq_hw_ctx *hctx, { struct mq_inflight *mi = priv; - /* - * index[0] counts the specific partition that was asked for. - */ if (rq->part == mi->part) - mi->inflight[0]++; + mi->inflight[rq_data_dir(rq)]++; return true; } @@ -119,19 +116,7 @@ unsigned int blk_mq_in_flight(struct request_queue *q, struct hd_struct *part) inflight[0] = inflight[1] = 0; blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight, &mi); - return inflight[0]; -} - -static bool blk_mq_check_inflight_rw(struct blk_mq_hw_ctx *hctx, - struct request *rq, void *priv, - bool reserved) -{ - struct mq_inflight *mi = priv; - - if (rq->part == mi->part) - mi->inflight[rq_data_dir(rq)]++; - - return true; + return inflight[0] + inflight[1]; } void blk_mq_in_flight_rw(struct request_queue *q, struct hd_struct *part, @@ -140,7 +125,7 @@ void blk_mq_in_flight_rw(struct request_queue *q, struct hd_struct *part, struct mq_inflight mi = { .part = part, .inflight = inflight, }; inflight[0] = inflight[1] = 0; - blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight_rw, &mi); + blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight, &mi); } void blk_freeze_queue_start(struct request_queue *q) From patchwork Mon Sep 30 18:55:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 11167463 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 099D6912 for ; Mon, 30 Sep 2019 20:53:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9ABA22500 for ; Mon, 30 Sep 2019 20:53:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kv2pXOlp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731581AbfI3Uxe (ORCPT ); Mon, 30 Sep 2019 16:53:34 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:40497 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727118AbfI3Uxe (ORCPT ); Mon, 30 Sep 2019 16:53:34 -0400 Received: by mail-wr1-f65.google.com with SMTP id l3so12871572wru.7; Mon, 30 Sep 2019 13:53:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2bu9cH1o0BJVB5OrcwUaFnQDN3/Qtc1RkyhexAVVqx4=; b=kv2pXOlpBCugCOp5kxNT6RU4VJx+nuADmtSd3uIY9Tq/kk0a9OGH6UofFKYovMfMj0 zePnSFNrBHEOtmetNUOFxvHMQW+2WHAvlSk6o6gV9Ag1apQD3hybdfzs2J5VgTAWszT4 kG/D4wglRiLRUmcnP9n8KYXoYxB9UMGElJLhdcILGwmYi3qNrg+vFT1UxlnX0CeOO+bo x9gOdXmNNKgVOsgDKjq/KnlY0rhZX7cryVc28OGZUIzTKZ9CXvTGwcUOfdNhGeICmART CP4pntQ2lYOTe3vvtBa50KYLAMXKw5ZLscyfBIOtD970bSMg0aB42khvPG14sqIfvLlV wcXQ== 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:mime-version:content-transfer-encoding; bh=2bu9cH1o0BJVB5OrcwUaFnQDN3/Qtc1RkyhexAVVqx4=; b=OYoqx648SsI1ZLfP4b8qItU7BPMgdySgKHSFzq0e7YajXvTSfTbuA9mtQJl6e100Si EblmvYqYtQ0c5twfZlhO95XPfzvLLIDyB2hcjI6wWdEBmD9PUokDDQn7kngsYWtbgGBQ GkhrcLf9G6/8Ma/fqv16mso5mlhvybjGlEoBUXW8TCVSs8H1gSSNFxdTnnVtap627Ncg fJLevg7YWJJoXkirpErbLNaW1TApAPaetbfgPJwS6fz5Jm2lTg9jT93l/kPKbzukyIq1 k06gjojclJp0prEpr9XqjtlyyxY3SvknFQUBIjKJH1jeJSkk30yMYMiSDtL7N4KI36in /pwA== X-Gm-Message-State: APjAAAUarCoZ4IcGNCIqRGUGDPRqQEdJtni6zCmhkYJz+To1KmeXK6WB FuM8QV2RUDVqZyYRucz3mIB/sLcbo7I= X-Google-Smtp-Source: APXvYqwaVxrPgUfy7StzNR3apPF8IB6CDqSnpQNMobiPcxZb4DsGDLK7k/zF4nLBjsKYQzSSNFlRjw== X-Received: by 2002:adf:e791:: with SMTP id n17mr10943405wrm.388.1569869743740; Mon, 30 Sep 2019 11:55:43 -0700 (PDT) Received: from localhost.localdomain ([109.126.142.9]) by smtp.gmail.com with ESMTPSA id u83sm1131184wme.0.2019.09.30.11.55.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 11:55:43 -0700 (PDT) From: "Pavel Begunkov (Silence)" To: Jens Axboe , Christoph Hellwig , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pavel Begunkov Subject: [PATCH v2 2/2] blk-mq: Embed counters into struct mq_inflight Date: Mon, 30 Sep 2019 21:55:34 +0300 Message-Id: <6f3392cd20e00cc1d6060bada86ca3db540de585.1569868094.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Pavel Begunkov Store inflight counters immediately in struct mq_inflight. That's type-safer and removes extra indirection. Signed-off-by: Pavel Begunkov --- block/blk-mq.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 3359a0b6c398..d97181d9a3ec 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -93,7 +93,7 @@ static void blk_mq_hctx_clear_pending(struct blk_mq_hw_ctx *hctx, struct mq_inflight { struct hd_struct *part; - unsigned int *inflight; + unsigned int inflight[2]; }; static bool blk_mq_check_inflight(struct blk_mq_hw_ctx *hctx, @@ -110,22 +110,21 @@ static bool blk_mq_check_inflight(struct blk_mq_hw_ctx *hctx, unsigned int blk_mq_in_flight(struct request_queue *q, struct hd_struct *part) { - unsigned inflight[2]; - struct mq_inflight mi = { .part = part, .inflight = inflight, }; + struct mq_inflight mi = { .part = part }; - inflight[0] = inflight[1] = 0; blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight, &mi); - return inflight[0] + inflight[1]; + return mi.inflight[0] + mi.inflight[1]; } void blk_mq_in_flight_rw(struct request_queue *q, struct hd_struct *part, unsigned int inflight[2]) { - struct mq_inflight mi = { .part = part, .inflight = inflight, }; + struct mq_inflight mi = { .part = part }; - inflight[0] = inflight[1] = 0; blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight, &mi); + inflight[0] = mi.inflight[0]; + inflight[1] = mi.inflight[1]; } void blk_freeze_queue_start(struct request_queue *q)