From patchwork Mon Jul 17 04:00:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 12105 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp894647vqt; Sun, 16 Jul 2023 21:07:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlHWr+cs6yAWR0lS/wqKqMldjtnEJ92PtMxai6Qlx0EosgHiJLqkaQgxnGRRS33qZHz078g0 X-Received: by 2002:a05:6a20:1383:b0:12b:fe14:907e with SMTP id hn3-20020a056a20138300b0012bfe14907emr10210367pzc.20.1689566874946; Sun, 16 Jul 2023 21:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689566874; cv=none; d=google.com; s=arc-20160816; b=oiYDaD9pMs4jLJMF+Mllv5XJ13Eo3xksNQTr1TbQlUu4zFje4t9/IuUAFc0Fv55Rmh lX9cJ6BnhgmBu0FQppYbrgcqmUhKKc24mhPwhDAM9RUQnGRDbHGX8jRAWXS9Nxh3lMzK xedVYzEnwg0GiLyL6fYgnIH5y79Z6X10RMwslN9OcYoJyj+afGeknUXOwjDm1AkT9kst KJ3t5Aek6znD3erK/c05jcra/kohiYaHvrEwlU0Nx+erz0Fl/u7re5lrX1LA3Vnfbmy4 IEBUFqD5k6gvpjgvRZkLh/pcG/d3Bl4eXFcYCQ5/6dkpywR8jeyTmNc6VKATQkgNwpQW 250Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=26hmSG3cG2qMCZKRMNmjIWTmveuGKUdShNQ0HXNAgXQ=; fh=o3CILnJq08Htpby3w3Eph3505qyaosLn1T+ze21qfHQ=; b=EWxB2FtgtudcIHYsSrn5W/AObu2GpYyHEyugDVpU6SAnuoPzf4sxDJE2KEPdySrbYb d18gUgfhfvOJRDtjQ2gj/O6qoRNhzQ34goMAIR73XSXPvso+sCMWV2lFQSDx05mc3jDa s/FPvf9c4EU8G36NG/VCbi+v1rkcPxIRFa3yplihCY8VmtwtxsR2VAPQ6Ra8G7iREqSx UJYhZhlLlVRyb2NWDhaMnlQnt3+FBGESHF5MFqKozatWb5P2OsFYVhO6UVFKsupk/PQu co+jAxZPEk5dVv78MZ7BPMmVZRngeRj1HG/WH5Rkm1rHaCZRiF7mEhv0SiU9fsPb9RCn C2xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=KT4Rcz6C; 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 f20-20020a056a0022d400b00681f56016b6si3604812pfj.57.2023.07.16.21.07.42; Sun, 16 Jul 2023 21:07:54 -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=KT4Rcz6C; 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 S230426AbjGQEB4 (ORCPT + 99 others); Mon, 17 Jul 2023 00:01:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230367AbjGQEBp (ORCPT ); Mon, 17 Jul 2023 00:01:45 -0400 Received: from out-57.mta0.migadu.com (out-57.mta0.migadu.com [91.218.175.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33D4EE41 for ; Sun, 16 Jul 2023 21:01:40 -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=1689566498; 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; bh=26hmSG3cG2qMCZKRMNmjIWTmveuGKUdShNQ0HXNAgXQ=; b=KT4Rcz6CdcyuiL90HQra1ibRCSc7FHSuWb9BOasmWz3ts1PocJEODxPlSJyVe+qCmWHfDj QPzUrxCYjH1fO34VkW1lk6xW4cEmZBwoDRji8kvBLKE6RQhe0xNQ9eD1aKITbnAEAiR8bL B4XWxTNnO9MShteo3pKdWZnSotdyXSU= From: chengming.zhou@linux.dev To: axboe@kernel.dk, ming.lei@redhat.com, hch@lst.de, bvanassche@acm.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, zhouchengming@bytedance.com Subject: [PATCH v4 0/4] blk-mq: optimize flush and request size Date: Mon, 17 Jul 2023 12:00:54 +0800 Message-ID: <20230717040058.3993930-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: INBOX X-GMAIL-THRID: 1771639275277839511 X-GMAIL-MSGID: 1771639275277839511 From: Chengming Zhou v4: - Rebase on the updated block/master branch, which include a flush bugfix from Christoph. Please help to check patch 04. Thanks! - Add a bugfix patch 02 for post-flush requests, put before other flush optimizations. - Collect Reviewed-by tags from Ming and Christoph. Thanks! - [v3] https://lore.kernel.org/lkml/20230707093722.1338589-1-chengming.zhou@linux.dev/ v3: - Collect Reviewed-by tags from Ming and Christoph. Thanks! - Remove the list and csd variables which are only used once. - Fix a bug report of blktests nvme/012 by re-initialization of rq->queuelist, which maybe corrupted by rq->rq_next reuse. - [v2] https://lore.kernel.org/all/20230629110359.1111832-1-chengming.zhou@linux.dev/ v2: - Change to use call_single_data_t, which use __aligned() to avoid to use 2 cache lines for 1 csd. Thanks Ming Lei. - [v1] https://lore.kernel.org/all/20230627120854.971475-1-chengming.zhou@linux.dev/ Hello, After the commit be4c427809b0 ("blk-mq: use the I/O scheduler for writes from the flush state machine"), rq->flush can't reuse rq->elv anymore, since flush_data requests can go into io scheduler now. That increased the size of struct request by 24 bytes, but this patchset can decrease the size by 40 bytes, which is good I think. patch 1 use percpu csd to do remote complete instead of per-rq csd, decrease the size by 24 bytes. patch 2 fixes a bug in blk-flush for post-flush requests. patch 3-4 reuse rq->queuelist in flush state machine pending list, and maintain unsigned long counter of inflight flush_data requests, decrease the size by 16 bytes. Thanks for comments! Chengming Zhou (4): blk-mq: use percpu csd to remote complete instead of per-rq csd blk-flush: fix rq->flush.seq for post-flush requests blk-flush: count inflight flush_data requests blk-flush: reuse rq queuelist in flush state machine block/blk-flush.c | 26 +++++++++++++++----------- block/blk-mq.c | 12 ++++++------ block/blk.h | 5 ++--- include/linux/blk-mq.h | 6 +----- 4 files changed, 24 insertions(+), 25 deletions(-)