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 D150DC5475B for ; Fri, 1 Mar 2024 11:38:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D2DC6B0092; Fri, 1 Mar 2024 06:38:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 382BA6B0095; Fri, 1 Mar 2024 06:38:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 271866B0096; Fri, 1 Mar 2024 06:38:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 17EFE6B0092 for ; Fri, 1 Mar 2024 06:38:12 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id DF1091A0470 for ; Fri, 1 Mar 2024 11:38:11 +0000 (UTC) X-FDA: 81848271582.04.9E1AE77 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf20.hostedemail.com (Postfix) with ESMTP id 020E71C000E for ; Fri, 1 Mar 2024 11:38:09 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf20.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709293090; 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=tH0WWTLJCWHdRS6wRwsnQXxUMaFiqaWTgm9qGQCvvic=; b=G2KEYwidIiraN57amDY7Jw4sZl+k3Ar4xXnVG7VSBn6WPTDCALw5XCTP3+pLtiRCFG0OsX /JNLCPAsPL32rN3dAFKIiObgvwkcKhKPDid9sMe5FMHUcSiAdkSJ/vS4KRhLfLFDbiMVlk imXuViFmhtsKnwa/4B6YDrfXiE0Oep4= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf20.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709293090; a=rsa-sha256; cv=none; b=wkPWo1UQFbLNP/vRGteDykATkrP5rW+H4posF/ubRD6e0ydwbCvACvQ7aj5hsLvak2HtnV YpPoTESg3+mI4MtBPBZtXuYyPwvV1+DW7tkaJfdoE6lLD/LZ4jpdZvh/PR6lX2T/UH6dr5 Yl1uwEgnzp4c0A85pHMIWnZrQQEhSkA= 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 2DD371FB; Fri, 1 Mar 2024 03:38:47 -0800 (PST) Received: from [10.57.68.58] (unknown [10.57.68.58]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E30923F6C4; Fri, 1 Mar 2024 03:38:06 -0800 (PST) Message-ID: <63b9dc1c-7bf6-4de7-8d23-cf54e3408207@arm.com> Date: Fri, 1 Mar 2024 11:38:05 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 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: <20240301091455.246686-1-alexghiti@rivosinc.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 020E71C000E X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 6fdfmsjo5etxheyxxqcag1bn4xbyfqz1 X-HE-Tag: 1709293089-972031 X-HE-Meta: U2FsdGVkX19UmTLbqizZukQ+mRIfvJlMVynkXlkUjngnvFK+LEyMN8p7KlMEY+Tch2KWCyqriioHsoDkRazLk7o/de4Y7nmJjJu3hHLLE5bDUrXrXFZe1L8Qsh8CFS3cqt37d9mWFopkUQmaBIluBrcTS9wEj5hzFJE+SqyFfUtPwcRxh3qGnD256n66NVD4Ls1gSxDJUvezXQ7zgmY7oQURHDLIOq+Ces83yFLe7HixO9oq1Gn7+/vFWERT2Ut8aHFL9WX0DX3n2DMiaSdmbUoDSMKJ7rUoQSTXqQ3T2Lb2C4o3hOGmt3aHKvgTU/Sy5qKvapovmZCgnmxUutyv6BDgp7rCMtzjzkow8eugpmmMR0gc6uRlXTCjgQuiDavevdBGhlPzdJwcI64/dG1ovymQ1f3UicvfZ7ufT0mBYPsNCkYF+O07rf5D3jzJLkUO4Rf8KUOF4w16GuZR65JzURQUm8aGm7dbW6aUG/ukglbgoWbbxTX/I1jt8mRYe6UglVIWk7jbcKQFwnsF1Z6kkiKYb80xHMMTWwOcEKB+XK9HiEXQaXU/i87ekfBTZmdWrJ18tqY4xNcX5xdTUVP7ntenmCrZkqv/kb2+EBsrSpM+dBylykuk16cZFZZ3wfr1bYYOw8oacJgEeRDvjj4Uhadu2HhQi0iFigkTmsWLU33CqhU0P5Atyk1xeJEoXSInSSjmG6IYcN+eLXqLa22cWnVTuTcJgyYwBBfMBOwQQvGi8k9i8gMBxtJbNJFkdmWJhk5hDmRIOnTmJnGEA3CaDaKhbD8PjPdXNK/hOWoiE60NKL/gfz2OrLkBXiqIdHkI7SxwlVHnKxRdXoYInOXJDzbsLa3XfzrK 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 01/03/2024 11:29, Alexandre Ghiti wrote: > Hi Ryan, > > On Fri, Mar 1, 2024 at 11:45 AM Ryan Roberts wrote: >> >> Hi Alexandre, >> >> I confess I haven't looked at the patches yet, but this cover letter raises a >> few quesions for me. I'll aim to look at the actual patches in due course. >> >> On 01/03/2024 09:14, 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. >> >> Yes that makes sense to me. The intention for mTHP (!hugetlb) is to fully >> encapsulate PTEs beind set_ptes(), ptep_get() and friends, so what's actually >> written to the pgtable is arch-specific and well abstracted. >> >>> >>> 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. >> >> You seem to be talking about both hugetlb (which uses the "huge" pte helpers) >> and contpte for THP (i.e. mTHP, which uses the regular pte helpers). They are >> pretty separate in my mind, so not sure why you would be modifying them both in >> the same series? > > I don't, this patchset only deals with hugetlb, I just meant that this > series was just the beginning as I'm working on moving the contpte for > THP support in the generic code for riscv to use. Ahh got it! Thanks for the explanation. > > Sorry my wording was ambiguous :) > > Thanks, > > Alex > >> >> Thanks, >> Ryan >> >>> >>> 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/ >>> >>> 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 | 59 +++++- >>> 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 | 120 +++++++++++- >>> arch/riscv/mm/hugetlbpage.c | 227 ---------------------- >>> mm/Kconfig | 3 + >>> mm/Makefile | 1 + >>> mm/contpte.c | 268 +++++++++++++++++++++++++ >>> 11 files changed, 456 insertions(+), 528 deletions(-) >>> create mode 100644 mm/contpte.c >>> >>