From patchwork Tue Jul 25 13:00: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: 12585 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2481489vqg; Tue, 25 Jul 2023 06:47:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlFnj4IrEysoenD16BSLuQWXflIOOCW2zBaYNxeVNqC6jHwXM5G5k0Cokkj35C0/JAyFLsxd X-Received: by 2002:a2e:b008:0:b0:2b6:ce35:2e9e with SMTP id y8-20020a2eb008000000b002b6ce352e9emr8425659ljk.44.1690292836032; Tue, 25 Jul 2023 06:47:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690292836; cv=none; d=google.com; s=arc-20160816; b=rJcdS+nuqUmoKrzoz1kL73d/JLyV4hZfoLKRtyw/gLJ3mGzmr5zx/S0+FMYEQCqvTL moswgAXwUKZhwWjRjGN6KthKts6/Rd3OYh2vMz4ralFfe1JF7wiJ2+fvcCoR5/VudKYL 7+y0Jv/9eFc3dazq/x+gI3saBrFpQbUZYaYUclXpUR5kIJ8iiRXu+y5Khmx4rrMnarrE 41tCedHFGioyRlpNB6zSMCFgnqDC2fRuqf90vswL0QAdwPIUVq2e1w5yZkgDz+EDMAad Tp+kMR16qMv2e/IeTbh6jG3JYzlE248gY1PvurG/2DAbkly24VQ4il0r1sFgmuxDvL5z IRJw== 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=o1A965Rmyit4V/K6hD1sBav9uLDra+3bpcOqxUt5eIs=; fh=4fzGWvE2LW7K10hgePOrl39slR3lbqz4nggQweyfPdc=; b=edS0JJWQPerV2M3lUh1ylUqGD1iYvIfFrvkKlFOBf9o1MYTFrNntcSr8FgGCAq1Tie P4+NxBRx7nlUseC3Ttt3ISjGCxUT/m159vJatE9XzRJ4RHaTB8iDKekn93+sR5/6KT6x Wfj5X2D2Fl1IAdf3nLCoV9fWNpibDO404oiGYjouRFqy9awjvAc7zCAY5ppVIc8SRudi oCX5L3MHmGMkl6gRp8hbuNekP+NiE3zJR586F9hA/Q329udLr1BNQQj9t725o4tlH2gx GRLlaHZGgEphIYuziDLxojfnesIMhI9ltqDM0KDtYihmBwvYNVtvJGgFwqDxJXC9kRAF 6KZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=dPQBmSow; 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 w8-20020a1709062f8800b00993398bcae2si7891151eji.122.2023.07.25.06.46.51; Tue, 25 Jul 2023 06:47:15 -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=dPQBmSow; 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 S229839AbjGYNTB (ORCPT + 99 others); Tue, 25 Jul 2023 09:19:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229830AbjGYNTA (ORCPT ); Tue, 25 Jul 2023 09:19:00 -0400 Received: from out-20.mta0.migadu.com (out-20.mta0.migadu.com [IPv6:2001:41d0:1004:224b::14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 266E310F6 for ; Tue, 25 Jul 2023 06:18:55 -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=1690291134; 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=o1A965Rmyit4V/K6hD1sBav9uLDra+3bpcOqxUt5eIs=; b=dPQBmSow5zQ4A2h2IYNoiNHUFfJmLfcnSv2nvtsExxlV4Q65g4JsN5MjLbRrK4f7Lt9qcI jwZUEhIvQq1paurJo4WxrU2RJFmxmdOjfv78KRNXDJliXJ5WmWjidD283EKIHlbKA9oJNm pUaFguEEtnzYC5DAAeoQIrxTrTbgfB4= From: chengming.zhou@linux.dev To: axboe@kernel.dk, hch@lst.de, ming.lei@redhat.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, zhouchengming@bytedance.com Subject: [PATCH v2 0/4] blk-flush: optimize non-postflush requests Date: Tue, 25 Jul 2023 21:00:58 +0800 Message-ID: <20230725130102.3030032-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,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1772400500712637895 X-GMAIL-MSGID: 1772400500712637895 From: Chengming Zhou Hello, This series optimize flush handling for non-postflush requests. Now we unconditionally replace rq->end_io to make rq return twice back to the flush state machine for post-flush. Obviously, non-postflush requests don't need it, they don't need to end request twice, so they don't need to replace rq->end_io callback. And the same for requests with the FUA bit on hardware with FUA support. The previous approach [1] we take is to move blk_rq_init_flush() to REQ_FSEQ_DATA stage and only replace rq->end_io if it needs post-flush. But this way add more magic to the already way too magic flush sequence. Christoph suggested that we can kill the flush sequence entirely, and just split the flush_queue into a preflush and a postflush queue. So this series implement the suggested approach that use two queues: preflush and postflush requests have separate pending list and running list, so we know what to do for each request in flush_end_io(), and we don't need the flush sequence entirely. Thanks for comments! [1] https://lore.kernel.org/lkml/20230710133308.GB23157@lst.de/ Chengming Zhou (4): blk-flush: flush_rq should inherit first_rq's cmd_flags blk-flush: split queues for preflush and postflush requests blk-flush: kill the flush state machine blk-flush: don't need to end rq twice for non postflush block/blk-flush.c | 181 +++++++++++++++++++++-------------------- block/blk.h | 3 +- include/linux/blk-mq.h | 1 - 3 files changed, 96 insertions(+), 89 deletions(-)