From nobody Sun Dec 14 19:20:11 2025
Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 919E113212A;
Thu, 22 May 2025 09:03:15 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
arc=none smtp.client-ip=80.241.56.151
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1747904597; cv=none;
b=PFNSXrh10IcV7NYhS+P96pxCoUdEJOUh0whTlNq/vxvOCtRIrrxzgAxwXykJIHyBINwSAOce2jVF3au7f5N8LypM1LSpqKPCusx0V28pQtxuh7645xjNDN2zmRf78pu2Dw2ro7U3q3nmKpziWBvzLuzA7zLvZi9VloRtaNFbA+A=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1747904597; c=relaxed/simple;
bh=/2FzKQy6N923y+2/aYeRTf7lFGlB3ZaKNCL5XEte00g=;
h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
MIME-Version;
b=LO6ozZayc1buD1UhtWvIy1v1PjZb72C1cDAESYcp5PHqZ2mIpMsxNGbz25UZoG/Mcj9pn/htR3DX2H4kQqEbYgxpQ3Y265y4D0DODWiw2AlX+I6tu8+87TFwT7NzRpsf44kXRkc2+gbU1KiNlKEItpEfK3R+kZvregewiGv7i9A=
ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=fail (p=none dis=none) header.from=samsung.com;
spf=pass smtp.mailfrom=pankajraghav.com;
arc=none smtp.client-ip=80.241.56.151
Authentication-Results: smtp.subspace.kernel.org;
dmarc=fail (p=none dis=none) header.from=samsung.com
Authentication-Results: smtp.subspace.kernel.org;
spf=pass smtp.mailfrom=pankajraghav.com
Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest
SHA256)
(No client certificate requested)
by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4b32Pq2VNhz9t4X;
Thu, 22 May 2025 11:03:11 +0200 (CEST)
From: Pankaj Raghav
To: Suren Baghdasaryan ,
Vlastimil Babka ,
Ryan Roberts ,
Mike Rapoport ,
Michal Hocko ,
Thomas Gleixner ,
Nico Pache ,
Dev Jain ,
Baolin Wang ,
Borislav Petkov ,
Ingo Molnar ,
"H . Peter Anvin" ,
Zi Yan ,
Dave Hansen ,
David Hildenbrand ,
Lorenzo Stoakes ,
Andrew Morton ,
"Liam R . Howlett" ,
Jens Axboe
Cc: linux-block@vger.kernel.org,
linux-fsdevel@vger.kernel.org,
"Darrick J . Wong" ,
gost.dev@samsung.com,
kernel@pankajraghav.com,
hch@lst.de,
linux-kernel@vger.kernel.org,
linux-mm@kvack.org,
willy@infradead.org,
x86@kernel.org,
mcgrof@kernel.org,
Pankaj Raghav
Subject: [RFC v2 2/2] block: use mm_huge_zero_folio in
__blkdev_issue_zero_pages()
Date: Thu, 22 May 2025 11:02:43 +0200
Message-ID: <20250522090243.758943-3-p.raghav@samsung.com>
In-Reply-To: <20250522090243.758943-1-p.raghav@samsung.com>
References: <20250522090243.758943-1-p.raghav@samsung.com>
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id:
List-Subscribe:
List-Unsubscribe:
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"
Use mm_huge_zero_folio in __blkdev_issue_zero_pages(). Fallback to
ZERO_PAGE if mm_huge_zero_folio is not available.
On systems that allocates mm_huge_zero_folio, we will end up sending larger
bvecs instead of multiple small ones.
Noticed a 4% increase in performance on a commercial NVMe SSD which does
not support OP_WRITE_ZEROES. The device's MDTS was 128K. The performance
gains might be bigger if the device supports bigger MDTS.
Signed-off-by: Pankaj Raghav
---
block/blk-lib.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/block/blk-lib.c b/block/blk-lib.c
index 4c9f20a689f7..221389412359 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -196,6 +196,12 @@ static void __blkdev_issue_zero_pages(struct block_dev=
ice *bdev,
sector_t sector, sector_t nr_sects, gfp_t gfp_mask,
struct bio **biop, unsigned int flags)
{
+ struct folio *zero_folio;
+
+ zero_folio =3D mm_get_huge_zero_folio(NULL);
+ if (!zero_folio)
+ zero_folio =3D page_folio(ZERO_PAGE(0));
+
while (nr_sects) {
unsigned int nr_vecs =3D __blkdev_sectors_to_bio_pages(nr_sects);
struct bio *bio;
@@ -208,11 +214,12 @@ static void __blkdev_issue_zero_pages(struct block_de=
vice *bdev,
break;
=20
do {
- unsigned int len, added;
+ unsigned int len, added =3D 0;
=20
- len =3D min_t(sector_t,
- PAGE_SIZE, nr_sects << SECTOR_SHIFT);
- added =3D bio_add_page(bio, ZERO_PAGE(0), len, 0);
+ len =3D min_t(sector_t, folio_size(zero_folio),
+ nr_sects << SECTOR_SHIFT);
+ if (bio_add_folio(bio, zero_folio, len, 0))
+ added =3D len;
if (added < len)
break;
nr_sects -=3D added >> SECTOR_SHIFT;
--=20
2.47.2