From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) (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 A3E8915530C; Tue, 22 Jul 2025 09:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.161 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753177357; cv=none; b=J3iSVDnNndQy8yafyPb18IrPRLAAeyScSAK6xKMIvtcPs/I4nmlviD5FHdGyp0Zo2ljq83hnY/hDLvdoa9yybwzAbSsNdD9ePxatMn1r1Hp8mejr352ZMvtGZsuq5yWzjeEvz4kIT/7HMXDkKNKav5hSa1L3pvK03VvwuD9GhiM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753177357; c=relaxed/simple; bh=D5Nx/L6pwQt6ktQzn8+SRh6yGCGIQr5QYh6/RMWz0q8=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=CSdlfLdsq+obGalwkVgruvjde4ZhIHDiBYjfWa748c5uVeOP3IFLr0jGLITW93jrC3KIKD+Shq4zQYOXO34UQg4v3KhSADpir7hSgcfPaK8sHveQiEfg3hzTvmU9zodDQt1CZyw5XzI5Nl6E4cNLzZnF0NtX6/9GB2vdbye/tE4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pankajraghav.com; spf=pass smtp.mailfrom=pankajraghav.com; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b=FeLF/FsA; arc=none smtp.client-ip=80.241.56.161 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pankajraghav.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pankajraghav.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b="FeLF/FsA" Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (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-103.mailbox.org (Postfix) with ESMTPS id 4bmXNx6blwz9svV; Tue, 22 Jul 2025 11:42:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1753177346; 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; bh=Urh8HRRY5Gk+UX/47pqglCk6rC9DKpiGj+KUTBX7+cY=; b=FeLF/FsA3wnqiSqMvPDYZwXjDYrax7X5skBfXJfI2kZXS7eGNxN50IorUfg0OnPD8REeJr LlX25h8JS22JeTq2p1zSBtLPDoufAANC7db1oLf2E547fIr+pD/dv/sNpk+CW6NQf0MMep hWP9OyYnFugTJKRMkt/yEN7Ob8j2Enk4C6fnWfMBFEBwQm8IduHD7fzxaKLoWi2iPOF6z2 lz4w8/FflPazzxv3QZfINLJ4nOxXv4qfS6Ty74WbcbWUpcHC3zEPnzIUYagnD8R8tnDDIp odpa1i++gPK91rL1aDstJtoL+LwOPBrs8Zh1aFZ6Ba84rXirsSBm00q5k76Sbg== From: "Pankaj Raghav (Samsung)" To: Suren Baghdasaryan , Ryan Roberts , Mike Rapoport , Michal Hocko , Thomas Gleixner , Nico Pache , Dev Jain , Baolin Wang , Borislav Petkov , Ingo Molnar , "H . Peter Anvin" , Vlastimil Babka , Zi Yan , Dave Hansen , David Hildenbrand , Lorenzo Stoakes , Andrew Morton , "Liam R . Howlett" , Jens Axboe Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org, x86@kernel.org, linux-block@vger.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 0/4] add static huge zero folio support Date: Tue, 22 Jul 2025 11:42:11 +0200 Message-ID: <20250722094215.448132-1-kernel@pankajraghav.com> Content-Type: text/plain; charset="utf-8" Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Pankaj Raghav NOTE: I am resending as an RFC again based on Lorenzo's feedback. The old series can be found here [1]. There are many places in the kernel where we need to zeroout larger chunks but the maximum segment we can zeroout at a time by ZERO_PAGE is limited by PAGE_SIZE. This concern was raised during the review of adding Large Block Size support to XFS[2][3]. This is especially annoying in block devices and filesystems where we attach multiple ZERO_PAGEs to the bio in different bvecs. With multipage bvec support in block layer, it is much more efficient to send out larger zero pages as a part of a single bvec. Some examples of places in the kernel where this could be useful: - blkdev_issue_zero_pages() - iomap_dio_zero() - vmalloc.c:zero_iter() - rxperf_process_call() - fscrypt_zeroout_range_inline_crypt() - bch2_checksum_update() ... Usually huge_zero_folio is allocated on demand, and it will be deallocated by the shrinker if there are no users of it left. At the moment, huge_zero_folio infrastructure refcount is tied to the process lifetime that created it. This might not work for bio layer as the completions can be async and the process that created the huge_zero_folio might no longer be alive. And, one of the main point that came during discussion is to have something bigger than zero page as a drop-in replacement. Add a config option STATIC_HUGE_ZERO_FOLIO that will always allocate the huge_zero_folio, and it will never drop the reference. This makes using the huge_zero_folio without having to pass any mm struct and does not tie the lifetime of the zero folio to anything, making it a drop-in replacement for ZERO_PAGE. I have converted blkdev_issue_zero_pages() as an example as a part of this series. I also noticed close to 4% performance improvement just by replacing ZERO_PAGE with static huge_zero_folio. I will send patches to individual subsystems using the huge_zero_folio once this gets upstreamed. Looking forward to some feedback. [1] https://lore.kernel.org/linux-mm/20250707142319.319642-1-kernel@pankajraghav.com/ [2] https://lore.kernel.org/linux-xfs/20231027051847.GA7885@lst.de/ [3] https://lore.kernel.org/linux-xfs/ZitIK5OnR7ZNY0IG@infradead.org/ Changes since last series[1]: - Instead of allocating a new page through memblock, use the same infrastructure as huge_zero_folio but raise the reference and never drop it. (David) - And some minor cleanups based on Lorenzo's feedback. Pankaj Raghav (4): mm: rename huge_zero_page_shrinker to huge_zero_folio_shrinker mm: add static huge zero folio mm: add largest_zero_folio() routine block: use largest_zero_folio in __blkdev_issue_zero_pages() arch/x86/Kconfig | 1 + block/blk-lib.c | 15 ++++++------ include/linux/huge_mm.h | 24 +++++++++++++++++++ mm/Kconfig | 12 ++++++++++ mm/huge_memory.c | 52 +++++++++++++++++++++++++++++++---------- 5 files changed, 85 insertions(+), 19 deletions(-) base-commit: 1b0686bd18c1aa9d7f01943829faa5befe6ab3d1 -- 2.49.0