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 934D4C83F1B for ; Thu, 17 Jul 2025 12:07:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1AD9C6B00A5; Thu, 17 Jul 2025 08:07:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 15F016B00A9; Thu, 17 Jul 2025 08:07:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 053BD6B00AB; Thu, 17 Jul 2025 08:07:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E7DF56B00A5 for ; Thu, 17 Jul 2025 08:07:48 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 942671606F9 for ; Thu, 17 Jul 2025 12:07:48 +0000 (UTC) X-FDA: 83673632616.04.EBC4BFA Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) by imf15.hostedemail.com (Postfix) with ESMTP id 75510A0008 for ; Thu, 17 Jul 2025 12:07:46 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b="Nbg/lMwq"; dmarc=pass (policy=quarantine) header.from=pankajraghav.com; spf=pass (imf15.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.151 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752754066; a=rsa-sha256; cv=none; b=m6ZWKxFU2/c81STl3gWXMxj1s6Tq0JwZIeec63yc8eNLeXMaYEybPAbITqOVYFcvh3nOO3 cSq/B4F1GKdG8RKBeDA/G87Og7mn1QeCa7iLnIG9UMduR3xgrYOtslw43fRjFu9GwKlnBH NnzcVT6kn93ds6cF0IWPvNi3UCVmlU4= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b="Nbg/lMwq"; dmarc=pass (policy=quarantine) header.from=pankajraghav.com; spf=pass (imf15.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.151 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=1752754066; 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=M2ybh1HtN61EqnwEX7w+RBXpg6drT9A8UjYiaAe7+9c=; b=vwk/0D74rxcGuwswYRnJPqCrJQub3berZlsu9jv+5vO/RpI4I9oiUTZsSgpR8eDgoNBCFa gNm5CrfUkgdZ2lpYBPDixFWzwIbfncDjoGKtWpFiZ6Gpp+AF8x2xuXQv1eZoOrZXPzI4c6 iqP5TrCcAXWM4rl0/cT5nbEimbVlQOo= 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-101.mailbox.org (Postfix) with ESMTPS id 4bjWrt05HWz9spH; Thu, 17 Jul 2025 14:07:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1752754062; 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=M2ybh1HtN61EqnwEX7w+RBXpg6drT9A8UjYiaAe7+9c=; b=Nbg/lMwqYQ7RdUmujBnBs7sqvXWbAL1VjgMtWdfg6Vod71r7uQGV6MlSF1iJS3sgoYwmjC ITsrV5wLVFlsVwEHveYY4MmVvDLIKioRhEbz8Tx1uqYCexUWMzJkrbSRQbEph6ZxD8YA+B hLjLl4ygK/sLIQosFGBKbpTYt6J1NGRIaF1aNgau5MhKsKxBOyQqh1IYGI+WtpsgaOZQfJ UNHCCsPxg+IUmX8KQLkhmEqbEAmAvHLYE3Aqfplup74bYRVuAVqE0cNHeNLx5h4GlL9Rq9 eMNglH3B6JzyC/mexb8GCIii/yPfEZEbFJh1lAvCLkpgVcO9j5MoY+r7/JuYVg== Date: Thu, 17 Jul 2025 14:07:31 +0200 From: "Pankaj Raghav (Samsung)" To: David Hildenbrand Cc: Suren Baghdasaryan , Ryan Roberts , Baolin Wang , Borislav Petkov , Ingo Molnar , "H . Peter Anvin" , Vlastimil Babka , Zi Yan , Mike Rapoport , Dave Hansen , Michal Hocko , Lorenzo Stoakes , Andrew Morton , Thomas Gleixner , Nico Pache , Dev Jain , "Liam R . Howlett" , Jens Axboe , linux-kernel@vger.kernel.org, willy@infradead.org, linux-mm@kvack.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, Pankaj Raghav Subject: Re: [PATCH v2 3/5] mm: add static PMD zero page Message-ID: References: <20250707142319.319642-1-kernel@pankajraghav.com> <20250707142319.319642-4-kernel@pankajraghav.com> <26fded53-b79d-4538-bc56-3d2055eb5d62@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 75510A0008 X-Stat-Signature: 3pid7gopya34aey67gqeejip67oagny1 X-HE-Tag: 1752754066-629379 X-HE-Meta: U2FsdGVkX1/5zhYAT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bwxzf3PgxDmJyg5tmx+QoGxpf5gLgAJVYHZ0407sMgjvwxVOKmWYjJFww66TGOYcbsOST5pjlQKNXXjQwaH1H+H/XNHCxIiweZxakVU7RfqH6H6Mt08yYnjsZn6NeBmarTS7aaky+GldTbQv9JtWy47hy2PgP42CdXCvLTHgPBIpPHaZqC1cl2M62zT7JbEhgM5lB7PWnXrPOw== 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, Jul 17, 2025 at 01:46:03PM +0200, David Hildenbrand wrote: > On 17.07.25 12:34, Pankaj Raghav (Samsung) wrote: > > > > Then, we'd only need a config option to allow for that to happen. > > > > > > Something incomplete and very hacky just to give an idea. It would try allocating > > > it if there is actual code running that would need it, and then have it > > > stick around forever. > > > > > Thanks a lot for this David :) I think this is a much better idea and > > reduces the amount code and reuse the existing infrastructure. > > > > I will try this approach in the next version. > > > > > > > + /* > > > + * Our raised reference will prevent the shrinker from ever having > > > + * success -> static. > > > + */ > > > + if (atomic_read(&huge_zero_folio_is_static)) > > > + return huge_zero_folio; > > > + /* TODO: memblock allocation if buddy is not up yet? Or Reject that earlier. */ > > > > Do we need memblock allocation? At least the use cases I forsee for > > static pmd zero page are all after the mm is up. So I don't see why we > > need to allocate it via memblock. > > Even better! > > We might want to detect whether allocation of the huge zeropage failed a > couple of times and then just give up. Otherwise, each and every user of the > largest zero folio will keep allocating it. Yes, that makes sense. We need sort of like a global counter to count the nr of failures and then give up trying to allocate it if it goes above a threshold. -- Pankaj