From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2DD629A0 for ; Mon, 14 Oct 2024 17:32:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728927178; cv=none; b=H+19gKGSfd2pEUkO1kjKhjb+qh1pDVLF9TxPcTs1IUF+7jqoPBar00DNyBlw7yX9cxNXIGzpGvlEnNDGroycIhizu4FhifFIx9kkUBSFKLlnjmFK3GDsnoDz700udohQznJvVHX+dkNqd85XrTF/PStCTT+yyvsdqBs+hPgfpoc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728927178; c=relaxed/simple; bh=x8k/egH+bBvK4s3ZnPRvk4qJCTowYXGGR8W2q6rwT/M=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=oAUdqU389QllnDYjs8tWA9t/H0w5Pxe9osjJMRmF9vXzes+Wp6Y9lOrbsQkBnwZFrZMBdJafuMrYuKn6EogILO++8WzvksatiYI7mxvXSweSlUt2WDiF8bnbW2DTFo7Hk0kUVCWQhyGxu4EnuypTUGMulAt0MNMYttlFWRzS2xw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=Wd5kbv5y; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Wd5kbv5y" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-20ce5e3b116so10017655ad.1 for ; Mon, 14 Oct 2024 10:32:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1728927176; x=1729531976; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=bQQSHSD7pMPEnyh5pSYNZBMzysQwlv1Sj6SfqEv1kug=; b=Wd5kbv5y4tBDXlLIDIidZ5r+dZtPPpbv1tiS79WrBzMv4K000GCiVSqThWmLS9CaGS WTbSktMTxNzfe7olV2vGoMAj7zBHGD4LHXpcltEJTq9obeiCxQS4fBzMMoVu/4fBB042 gi5tyKByyiCyc7xSeC1QXacUigaoYLj1tgvPM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728927176; x=1729531976; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language: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=bQQSHSD7pMPEnyh5pSYNZBMzysQwlv1Sj6SfqEv1kug=; b=GqLDrvzrpALESxZU9e+YBJpBwJG5PnLIDaOLeO+wvT9m9xq1O2C79MxkapCF0Z/dGU B4+CmDYjvKOEojf2dLu8inYKF9tjLM/qX07ABUg2wtdmIx04vqdBHb98+ov7ltOKHQ1d 1bZg14ZrHGuyr8JjEihnFDoov6O0e251Sw/8snCPuTQUk/PTNYBKHIOIKKZIIp2qRgem poWdfepvHRU/n1dTZ0kaXoVFGbKN0wkY8EaomPTunpqi39ATpYDsW2U3va10FuJnaRDY +ATIL9YworYypygvU6P8Ec15cVkBE3kMdrKestF4cYXG+bEPiiX8TPFqkm2kEPvxkfZb /fZA== X-Forwarded-Encrypted: i=1; AJvYcCW5nTen0z80d4CgWmxs7hqRc31y2eLq4AAjltrh/Xd8gIonMHEigowcIflMrekt2h/xrGUg6oew+U4fzww=@vger.kernel.org X-Gm-Message-State: AOJu0YwmiOYsZhmU/uMx5rtScfIdSjBFa6dq5+Gv9BVdwnGF27ttWS1Y iVcq6buRJC1Mpp8X19VgdYvwhAiBdr2jll4CO6Q50GApoVLCJX+Gqd+F9NtUkg== X-Google-Smtp-Source: AGHT+IEns2eqkxyiAg986XLyfsK4RpsMx2bwZL6BIHWTOuBJ8RnZHMXrUX4qvjPsrHC+Vm+yqwVq0A== X-Received: by 2002:a17:903:1c6:b0:20c:e262:2560 with SMTP id d9443c01a7336-20ce26227c9mr76987585ad.50.1728927175840; Mon, 14 Oct 2024 10:32:55 -0700 (PDT) Received: from [10.67.48.245] ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c8c0eb7bbsm68863045ad.162.2024.10.14.10.32.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Oct 2024 10:32:55 -0700 (PDT) Message-ID: <3e742298-2f38-496c-ba63-1e30d16318c6@broadcom.com> Date: Mon, 14 Oct 2024 10:32:53 -0700 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: [RFC PATCH v1 00/57] Boot-time page size selection for arm64 To: Ryan Roberts , Andrew Morton , Anshuman Khandual , Ard Biesheuvel , Catalin Marinas , David Hildenbrand , Greg Marsden , Ivan Ivanov , Kalesh Singh , Marc Zyngier , Mark Rutland , Matthias Brugger , Miroslav Benes , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20241014105514.3206191-1-ryan.roberts@arm.com> Content-Language: en-US From: Florian Fainelli Autocrypt: addr=florian.fainelli@broadcom.com; keydata= xsBNBFPA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lelQ8lSocmvxBKtMbX/OKhAfuP/iIwnTsww 95A2SaPiQZA51NywV8OFgsN0ITl2PlZ4Tp9hHERDe6nQCsNI/Us= In-Reply-To: <20241014105514.3206191-1-ryan.roberts@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 10/14/24 03:55, Ryan Roberts wrote: > Hi All, > > Patch bomb incoming... This covers many subsystems, so I've included a core set > of people on the full series and additionally included maintainers on relevant > patches. I haven't included those maintainers on this cover letter since the > numbers were far too big for it to work. But I've included a link to this cover > letter on each patch, so they can hopefully find their way here. For follow up > submissions I'll break it up by subsystem, but for now thought it was important > to show the full picture. > > This RFC series implements support for boot-time page size selection within the > arm64 kernel. arm64 supports 3 base page sizes (4K, 16K, 64K), but to date, page > size has been selected at compile-time, meaning the size is baked into a given > kernel image. As use of larger-than-4K page sizes become more prevalent this > starts to present a problem for distributions. Boot-time page size selection > enables the creation of a single kernel image, which can be told which page size > to use on the kernel command line. > > Why is having an image-per-page size problematic? > ================================================= > > Many traditional distros are now supporting both 4K and 64K. And this means > managing 2 kernel packages, along with drivers for each. For some, it means > multiple installer flavours and multiple ISOs. All of this adds up to a > less-than-ideal level of complexity. Additionally, Android now supports 4K and > 16K kernels. I'm told having to explicitly manage their KABI for each kernel is > painful, and the extra flash space required for both kernel images and the > duplicated modules has been problematic. Boot-time page size selection solves > all of this. > > Additionally, in starting to think about the longer term deployment story for > D128 page tables, which Arm architecture now supports, a lot of the same > problems need to be solved, so this work sets us up nicely for that. > > So what's the down side? > ======================== > > Well nothing's free; Various static allocations in the kernel image must be > sized for the worst case (largest supported page size), so image size is in line > with size of 64K compile-time image. So if you're interested in 4K or 16K, there > is a slight increase to the image size. But I expect that problem goes away if > you're compressing the image - its just some extra zeros. At boot-time, I expect > we could free the unused static storage once we know the page size - although > that would be a follow up enhancement. > > And then there is performance. Since PAGE_SIZE and friends are no longer > compile-time constants, we must look up their values and do arithmetic at > runtime instead of compile-time. My early perf testing suggests this is > inperceptible for real-world workloads, and only has small impact on > microbenchmarks - more on this below. > > Approach > ======== > > The basic idea is to rid the source of any assumptions that PAGE_SIZE and > friends are compile-time constant, but in a way that allows the compiler to > perform the same optimizations as was previously being done if they do turn out > to be compile-time constant. Where constants are required, we use limits; > PAGE_SIZE_MIN and PAGE_SIZE_MAX. See commit log in patch 1 for full description > of all the classes of problems to solve. > > By default PAGE_SIZE_MIN=PAGE_SIZE_MAX=PAGE_SIZE. But an arch may opt-in to > boot-time page size selection by defining PAGE_SIZE_MIN & PAGE_SIZE_MAX. arm64 > does this if the user selects the CONFIG_ARM64_BOOT_TIME_PAGE_SIZE Kconfig, > which is an alternative to selecting a compile-time page size. > > When boot-time page size is active, the arch pgtable geometry macro definitions > resolve to something that can be configured at boot. The arm64 implementation in > this series mainly uses global, __ro_after_init variables. I've tried using > alternatives patching, but that performs worse than loading from memory; I think > due to code size bloat. FWIW, this paragraph was not entirely clear to me until I looked at patch 57 to see that the compile time page size selection had been retained, and could continue to be used as-is. It was somewhat implicit, but not IMHO explicit enough, not a big deal though. Great work, thanks for doing that! This makes me wonder if we could leverage any of that to have a single kernel supporting both LPAE and !LPAE on ARM 32-bit, but that still seems like somewhat more difficult, largely due to the difference in the page table descriptor format (long vs. short). -- Florian