Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1908631rdf; Sun, 5 Nov 2023 20:54:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4cIDFnx4eln741lx8erIc3tc9wrj0XCejpoAAuGusEd28QdceyFEbqm+G2uFqhoq4MxsF X-Received: by 2002:a05:6a00:2e29:b0:690:41a1:9b6a with SMTP id fc41-20020a056a002e2900b0069041a19b6amr34025844pfb.5.1699246492619; Sun, 05 Nov 2023 20:54:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699246492; cv=none; d=google.com; s=arc-20160816; b=ypgX9QXG6ixgTRfV83yejAcX0VbT+GclFpmljWpYv0I0ZdIiJteuzzgH0r3klfAexg ZfWZR/MuGWptmL6epAR3YbURAD16LrYBTUQrz9ng5VcOxWCmlY4LpqsxtZgDbmPN9rkK 17tRsq2ZKdYFMM2YZtef5KRVqS2Ko4AwDZcrVYJagzaCr3gTLXa05IcIg8yKa/afQ3dn H+iZibfhHQqrDP0il4eNqduYPSPuF2aLU2RGs0k7Xx16MSnz6FwYGe3OM1n5qidirvPR kYLZU42FQtz9CLEpmy5Fig/a2ibK6Hp/+fFHrynNP4zSZSykdzjv8KtdN9x1/zB4STJx mM6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=J0xxS0GcTpI1/DgZckR1OrAQOwxzwiXZ07noMlU8lfM=; fh=SRCoHmzcwnh4fOUPxV6ln2SqLdBASUk+kROegSfhjiM=; b=lBGIVLp5cKdULq3DQ+Dc3aqpo4cRO6sqKwkFx1epFIa7M6etRfhWx/cW34LY9q9Jyk LY3KullhSUw6iGWjdQJNZO1ZMiAYu0uaZHz3vWYCnGwzKmFkFPhrt5h/e+bpU8m18jG4 9zoWCYmB/pPfF2TFkX4qImAovdW2XKGHK9vOUyKv+MxmbcI9TjMrhOsVe+YoRucGwc/R 4S96UvbZn8gl2v0z/IxQ/CyyoldkjHC994ago4OxnSLQZ2OYdomf7gJ1N67XEPKkCLLI FFWtKy58w+jRZxCF0/kxqCVDvE4sidUqbqBHbzbOEuU5BaEnaru1z8npfREj2W1QYtPf Nigg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AEFJ7tT+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id w5-20020a056a0014c500b006be322191e1si7654823pfu.254.2023.11.05.20.54.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 20:54:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AEFJ7tT+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 11260805CAB7; Sun, 5 Nov 2023 20:54:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229485AbjKFEyj (ORCPT + 99 others); Sun, 5 Nov 2023 23:54:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229486AbjKFEyi (ORCPT ); Sun, 5 Nov 2023 23:54:38 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27806DB for ; Sun, 5 Nov 2023 20:53:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699246429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J0xxS0GcTpI1/DgZckR1OrAQOwxzwiXZ07noMlU8lfM=; b=AEFJ7tT+HqXL6aYtCxTT6GUZC6eSpd9bEZLxn/7lUo7YmQKg7NQph9ZFHQAEAlfzwhiup5 RpkOFuuR0K0vYoharAdfuGv7xjsyrT0ckQZs9D8pF5+b/zjZiSQlVlpzByVWHPgbtMUcfg LO9xYuCreKnMuGBNIFqAPjO6TceUmZo= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-88-u2guWhx7NOmnhhSHkQuB-w-1; Sun, 05 Nov 2023 23:53:45 -0500 X-MC-Unique: u2guWhx7NOmnhhSHkQuB-w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CBCEB380628F; Mon, 6 Nov 2023 04:53:44 +0000 (UTC) Received: from fedora (unknown [10.72.120.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F11372166B26; Mon, 6 Nov 2023 04:53:35 +0000 (UTC) Date: Mon, 6 Nov 2023 12:53:31 +0800 From: Ming Lei To: Ed Tsai =?utf-8?B?KOiUoeWul+i7kik=?= Cc: Will Shiu =?utf-8?B?KOioseaBreeRnCk=?= , "linux-mediatek@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Peter Wang =?utf-8?B?KOeOi+S/oeWPiyk=?= , "linux-block@vger.kernel.org" , Alice Chao =?utf-8?B?KOi2meePruWdhyk=?= , wsd_upstream , "axboe@kernel.dk" , Casper Li =?utf-8?B?KOadjuS4reamrik=?= , Chun-Hung Wu =?utf-8?B?KOW3q+mnv+Wujyk=?= , Powen Kao =?utf-8?B?KOmrmOS8r+aWhyk=?= , Naomi Chu =?utf-8?B?KOacseipoOeUsCk=?= , "linux-arm-kernel@lists.infradead.org" , Stanley Chu =?utf-8?B?KOacseWOn+mZnik=?= , "matthias.bgg@gmail.com" , "angelogioacchino.delregno@collabora.com" , ming.lei@redhat.com Subject: Re: [PATCH 1/1] block: Check the queue limit before bio submitting Message-ID: References: <20231025092255.27930-1-ed.tsai@mediatek.com> <64db8f5406571c2f89b70f852eb411320201abe6.camel@mediatek.com> <2bc847a83849973b7658145f2efdda86cc47e3d5.camel@mediatek.com> <5ecedad658bf28abf9bbeeb70dcac09b4b404cf5.camel@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5ecedad658bf28abf9bbeeb70dcac09b4b404cf5.camel@mediatek.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Spam-Status: No, score=-1.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sun, 05 Nov 2023 20:54:50 -0800 (PST) On Mon, Nov 06, 2023 at 01:40:12AM +0000, Ed Tsai (蔡宗軒) wrote: > On Mon, 2023-11-06 at 09:33 +0800, Ed Tsai wrote: > > On Sat, 2023-11-04 at 11:43 +0800, Ming Lei wrote: ... > Sorry for missing out on my dd command. Here it is: > dd if=/data/test_file of=/dev/null bs=64m count=1 iflag=direct OK, thanks for the sharing. I understand the issue now, but not sure if it is one good idea to check queue limit in __bio_iov_iter_get_pages(): 1) bio->bi_bdev may not be set 2) what matters is actually bio's alignment, and bio size still can be big enough So I cooked one patch, and it should address your issue: diff --git a/block/bio.c b/block/bio.c index 816d412c06e9..7d982e74c65d 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1266,6 +1266,24 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) size -= trim; } + /* + * Try to make bio aligned with 128KB if there are pages left so we + * can avoid small bio in case of big chunk sequential IO + */ + if (iov_iter_count(iter)) { + unsigned curr_size = (bio->bi_iter.bi_size + size) & + ~((128U << 10) - 1); + if (curr_size <= bio->bi_iter.bi_size) { + ret = left = size; + goto revert; + } else { + curr_size -= bio->bi_iter.bi_size; + ret = size - curr_size; + iov_iter_revert(iter, ret); + size = curr_size; + } + } + if (unlikely(!size)) { ret = -EFAULT; goto out; @@ -1285,7 +1303,7 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) offset = 0; } - +revert: iov_iter_revert(iter, left); out: while (i < nr_pages) Thanks, Ming