From nobody Tue Dec 16 14:25:02 2025 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) (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 33F291F582A; Tue, 27 May 2025 05:05:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748322328; cv=none; b=WIo9jLGOQaIFc3Wa+dS8EgkncejK1l0ZMOzkz8tUYFiTbcmqrJ0/zHq0/TsksNG5GW8STGeGOnUgDaX0YPTq2DtRoCU58hf51HxprDs0nv+Ztx7jqcorYchPhc0x1P/XglI9AFRGSquVCTH8ZHiuciwnO9i/8F4/bdeyInHsneE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748322328; c=relaxed/simple; bh=ZfJzFdHvBVoVt9yihJ6HO+m02MTs9dzOAIW953o6f9Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WoIyUPObVPcKww13Q8twbDGvHDlJXkElaACm3UCBQlDEYRUyhz7xOwY2OIb/mXMkRu/On6zQTzLT/hU/EQ3uWdx4o/PYPHpxMbKFA3A1VQJxnvVh0eB0jXAxR1z32dAVmXw9XKD07I5oWmBCoLZwKJTjn4klQbtPdq+XB/JgpAk= 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.172 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 [IPv6:2001:67c:2050:b231:465::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-202.mailbox.org (Postfix) with ESMTPS id 4b60v75Kq0z9tPW; Tue, 27 May 2025 07:05:23 +0200 (CEST) From: Pankaj Raghav To: Suren Baghdasaryan , Ryan Roberts , Vlastimil Babka , Baolin Wang , Borislav Petkov , Ingo Molnar , "H . Peter Anvin" , Zi Yan , Mike Rapoport , Dave Hansen , Michal Hocko , David Hildenbrand , Lorenzo Stoakes , Andrew Morton , Thomas Gleixner , Nico Pache , Dev Jain , "Liam R . Howlett" , Jens Axboe Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org, willy@infradead.org, x86@kernel.org, linux-fsdevel@vger.kernel.org, "Darrick J . Wong" , mcgrof@kernel.org, gost.dev@samsung.com, kernel@pankajraghav.com, hch@lst.de, Pankaj Raghav Subject: [RFC 3/3] block: use mm_huge_zero_folio in __blkdev_issue_zero_pages() Date: Tue, 27 May 2025 07:04:52 +0200 Message-ID: <20250527050452.817674-4-p.raghav@samsung.com> In-Reply-To: <20250527050452.817674-1-p.raghav@samsung.com> References: <20250527050452.817674-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 X-Rspamd-Queue-Id: 4b60v75Kq0z9tPW 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 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/block/blk-lib.c b/block/blk-lib.c index 4c9f20a689f7..0fd55e028170 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -4,6 +4,7 @@ */ #include #include +#include #include #include #include @@ -196,6 +197,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 +215,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