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 C393AC25B78 for ; Mon, 13 May 2024 09:00:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C1B336B0283; Mon, 13 May 2024 05:00:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BCA4B6B0284; Mon, 13 May 2024 05:00:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE0366B0285; Mon, 13 May 2024 05:00:05 -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 919886B0283 for ; Mon, 13 May 2024 05:00:05 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1D106A1C3E for ; Mon, 13 May 2024 09:00:05 +0000 (UTC) X-FDA: 82112775570.17.D7BDBEC Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf13.hostedemail.com (Postfix) with ESMTP id 5AE8020021 for ; Mon, 13 May 2024 09:00:03 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715590803; a=rsa-sha256; cv=none; b=btbzj8nFmw4QTrrA9Gk4hATaUtIJzy6jkGve+iAO3NOBYNPZ5UNmHO6gVdtUkfv011JtDi ttG4dl14wz9x5vUTF56U2HPdnhp0cCGG9myAllCgvSmRz2pPv5Xyz0t5w/Z7mtXTxlOV7I OaVxG/M6Ml80JTmFxUsTNz97XHIPFo0= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715590803; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y4ceyFT1b5mnthMHGfJRJondNJaFrui+kznUQsNOuW0=; b=aZ1VXComq5OqzADkO7+FLuC4TOkY39bWVFbd/mWMRMVDwzQa1RVjxnR6+9IuTm1L4ndz6J urPHU/2ogf4wV5IE8j16S2qhckrSG2cri5e6Q+M8nrxGRMMmMB1XhOW1l581PwC5wkElAn Y/Lvpl5imMge3RCBlQFzmZYv6MIHfus= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B5E1B1007; Mon, 13 May 2024 02:00:27 -0700 (PDT) Received: from [10.57.68.95] (unknown [10.57.68.95]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A91963F762; Mon, 13 May 2024 02:00:00 -0700 (PDT) Message-ID: <7504a525-8211-48b3-becb-a6e838c1b42e@arm.com> Date: Mon, 13 May 2024 09:59:59 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RESEND v2 0/9] Merge arm64/riscv hugetlbfs contpte support Content-Language: en-GB To: Alexandre Ghiti Cc: Catalin Marinas , Will Deacon , Mark Rutland , Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-mm@kvack.org References: <20240508113419.18620-1-alexghiti@rivosinc.com> <6d37f914-d139-48ea-be63-c428ac767cc1@arm.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5AE8020021 X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: p4q7b9qrdy5mz8jft9ds8cmrj4sb5nis X-HE-Tag: 1715590803-416996 X-HE-Meta: U2FsdGVkX1/mbs1QY5vW4d7ILzAED2wcuphJWkTCOv1Am3YOOwXwOwPKbiACb20j/K6iRlR5FHxze14sHj91quGKqs6RzoopfpHoeSczrZdTQvePbzSYNBrlKpbbLSJfq89WrlwGvF0gBELZjcXV9QYxed4nPHXQN9VZ0TBIdcONTlbaoKeY2Qpx+PXEizYjXocaAfC1abDYhCa2ispu0eEtVt1B7TfRcqRXUdh34koGKC4bvXoMM2vczIEixJZkVLJXdZXdWCf+oikslmPw5vKayVysTK7Pg26orE/yW/K2mhP9HwDvRIBLXbmf2AjeyB44SkKqhhGTWNwo8rw/SGqmAATdNxVSmKTlaVR6F7fCj5U7fYLlykN/rBj+xCGXvzEbE48rOq4X07MUnQlMMyn/lSlTW9rnuAyMc2ZaC7QpWUpJj5lfZLd9X688BaTK4LEYEtiPaPjJ/Hu9c8TyHuEFEsWL3N2XKpa3/hd7L634vGHDyfl93lVhvj3g93yWiipYoIg3P4zUbHIzisz1Y1rE9gURbOtht/WsmLH8NM7/s22yMEwGuSFKuLx/8he7Ggo6wIPN0yxmP7t34hCtvZCRdZIIEew5aeg04hVsUINpFYPPxskVXwY4OzbEQHmKQp6bJMRX7kWVBb7a2o4Rukns8KGoQNQmUEDydZ9fUH/6xUwrTGAT5M98AQ93HcyxgCXUjpRxTcFiDbGru9dCBlNyZrKTzV9XvFU5MI+rxLu5voHJYutI31H+XqZTUhVpTGyqEKvBa7eR0/sykzPIBQ9rhJPzzPEzsqXq7F5PHi2Hu58vpO7CcvTOq0UlSb6CDiPa6KN8WKSbUby//86R67nSTEuO1F+EbN9ziAXgArJ2ueM1aAQ48SMOgQkLYe82JyEPcAkZqfH4gTMfn+27SI+dlMAz9kyQZtsq3YCIV2k7Y1nKVWO0g0050RIoxPPhlqlAS57smZ6dO6TQtIj pGEQMeM2 P51IAvBXWYEymcedV9Vd56TIRBnZcFzFPA9RNbMlYUjzSlc/gdVYPhjjuE4r3c3cMH5RADY6J7xSumLHp79VanKybs9XSmI8nvZZsclxFesrZ4hfdYOYiHOsGd31E7Cysrrswl/6AX/hNmj77Cn1uu3G8Gs+4rJK9KADfipTGpu7PAKXNO3+n55QhSF0sGSxN88qI1KjHKPWhGW/7YoqNETfMTOF9m3vqLdtfUk575erEIM43FmR7vwLgxSABG5hJltqfIj3ZCuFzKy5FoAEHMFIwpCvwtowriiM3 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 12/05/2024 18:25, Alexandre Ghiti wrote: > Hi Ryan, > > On Fri, May 10, 2024 at 3:49 PM Ryan Roberts wrote: >> >> On 08/05/2024 12:34, Alexandre Ghiti wrote: >>> This patchset intends to merge the contiguous ptes hugetlbfs implementation >>> of arm64 and riscv. >>> >>> Both arm64 and riscv support the use of contiguous ptes to map pages that >>> are larger than the default page table size, respectively called contpte >>> and svnapot. >>> >>> The riscv implementation differs from the arm64's in that the LSBs of the >>> pfn of a svnapot pte are used to store the size of the mapping, allowing >>> for future sizes to be added (for now only 64KB is supported). That's an >>> issue for the core mm code which expects to find the *real* pfn a pte points >>> to. Patch 1 fixes that by always returning svnapot ptes with the real pfn >>> and restores the size of the mapping when it is written to a page table. >>> >>> The following patches are just merges of the 2 different implementations >>> that currently exist in arm64 and riscv which are very similar. It paves >>> the way to the reuse of the recent contpte THP work by Ryan [1] to avoid >>> reimplementing the same in riscv. >> >> Hi Alexandre, >> >> I've skimmed through this series and the one that moves contpte. I can see there >> is definitely value in sharing the implementation, and the rough shape of things >> seems appropriate. I had some minor concerns about making it harder to implement >> potential future arm64 errata workarounds but on reflection, most of the >> now-shared code is really just wrapping the primitives that are still arch-specific. >> >> I'm going to need to spend proper time reviewing it to give detailed feedback, >> but I'll be out on paternity leave for 3 weeks from end of Monday at the latest. > > Too bad, I expected to discuss that with you at LSF/MM...But congrats! > Hope your wife is fine :) Thanks! Yes its unfortunate timing - there are a few topics I would have liked to get involved with. There's always next year... > >> So realistically I won't be able to do the detailed review until at least the >> first week of June. >> >> Some high level thoughts: >> >> - huge_ptep_* functions could be working on different sized huge ptes - arm64 >> supports contpte, pmd, contpmd and pud. Is keeping them in contpte.c >> appropriate? > > Hmm indeed, I'll see what I can do. > >> Perhaps it's better to keep huge_pte and contpte separate? Also, it >> only works on arm64 because we can get away with calling the lower-level pte >> functions even when the huge_pte is actually a contpmd/pmd/pud, because the >> format is the same. That might present challenges to other arches if the format >> is different? > > Yes, but I think that if that happens, we could get away with it by > choosing the right function depending on the size of the mapping? Yes possibly. One potential future new user of this common code would be arm32 (arch/arm), which also has the contig bit. But AIUI, the pmd an pte formats are quite different. It's likely that arm would want to opt-in to contpte but not huge_ptep, so separate selectors may be valuable. > >> >> - It might be easier to review if the arm64 stuff is first moved (without >> changes) then modified to make it suitable for riscv, then for riscv to be >> hooked up. At the moment I'm trying to follow all 3 parts per-function. > > Ok, let me give it a try during your paternity leave! Thanks! If it's too difficult then it's not a deal-breaker. Perhaps just an initial patch to move the existing arm functions to core-mm without change, then all your existing patches on top of that would do the job? > >> >> Thanks, >> Ryan > > Thanks, > > Alex > >> >> >>> >>> This patchset was tested by running the libhugetlbfs testsuite with 64KB >>> and 2MB pages on both architectures (on a 4KB base page size arm64 kernel). >>> >>> [1] https://lore.kernel.org/linux-arm-kernel/20240215103205.2607016-1-ryan.roberts@arm.com/ >>> >>> Changes in v2: >>> - Rebase on top of 6.9-rc3 >>> >>> Alexandre Ghiti (9): >>> riscv: Restore the pfn in a NAPOT pte when manipulated by core mm code >>> riscv: Safely remove huge_pte_offset() when manipulating NAPOT ptes >>> mm: Use common huge_ptep_get() function for riscv/arm64 >>> mm: Use common set_huge_pte_at() function for riscv/arm64 >>> mm: Use common huge_pte_clear() function for riscv/arm64 >>> mm: Use common huge_ptep_get_and_clear() function for riscv/arm64 >>> mm: Use common huge_ptep_set_access_flags() function for riscv/arm64 >>> mm: Use common huge_ptep_set_wrprotect() function for riscv/arm64 >>> mm: Use common huge_ptep_clear_flush() function for riscv/arm64 >>> >>> arch/arm64/Kconfig | 1 + >>> arch/arm64/include/asm/pgtable.h | 56 +++++- >>> arch/arm64/mm/hugetlbpage.c | 291 +--------------------------- >>> arch/riscv/Kconfig | 1 + >>> arch/riscv/include/asm/hugetlb.h | 2 +- >>> arch/riscv/include/asm/pgtable-64.h | 11 ++ >>> arch/riscv/include/asm/pgtable.h | 153 +++++++++++++-- >>> arch/riscv/mm/hugetlbpage.c | 227 ---------------------- >>> arch/riscv/mm/pgtable.c | 6 +- >>> mm/Kconfig | 3 + >>> mm/Makefile | 1 + >>> mm/contpte.c | 272 ++++++++++++++++++++++++++ >>> 12 files changed, 480 insertions(+), 544 deletions(-) >>> create mode 100644 mm/contpte.c >>> >>