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 5D092C71135 for ; Fri, 13 Jun 2025 08:58:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F09066B008C; Fri, 13 Jun 2025 04:58:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E92DC6B0092; Fri, 13 Jun 2025 04:58:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D72626B0093; Fri, 13 Jun 2025 04:58:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B5B566B008C for ; Fri, 13 Jun 2025 04:58:39 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3900B81597 for ; Fri, 13 Jun 2025 08:58:39 +0000 (UTC) X-FDA: 83549776758.13.41C2D0D Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) by imf21.hostedemail.com (Postfix) with ESMTP id EEBFB1C0009 for ; Fri, 13 Jun 2025 08:58:36 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=MMO1xn8w; spf=pass (imf21.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.151 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1749805117; 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=Z2jomFBz2wMuPndwQd5iG25ynyxt9aXkujr5axP6UUI=; b=G+wmwsqEEele85TfvEiVzjLTKBL4lYMO6EGTYbnkBMomh3xRREFbN2lUiobtTfFdgtf7Ix iKI/mJdTxj8+vEogh1UJjAHo88C0H9wRNX3bVWb7T8ys5FeOt9n+IFotR5eY3EYWs9wQ7N xN8qyNepQvzCgtobvBQqDwMVh8LB1DI= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=MMO1xn8w; spf=pass (imf21.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.151 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1749805117; a=rsa-sha256; cv=none; b=bVQFQjOjm2jcE4cRYegdgQ2oqVCXb0Iu7gXhOP84s6XBZmqcxg9B91ocWxEpMHC78oFucj +TYD6qI4QUNrsj6rJFhRDZk4rVGz00mhS2ZcY2C13P3LMdzfnNmJ/boFLcuvuoQzW5QWgN 50vO068aRZDzKOENtRZzHGseKACF2/4= 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 4bJYGJ2fvjz9t8V; Fri, 13 Jun 2025 10:58:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1749805112; 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: in-reply-to:in-reply-to:references:references; bh=Z2jomFBz2wMuPndwQd5iG25ynyxt9aXkujr5axP6UUI=; b=MMO1xn8wlpONqE+KPlWLozUOErEPYd4E2YI69SMPEhvG6j+lBhWvUDviiofp3xrQpunbMn vgh1XyuaMAqxStcd/Xi6bQ/Z+9hXlS8osru9te+iMAE1+scQL6No6y5ZuadwHlCDOdqPAK 1BMB6cfqjP3UDQ8nZlzXNr8BlbUTiACKxL/lleuJWXbCdh2tcA96k+2BKtDECL3kOCHcDa H373TlNzoB6xivpxumubb5noY2fROfyPUa5RgpLNS24sN12yBvH4jHPDGT79nAV9LoYT+H +wJlczYGnY0Pv7e0MKOlPE/UyQrx5ycxApN0BFCN0coNPujQQdgmzK0/YDsL1w== Date: Fri, 13 Jun 2025 10:58:15 +0200 From: "Pankaj Raghav (Samsung)" To: Dave Hansen Cc: Pankaj Raghav , 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 , 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, hch@lst.de Subject: Re: [PATCH 0/5] add STATIC_PMD_ZERO_PAGE config option Message-ID: References: <20250612105100.59144-1-p.raghav@samsung.com> <30a3048f-efbe-4999-a051-d48056bafe0b@intel.com> <76a48d80-7eb0-4196-972d-ecdcbd4ae709@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <76a48d80-7eb0-4196-972d-ecdcbd4ae709@intel.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: EEBFB1C0009 X-Stat-Signature: uzhij6rw5znfmmcjt9e765do5nqa1zo3 X-Rspam-User: X-HE-Tag: 1749805116-543222 X-HE-Meta: U2Fsd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OB8z7NRgtfYWMP2mOdi7wCpmquBsE8G2hdUkCD6107QWMNbsT0M1EyQFUB9d/MIL9U3n0+GmGYdoD6bB95K3Uy9n8N2gtV6+EBcfoxhHq48dBzHm6k/xoegyH92puV4K8gcv4vbGfbkMZlXW4anjNSGw4Ac/e9XH6AVmNf+D6mefoTRKUssKNR+9PeBF979L0vvu1YTvVFHlf92AYNaa6gOQPWiua05acMBcTabCNxZYnwmcuBRt0klvevRPDe/Dp5DEp0jnOZ2LGoAXRDrxwKJv/olW8f+JSMtol 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: On Thu, Jun 12, 2025 at 02:46:34PM -0700, Dave Hansen wrote: > On 6/12/25 13:36, Pankaj Raghav (Samsung) wrote: > > On Thu, Jun 12, 2025 at 06:50:07AM -0700, Dave Hansen wrote: > >> On 6/12/25 03:50, Pankaj Raghav wrote: > >>> 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 in x86). > >> > >> So, what's the problem with calling a destructor? > >> > >> In your last patch, surely bio_add_folio() can put the page/folio when > >> it's done. Is the real problem that you don't want to call zero page > >> specific code at bio teardown? > > > > Yeah, it feels like a lot of code on the caller just to use a zero page. > > It would be nice just to have a call similar to ZERO_PAGE() in these > > subsystems where we can have guarantee of getting huge zero page. > > > > Apart from that, these are the following problems if we use > > mm_get_huge_zero_folio() at the moment: > > > > - We might end up allocating 512MB PMD on ARM systems with 64k base page > > size, which is undesirable. With the patch series posted, we will only > > enable the static huge page for sane architectures and page sizes. > > Does *anybody* want the 512MB huge zero page? Maybe it should be an > opt-in at runtime or something. > Yeah, I think that needs to be fixed. David also pointed this out in one of his earlier reviews[1]. > > - In the current implementation we always call mm_put_huge_zero_folio() > > in __mmput()[1]. I am not sure if model will work for all subsystems. For > > example bio completions can be async, i.e, we might need a reference > > to the zero page even if the process is no longer alive. > > The mm is a nice convenient place to stick an mm but there are other > ways to keep an efficient refcount around. For instance, you could just > bump a per-cpu refcount and then have the shrinker sum up all the > refcounts to see if there are any outstanding on the system as a whole. > > I understand that the current refcounts are tied to an mm, but you could > either replace the mm-specific ones or add something in parallel for > when there's no mm. But the whole idea of allocating a static PMD page for sane architectures like x86 started with the intent of avoiding the refcounts and shrinker. This was the initial feedback I got[2]: I mean, the whole thing about dynamically allocating/freeing it was for memory-constrained systems. For large systems, we just don't care. [1] https://lore.kernel.org/linux-mm/1e571419-9709-4898-9349-3d2eef0f8709@redhat.com/ [2] https://lore.kernel.org/linux-mm/cb52312d-348b-49d5-b0d7-0613fb38a558@redhat.com/ -- Pankaj