From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C3D4C54F30 for ; Tue, 27 May 2025 05:05:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AEC046B0082; Tue, 27 May 2025 01:05:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC5096B0083; Tue, 27 May 2025 01:05:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A00B06B0085; Tue, 27 May 2025 01:05:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 811966B0082 for ; Tue, 27 May 2025 01:05:13 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D2BD85FFC8 for ; Tue, 27 May 2025 05:05:12 +0000 (UTC) X-FDA: 83487498864.04.DB27F51 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by imf09.hostedemail.com (Postfix) with ESMTP id 165BF140004 for ; Tue, 27 May 2025 05:05:10 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=samsung.com (policy=none); spf=pass (imf09.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1748322311; h=from:from:sender: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: references; bh=a7+tMLSzDBvgOvlYAtuUuX9N6lU6ovtQB/5os5iU1vI=; b=yJxgzd3Ii3V8NvXdrwgAeAkCK2RN/cnlL2vU+0dW04WW3BfyvfPnU16WT+tXp6bWCOEZFv 3kbSb4eOAIRmC0HZvhZyLdd6/7pS0C8+qPHKoztcX8UnR2Ht7B5XKBrUYl2JAPGoCi7dqL MgCIbb0QUiYILdGrAcTtJJnpizn4iEA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=samsung.com (policy=none); spf=pass (imf09.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1748322311; a=rsa-sha256; cv=none; b=j/RRVp9Lwg3k5ZZMpjj7plQDzv+W9cns2Xw0VKB5pSK8R42MfjA/KTjcTH+zhr8enSq1az 1B2nwQfoMxiV9+wLvmPon81HAuBpZAi3xbY09KZMOuLQ0yk0iFyNQpFrUNBMKjBQcCclMg vci8zWL2B/LSRYGbLJSPQCYgMr/mlOs= Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4b60tp125Fz9sxp; Tue, 27 May 2025 07:05:06 +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 0/3] add STATIC_PMD_ZERO_PAGE config option Date: Tue, 27 May 2025 07:04:49 +0200 Message-ID: <20250527050452.817674-1-p.raghav@samsung.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 165BF140004 X-Stat-Signature: ofeqrrc87ehk3yqfepryrihignwpya45 X-Rspam-User: X-HE-Tag: 1748322310-30032 X-HE-Meta: U2FsdGVkX1+XRUC55X/QwS1DQ1GfEQK2q5O10Beow3vpmlTt/4Q7Jn9xzmqpcicKq2QVs7ZWWS1U1hFCPnsPhtLqyNMHjPxnObP6oQwYVvwQgSkXeaGmdJjJRn//58ZHlUD4BKV0wjPcxZSJDLpWZQwHSEA8lKBkejAeWo+wRNJwPEvqGOP6fen2o9yjVEf+sNhMoXsUFel5+moDh65ZKpp6wVZB/VykayxsTALCI6t6lxuhZMMoMGi8M72l7Lqw0YAspWwzDulbHlbPsv7nsRLjdppweIxyAfQCWQw+gMmcdT9xuCXrxEn4yENKYhrEr7o6lFCekvuUTqQ/1iNmAqtBq4H/QBGt/tvnfteZsuuSXDFlT00lPafFt/R3R1C7JM9kJTP6GdhItoNCCkBr825VtbHBFe7ij61s/GOyI2oOTgJjRPH/0BvT2MZEW6suwJnAa3xc4uWzSMmoZgJJYScFiNKwF4OZOAEpQMPRjrR3YYoXpDLUpZGhxRw+g3s/rjvXufI+fJgPSWBgz39/zc3RhLaSlhEarGzWptNXLBpSALZ1DCBz8H7Cwrjn+vrrLkuUetzrWVMFG7GPUMNW4ScjOaXVcU4C1kvJK+LcH/EEekQnLWbU62yn6sxqI9HdDF4UojsK7Rloqp2OQBSOkANn6er5vCL2l/8Uxjxp3a02uOERmoXml/AVtiYw1VcdlYkjtoSO59RAo9Bp1D7/tftXUSgd6G2b4d7dZgDKiHANacAKelUnOIf3AlZEZ9NgMm6s5uI3lB4GCQVhK6WWmYuGhvhERTGiPBDV+AmbPVtReZm1fuEeUmD66w1QuN3eZY7ZRATSMd3U5fF6r5sxA5l+QOr0CDUWfmAPGFT7chxuOhYsBRmCAXxyhncyLBxa0asKstexSulYyuXCmYQplXYp/fFbSWKTBq3bftb/lXPXqNVlb0x4DFJn8KhDAyxv06jpa/yHlcKvkQwshX/ HN5tv8gb 5/FFs5mvCB0fLZRIOKuQT+qRLFn9x1THAgayXgbWvC5rbCYdV+Fei2qxYUOn2BRIo6UrAXHl/K/b+KBrRazOvrXjm9qwaRBg6Q3kZXH7QSY3BS2xF1bpaKpCz+61LQhuGFII1mEmqt7mawwcdQEZJhMYiToF858llViytY9l/1815FzW6brga4qdVpwFmFJhfOOpKedcZNGRs4OQCL6gUYMnKQWUIriZQEW1O8VCBJ42zKf0xVPf5w00mUAKuHU3ciNFRlIdpuKZnQt6eARvZzz8l1Q73fE5U39tZai9giOoG1JDYmMPYz04kAXUv/vBwaH19t7u6GN31uzESKCB3U0vFcJQaFSBW1mRSlpF9bKB8/E/tTsa5Ni9Ya3mxbT6rDQojLaK6EwcDJPsS8lOlqwFJt0V90bDUd9X0XAiiTWjdKBGKfxkrbpZAO8bfVxYrPQMSZ1XbX2yDBlv90QsoNA9wWqUvaNnTr/b0vDirMc3BdcurIFviXTp0bR+qU6Fe4qw3Uq1O7uAW4PQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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[1][2]. 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() ... We already have huge_zero_folio that is allocated on demand, and it will be deallocated by the shrinker if there are no users of it left. But to use huge_zero_folio, we need to pass a mm struct and the put_folio needs to be called in the destructor. This makes sense for systems that have memory constraints but for bigger servers, it does not matter if the PMD size is reasonable (like x86). Add a config option STATIC_PMD_ZERO_PAGE that will always allocate the huge_zero_folio, and it will never be freed. This makes using the huge_zero_folio without having to pass any mm struct and a call to put_folio in the destructor. I have converted blkdev_issue_zero_pages() as an example as a part of this series. 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-xfs/20231027051847.GA7885@lst.de/ [2] https://lore.kernel.org/linux-xfs/ZitIK5OnR7ZNY0IG@infradead.org/ Changes since v1: - Added the config option based on the feedback from David. - Removed iomap patches so that I don't clutter this series with too many subsystems. Pankaj Raghav (3): mm: move huge_zero_folio from huge_memory.c to memory.c mm: add STATIC_PMD_ZERO_PAGE config option block: use mm_huge_zero_folio in __blkdev_issue_zero_pages() arch/x86/Kconfig | 1 + block/blk-lib.c | 16 ++++-- include/linux/huge_mm.h | 16 ------ include/linux/mm.h | 16 ++++++ mm/Kconfig | 12 ++++ mm/huge_memory.c | 105 +--------------------------------- mm/memory.c | 121 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 164 insertions(+), 123 deletions(-) base-commit: f1f6aceb82a55f87d04e2896ac3782162e7859bd -- 2.47.2