From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 58934288520 for ; Tue, 15 Jul 2025 14:06:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752588401; cv=none; b=DJfwP1lVn3O8fRnXlCRqEK55JuDDBNqImIlTn+m5ghsuXQnaiE7TKyke4HnMUepaqc81MRdCzVAeOoZ2Sn/NGWkRuOkg5gWid8gw9EOjvXV/46ribC4IOJ8q0JWijYrLwzlrOqvtH0WYuZVsXH4G6sSIRPtom1nUqnzQL+WeX7U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752588401; c=relaxed/simple; bh=NGjl+k0iCeICYYeTIxSQzRMo78FaxzR0hHeAkayY7lg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mAEnjSycEb/tCp1SgqVf460DHp5UXa5G19aq/uV8qVpF0IBgJeetAPKwEBjJ5X3g3AmFfDj5H4GaI+QPKRHzWVDAQA0mCgNLBl1F/pCeZWKEKFYoGO6hAxtGsK5hsrxtK+/JK1XnARgZK1Wir8TGj2QaFyFJniOmBK8zvN1z7Iw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=VBTdE9Mh; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VBTdE9Mh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752588397; 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: in-reply-to:in-reply-to:references:references; bh=lBxA7fPx+kaOUHpIDxI1a9myrZ8g1CRn9224twnAPJQ=; b=VBTdE9Mht/erlxJzrCEEmJj+Gucd0WCK3OmpwU0TFC8TX7fsLPYvC0eXMfH4hut2dwBN48 RJmZgsB3XU+9v5vKm5ZBIN4Ddcflvu91H1z7pZLHIrBG9ZEJ8NQEzIWoN6r+QBIkQujWhH q24b0uXkh1gw7cssdK8i7+UHaewGT8M= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-548-MlTp-Td3NzyOwKgblv0WNA-1; Tue, 15 Jul 2025 10:06:35 -0400 X-MC-Unique: MlTp-Td3NzyOwKgblv0WNA-1 X-Mimecast-MFC-AGG-ID: MlTp-Td3NzyOwKgblv0WNA_1752588394 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3a4f858bc5eso4218117f8f.0 for ; Tue, 15 Jul 2025 07:06:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752588393; x=1753193193; h=content-transfer-encoding:in-reply-to:organization:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lBxA7fPx+kaOUHpIDxI1a9myrZ8g1CRn9224twnAPJQ=; b=n+l0pBtWGJaORZZy+iwt79lRHMEAo5Ruv1KBBkjJNIio/G9IT018jlCOIYVxU3VtRN 3y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:6000:2085:b0:3a4:e667:922e with SMTP id ffacd0b85a97d-3b5f2dacddamr13012952f8f.4.1752588392966; Tue, 15 Jul 2025 07:06:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGWK4HuTxAUxy5B//ipMMWWwodJ7JkwfIbQV6DrOEaPS5dsc6t+pb8z58e8T3W45U4i7z4JQw== X-Received: by 2002:a05:6000:2085:b0:3a4:e667:922e with SMTP id ffacd0b85a97d-3b5f2dacddamr13012870f8f.4.1752588392263; Tue, 15 Jul 2025 07:06:32 -0700 (PDT) Received: from ?IPV6:2003:d8:2f28:4900:2c24:4e20:1f21:9fbd? (p200300d82f2849002c244e201f219fbd.dip0.t-ipconnect.de. [2003:d8:2f28:4900:2c24:4e20:1f21:9fbd]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b5e8dc217esm14797863f8f.28.2025.07.15.07.06.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Jul 2025 07:06:31 -0700 (PDT) Message-ID: Date: Tue, 15 Jul 2025 16:06:29 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 0/5] add static PMD zero page support To: Lorenzo Stoakes , Pankaj Raghav Cc: Zi Yan , Suren Baghdasaryan , Ryan Roberts , Baolin Wang , Borislav Petkov , Ingo Molnar , "H . Peter Anvin" , Vlastimil Babka , Mike Rapoport , Dave Hansen , Michal Hocko , 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 References: <20250707142319.319642-1-kernel@pankajraghav.com> From: David Hildenbrand Content-Language: en-US Organization: Red Hat In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 15.07.25 16:02, Lorenzo Stoakes wrote: > On Wed, Jul 09, 2025 at 10:03:51AM +0200, Pankaj Raghav wrote: >> Hi Zi, >> >>>> Add a config option STATIC_PMD_ZERO_PAGE that will always allocate the huge_zero_folio via >>>> memblock, and it will never be freed. >>> >>> Do the above users want a PMD sized zero page or a 2MB zero page? Because on systems with non >>> 4KB base page size, e.g., ARM64 with 64KB base page, PMD size is different. ARM64 with 64KB base >>> page has 512MB PMD sized pages. Having STATIC_PMD_ZERO_PAGE means losing half GB memory. I am >>> not sure if it is acceptable. >>> >> >> That is a good point. My intial RFC patches allocated 2M instead of a PMD sized >> page. >> >> But later David wanted to reuse the memory we allocate here with huge_zero_folio. So >> if this config is enabled, we simply just use the same pointer for huge_zero_folio. >> >> Since that happened, I decided to go with PMD sized page. >> >> This config is still opt in and I would expect the users with 64k page size systems to not enable >> this. >> >> But to make sure we don't enable this for those architecture, I could do a per-arch opt in with >> something like this[1] that I did in my previous patch: >> >> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig >> index 340e5468980e..c3a9d136ec0a 100644 >> --- a/arch/x86/Kconfig >> +++ b/arch/x86/Kconfig >> @@ -153,6 +153,7 @@ config X86 >> select ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP if X86_64 >> select ARCH_WANT_HUGETLB_VMEMMAP_PREINIT if X86_64 >> select ARCH_WANTS_THP_SWAP if X86_64 >> + select ARCH_HAS_STATIC_PMD_ZERO_PAGE if X86_64 >> select ARCH_HAS_PARANOID_L1D_FLUSH >> select ARCH_WANT_IRQS_OFF_ACTIVATE_MM >> select BUILDTIME_TABLE_SORT >> >> >> diff --git a/mm/Kconfig b/mm/Kconfig >> index 781be3240e21..fd1c51995029 100644 >> --- a/mm/Kconfig >> +++ b/mm/Kconfig >> @@ -826,6 +826,19 @@ config ARCH_WANTS_THP_SWAP >> config MM_ID >> def_bool n >> >> +config ARCH_HAS_STATIC_PMD_ZERO_PAGE >> + def_bool n > > Hm is this correct? arm64 supports mutliple page tables sizes, so while the > architecture might 'support' it, it will vary based on page size, so actually we > don't care about arch at all? > >> + >> +config STATIC_PMD_ZERO_PAGE >> + bool "Allocate a PMD page for zeroing" >> + depends on ARCH_HAS_STATIC_PMD_ZERO_PAGE > > Maybe need to just make this depend on !CONFIG_PAGE_SIZE_xx? I think at some point we discussed "when does the PMD-sized zeropage make *any* sense on these weird arch configs" (512MiB on arm64 64bit) No idea who wants to waste half a gig on that at runtime either. But yeah, we should let the arch code opt in whether it wants it or not (in particular, maybe only on arm64 with CONFIG_PAGE_SIZE_4K) -- Cheers, David / dhildenb