From patchwork Thu Jun 29 11:03:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 114280 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9576019vqr; Thu, 29 Jun 2023 04:49:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ53OI1cx5pzfPwVhauGAvr23QRn47repy/3HV6ZyTmQSSOIbUKkepYZq5Ru5sUqQo36BaHp X-Received: by 2002:a05:6a20:8f04:b0:121:d102:248c with SMTP id b4-20020a056a208f0400b00121d102248cmr36283270pzk.6.1688039356162; Thu, 29 Jun 2023 04:49:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688039356; cv=none; d=google.com; s=arc-20160816; b=JqoQLPw+LyhuhEMpCCKBSQPYKFUTGwXEE7xBFwzDHAmhtGpNH0d+0676OvfUaEYpOp MBEeXK0p7trLiUT5+vLS8KiWfctV1oZJGFsmc7URHgdswbYbzSN83drhh+l/iywFWP8n A8mACVcK+w0FquqZrdhiNPTX8gVJPYCPnjsH4kxTNeyspITct3ARFZzWqbXlvB70VrAg ujnGutKN6sl4L40ZP+/ufJzH/6v4pacQztiuWvmxF6LzjCTthwhWJleM9Z7r4WI/gI0L FGHvjdYBIsXqBlCYgh0eND6Tdjw5ICOgk8+L9ZCPn6F3tVy7XtR0xpJoEDMEUJMdnIAD Rf/g== 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=dNin81+NgdWvZKUgysygT1wpEuRFau3v3obyeOkX5fM=; fh=jVO2EC1fXvr6Bl8+7yHtFIrYqo7iQ9dvd55sFdmq7po=; b=qzrDymcgYxGWRo0vVNT/VhxiOEKg2IF9p+avSdXpOHc38oEpDovFvXaWCs0HbcCq5q 760MTOS+pep7nUoVNxjeD3LjoL2+RFkZsIkVDiaJfmVKZOKjAQzyvl4HHBrZcbfYA2ER IVlC/umSTEzGS7eaF0mPPORFczPWJrAb1RPp4Eldpxk7+MbkhpkvuM2Eq4NYVhRTlzoH eIdAFfiEAjiDnV4k8KAmZYb2MKe8emLysBplDNH9RU49VACEa49rs7OwdtmuU3X19xG/ /pHucqgqIeIUvA7N9CaqbmmhFkHaAQSSp0st0TiXauvvpjG2pdroJBVjHTjMfRFx07oe 8rdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=wwqEmJdr; 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=linux.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bg1-20020a17090b0d8100b00262db07eda9si9040258pjb.120.2023.06.29.04.49.00; Thu, 29 Jun 2023 04:49:16 -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=@linux.dev header.s=key1 header.b=wwqEmJdr; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232192AbjF2LHW (ORCPT + 99 others); Thu, 29 Jun 2023 07:07:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232138AbjF2LHQ (ORCPT ); Thu, 29 Jun 2023 07:07:16 -0400 Received: from out-55.mta1.migadu.com (out-55.mta1.migadu.com [IPv6:2001:41d0:203:375::37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94B16E72 for ; Thu, 29 Jun 2023 04:07:15 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1688036833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dNin81+NgdWvZKUgysygT1wpEuRFau3v3obyeOkX5fM=; b=wwqEmJdrPmGhPaPCNNeah4+ETGQTleAhQTC7xostmyZuZdJychdvBYIDsi+H4x6MrfHW8p c6P2ePqkoYs95JZypBggJd7pyt64ZMEfrqpnao0izFegeXWFKgAL8UwFUZRoOWGW+V21oL hto1QBQcoDWwYWAKXB5SN1k+aLYpCkk= From: chengming.zhou@linux.dev To: axboe@kernel.dk, ming.lei@redhat.com, hch@lst.de, tj@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Chengming Zhou Subject: [PATCH v2 1/4] blk-mq: use percpu csd to remote complete instead of per-rq csd Date: Thu, 29 Jun 2023 19:03:56 +0800 Message-Id: <20230629110359.1111832-2-chengming.zhou@linux.dev> In-Reply-To: <20230629110359.1111832-1-chengming.zhou@linux.dev> References: <20230629110359.1111832-1-chengming.zhou@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770037555991353154?= X-GMAIL-MSGID: =?utf-8?q?1770037555991353154?= From: Chengming Zhou If request need to be completed remotely, we insert it into percpu llist, and smp_call_function_single_async() if llist is empty previously. We don't need to use per-rq csd, percpu csd is enough. And the size of struct request is decreased by 24 bytes. This way is cleaner, and looks correct, given block softirq is guaranteed to be scheduled to consume the list if one new request is added to this percpu list, either smp_call_function_single_async() returns -EBUSY or 0. Signed-off-by: Chengming Zhou Reviewed-by: Ming Lei --- v2: - Change to use call_single_data_t, which avoid to use 2 cache lines for 1 csd, as suggested by Ming Lei. - Improve the commit log, the explanation is copied from Ming Lei. --- block/blk-mq.c | 12 ++++++++---- include/linux/blk-mq.h | 5 +---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index decb6ab2d508..e52200edd2b1 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -43,6 +43,7 @@ #include "blk-ioprio.h" static DEFINE_PER_CPU(struct llist_head, blk_cpu_done); +static DEFINE_PER_CPU(call_single_data_t, blk_cpu_csd); static void blk_mq_insert_request(struct request *rq, blk_insert_t flags); static void blk_mq_request_bypass_insert(struct request *rq, @@ -1156,13 +1157,13 @@ static void blk_mq_complete_send_ipi(struct request *rq) { struct llist_head *list; unsigned int cpu; + call_single_data_t *csd; cpu = rq->mq_ctx->cpu; list = &per_cpu(blk_cpu_done, cpu); - if (llist_add(&rq->ipi_list, list)) { - INIT_CSD(&rq->csd, __blk_mq_complete_request_remote, rq); - smp_call_function_single_async(cpu, &rq->csd); - } + csd = &per_cpu(blk_cpu_csd, cpu); + if (llist_add(&rq->ipi_list, list)) + smp_call_function_single_async(cpu, csd); } static void blk_mq_raise_softirq(struct request *rq) @@ -4796,6 +4797,9 @@ static int __init blk_mq_init(void) for_each_possible_cpu(i) init_llist_head(&per_cpu(blk_cpu_done, i)); + for_each_possible_cpu(i) + INIT_CSD(&per_cpu(blk_cpu_csd, i), + __blk_mq_complete_request_remote, NULL); open_softirq(BLOCK_SOFTIRQ, blk_done_softirq); cpuhp_setup_state_nocalls(CPUHP_BLOCK_SOFTIRQ_DEAD, diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index f401067ac03a..070551197c0e 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -182,10 +182,7 @@ struct request { rq_end_io_fn *saved_end_io; } flush; - union { - struct __call_single_data csd; - u64 fifo_time; - }; + u64 fifo_time; /* * completion callback. From patchwork Thu Jun 29 11:03:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 114282 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9576453vqr; Thu, 29 Jun 2023 04:50:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlEW7N6NwP4WOWje8KT7OUkFym5Pt3nNudE4oG9WzII8tAu1Xqes+nrdwHaXy/2DOXyHsOJC X-Received: by 2002:a17:902:a9cb:b0:1b8:17e8:547e with SMTP id b11-20020a170902a9cb00b001b817e8547emr2139155plr.1.1688039406460; Thu, 29 Jun 2023 04:50:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688039406; cv=none; d=google.com; s=arc-20160816; b=oLCrf+zwHnc966ZQ08SfUoLRGSAZ4nXQ/2ervrMo4eyqaNzXQqgzoBfsXJyuVZUv1V zX7xA12s4Cabh2foX5N+V/VdIASbA2jbMQv2N+fP2DiM349m24gEwMJCSBP2l7+cakPE stq+TFXQY+ArAoWcjdLyC1GmZ5+pvADnsAECXxdSY1nippMZAKpTOGXWFlXbtnEk+iA4 dgbBkOJJXnQXJ1853E6XwG8Qg7Hkzy9Hspi88VOTWpGS2H8Zxrw4fWwFQtdyvNcA9qbG /NHzOfMpoOYd5WtfC7DG+jCLG82rLeK2WsBDJuXWt1S+5HvOsw778fAPrkWC7EBxWGiU +lhA== 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=MamvVjI1jeXw3Kjngjhi6g/DzhtYYjp3x8kVfhCNxDw=; fh=jVO2EC1fXvr6Bl8+7yHtFIrYqo7iQ9dvd55sFdmq7po=; b=r+7CjgLXabLIDd8iaeJ55eW+AJHLur/6SI6aNcWSq0FzaJtlnjWJlx9aof09PYFRcL KZP/NXLpLxZXjzz1KDkZwILL387zmgOKGMhq3WpSiWmo92RlWpdfM68VcUWaJrobZMPT l3di98g/LBRFajWsQu6IDSy0kgoMbdXU/0231Bv3fUXYb/rDsXbErfGN5I+pz7r8znfV vwXFFDoH1MdwtUqgs1g7KWhfgdpRVWxk9CMskYdaGXOd8NZV+vdxc+aljA9dqya4U1g5 xv9cvBnnNogwzussKyxZ5NHpQKDxs1GgnktzYu+Xw7aOtExCW+VyGJYYc8rQz5Ll9REC lU7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=gLJaqTIY; 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=linux.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c13-20020a170902d48d00b001b830766505si3559459plg.112.2023.06.29.04.49.53; Thu, 29 Jun 2023 04:50:06 -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=@linux.dev header.s=key1 header.b=gLJaqTIY; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232255AbjF2LHc (ORCPT + 99 others); Thu, 29 Jun 2023 07:07:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232170AbjF2LHU (ORCPT ); Thu, 29 Jun 2023 07:07:20 -0400 Received: from out-53.mta1.migadu.com (out-53.mta1.migadu.com [95.215.58.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F3E31FD7 for ; Thu, 29 Jun 2023 04:07:18 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1688036836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MamvVjI1jeXw3Kjngjhi6g/DzhtYYjp3x8kVfhCNxDw=; b=gLJaqTIYrWNNdCKmHcyxDtI7XwL0mz5l3b8romo8vPvm3yG7ob3tBombjqyDMsDaGTHxQb +kHsA+GFLKWIs8pAEGKOvbbzIVfb/nq9my9qTM5RpeenzPBIiyKWjry3rp6b7NL5Rz8VSt 15Y7uKyzuXr8dJjMaVC2yBqu+gsqTXE= From: chengming.zhou@linux.dev To: axboe@kernel.dk, ming.lei@redhat.com, hch@lst.de, tj@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Chengming Zhou Subject: [PATCH v2 2/4] blk-flush: count inflight flush_data requests Date: Thu, 29 Jun 2023 19:03:57 +0800 Message-Id: <20230629110359.1111832-3-chengming.zhou@linux.dev> In-Reply-To: <20230629110359.1111832-1-chengming.zhou@linux.dev> References: <20230629110359.1111832-1-chengming.zhou@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770037608582322517?= X-GMAIL-MSGID: =?utf-8?q?1770037608582322517?= From: Chengming Zhou The flush state machine use a double list to link all inflight flush_data requests, to avoid issuing separate post-flushes for these flush_data requests which shared PREFLUSH. So we can't reuse rq->queuelist, this is why we need rq->flush.list In preparation of the next patch that reuse rq->queuelist for flush state machine, we change the double linked list to unsigned long counter, which count all inflight flush_data requests. This is ok since we only need to know if there is any inflight flush_data request, so unsigned long counter is good. Signed-off-by: Chengming Zhou Reviewed-by: Ming Lei Reviewed-by: Christoph Hellwig --- block/blk-flush.c | 9 +++++---- block/blk.h | 5 ++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/block/blk-flush.c b/block/blk-flush.c index dba392cf22be..bb7adfc2a5da 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c @@ -187,7 +187,8 @@ static void blk_flush_complete_seq(struct request *rq, break; case REQ_FSEQ_DATA: - list_move_tail(&rq->flush.list, &fq->flush_data_in_flight); + list_del_init(&rq->flush.list); + fq->flush_data_in_flight++; spin_lock(&q->requeue_lock); list_add_tail(&rq->queuelist, &q->flush_list); spin_unlock(&q->requeue_lock); @@ -299,7 +300,7 @@ static void blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq, return; /* C2 and C3 */ - if (!list_empty(&fq->flush_data_in_flight) && + if (fq->flush_data_in_flight && time_before(jiffies, fq->flush_pending_since + FLUSH_PENDING_TIMEOUT)) return; @@ -374,6 +375,7 @@ static enum rq_end_io_ret mq_flush_data_end_io(struct request *rq, * the comment in flush_end_io(). */ spin_lock_irqsave(&fq->mq_flush_lock, flags); + fq->flush_data_in_flight--; blk_flush_complete_seq(rq, fq, REQ_FSEQ_DATA, error); spin_unlock_irqrestore(&fq->mq_flush_lock, flags); @@ -445,7 +447,7 @@ bool blk_insert_flush(struct request *rq) blk_rq_init_flush(rq); rq->flush.seq |= REQ_FSEQ_POSTFLUSH; spin_lock_irq(&fq->mq_flush_lock); - list_move_tail(&rq->flush.list, &fq->flush_data_in_flight); + fq->flush_data_in_flight++; spin_unlock_irq(&fq->mq_flush_lock); return false; default: @@ -496,7 +498,6 @@ struct blk_flush_queue *blk_alloc_flush_queue(int node, int cmd_size, INIT_LIST_HEAD(&fq->flush_queue[0]); INIT_LIST_HEAD(&fq->flush_queue[1]); - INIT_LIST_HEAD(&fq->flush_data_in_flight); return fq; diff --git a/block/blk.h b/block/blk.h index 608c5dcc516b..686712e13835 100644 --- a/block/blk.h +++ b/block/blk.h @@ -15,15 +15,14 @@ struct elevator_type; extern struct dentry *blk_debugfs_root; struct blk_flush_queue { + spinlock_t mq_flush_lock; unsigned int flush_pending_idx:1; unsigned int flush_running_idx:1; blk_status_t rq_status; unsigned long flush_pending_since; struct list_head flush_queue[2]; - struct list_head flush_data_in_flight; + unsigned long flush_data_in_flight; struct request *flush_rq; - - spinlock_t mq_flush_lock; }; bool is_flush_rq(struct request *req); From patchwork Thu Jun 29 11:03:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 114281 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9576255vqr; Thu, 29 Jun 2023 04:49:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlH2jNVwjum+giO56QQeGqGRhSJtuBWAWNWSh0pwrrIKOKYvD7APXLbA75y8NZQ+dH+ZpIP5 X-Received: by 2002:a17:90b:3c83:b0:263:5c30:2cf8 with SMTP id pv3-20020a17090b3c8300b002635c302cf8mr1491901pjb.0.1688039384669; Thu, 29 Jun 2023 04:49:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688039384; cv=none; d=google.com; s=arc-20160816; b=IOOm6Uoi8gp8nQxYGchRSN45NPi3HvuDHkZSItI31T/dRY4Hzfh+llRluye17ySd0A 9cmwHlbouv7x79G4J+9U4ZC2A81JG4sK5W+d1DNQgDi5iwV0dn5aAHGmsYqatS2GsZ0w URMreeMQQWBs6+npAvxVrD0rImNqiT1QyT3yTm9IwNy/wDhLok45zwm3ippAOA1VuT1r 2AJ8AyvvKbOvx/siAvfceC4SiYm5zft+tAAwsrUpNxrYO9iUDh1OT9yADL42F5i6GW3M dxjxEwDb+JnEYlyphHRXlcxbOALLUuW4NwCFT/5eRMoOJBJKRsWpiPZoty9ROg9VZ8mv h2OA== 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=hdKaqogn/I3BFaAaWb1R9T3dUmGgvZb8Wo54xKMjRbQ=; fh=jVO2EC1fXvr6Bl8+7yHtFIrYqo7iQ9dvd55sFdmq7po=; b=ily0yIwQ7aAmtUG42dVeCO/ejDdcOzA7SgNjz3Yh/yXVIZ9NGvy8qazcBAxwzv++s8 SafrinYytU6Tdln83k8RnMA/SkRLHYjBeLQgHKpHTVuvP/3pgZnrPmAs9s5jW31zpUO+ Vl9xPoUCPb0PMuaV91n6KzL8jJ1u1+kb0tyRjRaD6NRj6EAh3fi053REhtdJW9Wzppwe oTj0xS+muJx/FMlDOggWfK6dDPT+wrYChJ94LYIddOAU83caAFHr+bHizTfo25E0aR2i EOwUKJ9F+2PewRYX8gSZdRKlst44dlTSiVRUyMlxmp+tYNEC8aH+yq1wEqYpGHK8hddB fjMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Silj4Fte; 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=linux.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a17090aca8d00b0025e81971635si12799290pjt.24.2023.06.29.04.49.28; Thu, 29 Jun 2023 04:49:44 -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=@linux.dev header.s=key1 header.b=Silj4Fte; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232292AbjF2LHq (ORCPT + 99 others); Thu, 29 Jun 2023 07:07:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232197AbjF2LHW (ORCPT ); Thu, 29 Jun 2023 07:07:22 -0400 Received: from out-52.mta1.migadu.com (out-52.mta1.migadu.com [95.215.58.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C0B11FCB for ; Thu, 29 Jun 2023 04:07:20 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1688036839; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hdKaqogn/I3BFaAaWb1R9T3dUmGgvZb8Wo54xKMjRbQ=; b=Silj4FteQiWcNtz1G5WBCi+kTB4VQErkWfbaa7zSefq9ofMpCw2enGXVGq1vM3jhZTLgFn NEpX1/qmz+ji/HU91h7L4sqAwSCrqyD+NBNJCJer5WZU0VA0mzEShHlAz39RAbTxvuJ6UF SZ1nj4EpaWnZkhJ282cITiMpW021VZQ= From: chengming.zhou@linux.dev To: axboe@kernel.dk, ming.lei@redhat.com, hch@lst.de, tj@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Chengming Zhou Subject: [PATCH v2 3/4] blk-flush: reuse rq queuelist in flush state machine Date: Thu, 29 Jun 2023 19:03:58 +0800 Message-Id: <20230629110359.1111832-4-chengming.zhou@linux.dev> In-Reply-To: <20230629110359.1111832-1-chengming.zhou@linux.dev> References: <20230629110359.1111832-1-chengming.zhou@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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?1770037586198173364?= X-GMAIL-MSGID: =?utf-8?q?1770037586198173364?= From: Chengming Zhou Since we don't need to maintain inflight flush_data requests list anymore, we can reuse rq->queuelist for flush pending list. This patch decrease the size of struct request by 16 bytes. Signed-off-by: Chengming Zhou Reviewed-by: Christoph Hellwig --- block/blk-flush.c | 12 +++++------- include/linux/blk-mq.h | 1 - 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/block/blk-flush.c b/block/blk-flush.c index bb7adfc2a5da..81588edbe8b0 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c @@ -183,14 +183,13 @@ static void blk_flush_complete_seq(struct request *rq, /* queue for flush */ if (list_empty(pending)) fq->flush_pending_since = jiffies; - list_move_tail(&rq->flush.list, pending); + list_move_tail(&rq->queuelist, pending); break; case REQ_FSEQ_DATA: - list_del_init(&rq->flush.list); fq->flush_data_in_flight++; spin_lock(&q->requeue_lock); - list_add_tail(&rq->queuelist, &q->flush_list); + list_move_tail(&rq->queuelist, &q->flush_list); spin_unlock(&q->requeue_lock); blk_mq_kick_requeue_list(q); break; @@ -202,7 +201,7 @@ static void blk_flush_complete_seq(struct request *rq, * flush data request completion path. Restore @rq for * normal completion and end it. */ - list_del_init(&rq->flush.list); + list_del_init(&rq->queuelist); blk_flush_restore_request(rq); blk_mq_end_request(rq, error); break; @@ -258,7 +257,7 @@ static enum rq_end_io_ret flush_end_io(struct request *flush_rq, fq->flush_running_idx ^= 1; /* and push the waiting requests to the next stage */ - list_for_each_entry_safe(rq, n, running, flush.list) { + list_for_each_entry_safe(rq, n, running, queuelist) { unsigned int seq = blk_flush_cur_seq(rq); BUG_ON(seq != REQ_FSEQ_PREFLUSH && seq != REQ_FSEQ_POSTFLUSH); @@ -292,7 +291,7 @@ static void blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq, { struct list_head *pending = &fq->flush_queue[fq->flush_pending_idx]; struct request *first_rq = - list_first_entry(pending, struct request, flush.list); + list_first_entry(pending, struct request, queuelist); struct request *flush_rq = fq->flush_rq; /* C1 described at the top of this file */ @@ -386,7 +385,6 @@ static enum rq_end_io_ret mq_flush_data_end_io(struct request *rq, static void blk_rq_init_flush(struct request *rq) { rq->flush.seq = 0; - INIT_LIST_HEAD(&rq->flush.list); rq->rq_flags |= RQF_FLUSH_SEQ; rq->flush.saved_end_io = rq->end_io; /* Usually NULL */ rq->end_io = mq_flush_data_end_io; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 070551197c0e..96644d6f8d18 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -178,7 +178,6 @@ struct request { struct { unsigned int seq; - struct list_head list; rq_end_io_fn *saved_end_io; } flush; From patchwork Thu Jun 29 11:03:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 114277 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9561391vqr; Thu, 29 Jun 2023 04:20:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5MR2NYSkb8mT/FWsf7qKkfZBhPhM69W2cH4FJDhjLWpFL+NrS96sPVsKNNB0LjjLGDJHTd X-Received: by 2002:a05:6a00:24cf:b0:676:2a5c:7bc5 with SMTP id d15-20020a056a0024cf00b006762a5c7bc5mr13976342pfv.1.1688037647565; Thu, 29 Jun 2023 04:20:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688037647; cv=none; d=google.com; s=arc-20160816; b=CjO/ukQd41qh91l1OdT1kM7cGTlW1RrKPmWvwtIZk54JM8jzmxDMpnxi0SNA4nGrL9 EHAFfqOCxlMZRu8J06mkzYFsVwsiW5cSngGx6j7CKxCppSwSKDzI3aXntTbvO70znTAt vf9C9TGE0c5+Ivk9bWCa6Tu93hkPb7S0pmfR3X9fek9qpMdEa7UmuKeonvhErgrR3w5M b+cCISZnZsBNcUkG70AoHc7HUT2lfFde2XXB6jpKataKikZ+bv+1suSKjGMES4AoEPOS RlYJwJTZRrpBcw9JBhYojjQHfgOg5yTt6TO6TDULu60G0aghX8nqIlq5bnfbDBlre03Z 9NWg== 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=/O8YJWAa7A//A8YJ1hLAuWA8H/d3IRDfJMQYLuFl59Q=; fh=jVO2EC1fXvr6Bl8+7yHtFIrYqo7iQ9dvd55sFdmq7po=; b=QfouMbCiHOGVhrcdmxVBtJI74Ztcmx2mWnF0PLDi+igwpby4FAiX8GGWWAVt7BXJ1s Ezqsg6599WbFykFqgTrNf1GwxicL9mKozYWqvSEFf3duROZWARqm6TXN3r6F6Pv2qvt8 9UR5vFqHkLhhVBRGnFehtxOjIkEBwGXdmNxIa2O7QhbxlNPPOknJURnopn57c+9idw6f pQ/DdAU24UGpIP89DJv19aRfBNGDGWDre3dIGJ6R7IAUF2ykoBjr2S0D877HDVpV6745 ur/SBpCacWqLNL91nTfdT7bucryUESTiQ8Xvd3A5IRVDMBpEdfZNkHfteYQKObq2j8p7 C09A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=mbIzMFKm; 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=linux.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t189-20020a6381c6000000b0054fe9faf30bsi128303pgd.562.2023.06.29.04.20.29; Thu, 29 Jun 2023 04:20:47 -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=@linux.dev header.s=key1 header.b=mbIzMFKm; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231855AbjF2LH7 (ORCPT + 99 others); Thu, 29 Jun 2023 07:07:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232180AbjF2LHZ (ORCPT ); Thu, 29 Jun 2023 07:07:25 -0400 Received: from out-12.mta1.migadu.com (out-12.mta1.migadu.com [IPv6:2001:41d0:203:375::c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F408294E for ; Thu, 29 Jun 2023 04:07:24 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1688036842; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/O8YJWAa7A//A8YJ1hLAuWA8H/d3IRDfJMQYLuFl59Q=; b=mbIzMFKmGOLPlHTie0bZkFzRR4kKsmNBsTYTIAcXDY9PhKLh+AWN83tEAps+QrlCmHpQJ5 6vPVir4H9Ri7Ue7A0rX45a+10TN8gVkVcHKOdW31Bm1xjWYh2rKJU5FdRDZn+3xBXxdoKu lTL8df0btTRLK09OBxfpmKmt+c9Wkm4= From: chengming.zhou@linux.dev To: axboe@kernel.dk, ming.lei@redhat.com, hch@lst.de, tj@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Chengming Zhou Subject: [PATCH v2 4/4] blk-mq: delete unused completion_data in struct request Date: Thu, 29 Jun 2023 19:03:59 +0800 Message-Id: <20230629110359.1111832-5-chengming.zhou@linux.dev> In-Reply-To: <20230629110359.1111832-1-chengming.zhou@linux.dev> References: <20230629110359.1111832-1-chengming.zhou@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770035764243537135?= X-GMAIL-MSGID: =?utf-8?q?1770035764243537135?= From: Chengming Zhou After global search, I found "completion_data" in struct request is not used anywhere, so just clean it up by the way. Signed-off-by: Chengming Zhou Reviewed-by: Christoph Hellwig --- include/linux/blk-mq.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 96644d6f8d18..ab790eba5fcf 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -158,13 +158,11 @@ struct request { /* * The rb_node is only used inside the io scheduler, requests - * are pruned when moved to the dispatch queue. So let the - * completion_data share space with the rb_node. + * are pruned when moved to the dispatch queue. */ union { struct rb_node rb_node; /* sort/lookup */ struct bio_vec special_vec; - void *completion_data; }; /*