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 3C8D9C54E90 for ; Thu, 22 May 2025 11:31:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A58F6B0082; Thu, 22 May 2025 07:31:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 456C26B0083; Thu, 22 May 2025 07:31:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36EA86B0085; Thu, 22 May 2025 07:31:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 0FCEC6B0082 for ; Thu, 22 May 2025 07:31:54 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9D5E21CCD68 for ; Thu, 22 May 2025 11:31:53 +0000 (UTC) X-FDA: 83470329306.18.B5E9B95 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf18.hostedemail.com (Postfix) with ESMTP id C74861C0004 for ; Thu, 22 May 2025 11:31:51 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OJgLFVYb; spf=pass (imf18.hostedemail.com: domain of rppt@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1747913512; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IqNNWbOA/xOGDB+exN4SKgUVeddXFTMnj9j/7wj8b2c=; b=MgX8zbv+WFpLcdS4LhmHo/S9DQTvb4qP7xJ6tpu+oazCRdJFIPjhCxdAYfDyLeN+LZms5L 3VZguxgESX/2SZr1u6wwHG0Pj2iPrYTfyDpdwXtYAZY1tFKYNFr3Ai9suleXtDRz3TLJ2x tCQgfMh9xQHKJeN4yy2oB2kq1a5CknY= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OJgLFVYb; spf=pass (imf18.hostedemail.com: domain of rppt@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1747913512; a=rsa-sha256; cv=none; b=YVlZza6MS7duk4SyTcvajzTKkY/W+DvET6UCRyi+IeurB9xx3rgEUWgobp8BFa1bPBEQYW Y/Vo0A53YMrNNl+Uq7SWMJcB/W57pGpXC4qCnf5Se9bqKkrg/EweeKwpGxVw7sDid93zY6 phNPb/r+ibcPbPswxo7vZzVbEeWEYhk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 54A1B4A1E0; Thu, 22 May 2025 11:31:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 007A2C4CEE4; Thu, 22 May 2025 11:31:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1747913510; bh=Wh+9CNaey11qCTmNEpnWhOiC2XWB0qsO84H2HRuVPj4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OJgLFVYbYw/6KZT3isNE0iv42H39HSgV9c7TFTiIbYYRGDX5/+DY272LQlVLJ5oTD vp9ZRnB6iuPnHxnWbFWv5tw0E3LLqdpWd4Jwz28Ow0xG7Q/I7REvBvAt/ZQ9pcre15 1FdKK1ZBIqsJMuWrT6l06GjK0HxHnL+32qrjY2vEodKWXeVPkaQvv5dcG9mvYsp6Vc Gyj8B6gIkvduc6fKxuMsn8vp8PczW2q/JtuMTDo7/S0EzEXnLKvLCOf+3ojmuwcfFX Mom1vfQ+SZNfMA+Zwvbl7S/Cw+9m0H+3spja5fSOPR7kyvic3VG7aeF5c0bTmDb4BB sXvyGBd49XZJQ== Date: Thu, 22 May 2025 14:31:36 +0300 From: Mike Rapoport To: Pankaj Raghav Cc: Suren Baghdasaryan , Vlastimil Babka , Ryan Roberts , 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 , 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 Subject: Re: [RFC v2 0/2] add THP_HUGE_ZERO_PAGE_ALWAYS config option Message-ID: References: <20250522090243.758943-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250522090243.758943-1-p.raghav@samsung.com> X-Stat-Signature: 8jya9nyx7eabhichyeezxygn1yfu6yzj X-Rspamd-Queue-Id: C74861C0004 X-Rspam-User: X-Rspamd-Server: rspam02 X-HE-Tag: 1747913511-403601 X-HE-Meta: U2FsdGVkX1+7Aa6RxoJf6Z5dYm/A7cPiHIHDz7m5f3/vwsK2tOPiXuTDbQDDvRvJjBw02op6pN/PR6gvDzmV+6NCTbJ6dQk39xrBOFg5AhzRi4yr179mdI2SANdrSGSYvUKa8VfKL4CtseFG+7q+SLoTiLCEu7AveiSJtyhaVb0/0h5JW2cE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h0Eoy2s/Qr5uTfFwsh4wK17aGgn1yIyJWf/DuSlGK/VFZh8Zqeme1hp4CbglALQt8DgRRTVaI4QjB2Z1dXdl4BlySwOMqW8fRmcg+WQ1SEUva 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: Hi Pankaj, On Thu, May 22, 2025 at 11:02:41AM +0200, Pankaj Raghav wrote: > 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 THP_HUGE_ZERO_PAGE_ALWAYS 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 don't think this config option should be tied to THP. It's perfectly sensible to have a configuration with HUGETLB and without THP. > 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 (2): > mm: add THP_HUGE_ZERO_PAGE_ALWAYS config option > block: use mm_huge_zero_folio in __blkdev_issue_zero_pages() > > arch/x86/Kconfig | 1 + > block/blk-lib.c | 15 +++++++++--- > mm/Kconfig | 12 +++++++++ > mm/huge_memory.c | 63 ++++++++++++++++++++++++++++++++++++++---------- > 4 files changed, 74 insertions(+), 17 deletions(-) > > > base-commit: f1f6aceb82a55f87d04e2896ac3782162e7859bd > -- > 2.47.2 > > -- Sincerely yours, Mike.