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 E23D6C5475B for ; Fri, 1 Mar 2024 11:29:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 689766B008A; Fri, 1 Mar 2024 06:29:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 611AA6B0096; Fri, 1 Mar 2024 06:29:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4DAC36B0098; Fri, 1 Mar 2024 06:29:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3B66A6B008A for ; Fri, 1 Mar 2024 06:29:33 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 017BA161305 for ; Fri, 1 Mar 2024 11:29:32 +0000 (UTC) X-FDA: 81848249826.14.1976FCF Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by imf23.hostedemail.com (Postfix) with ESMTP id E34FB14000A for ; Fri, 1 Mar 2024 11:29:30 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=kRvOh3uh; dmarc=none; spf=pass (imf23.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709292571; a=rsa-sha256; cv=none; b=AeIQ0oAh4GfLIb+teFMB1SQhTH8lsfD3zIhCFkjTc44rKcpO5zomwzPa95KAdVwcnfMbW3 f86jLyi01VRp/XeRXh5VaTNaSINRcONXMbCHRYzR0krp9alCUedC5iXLxI+zDBw25BkX/D 6gTnxCG9GUSPoBBYmJ9HGTOMdK8ELt0= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=kRvOh3uh; dmarc=none; spf=pass (imf23.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709292571; 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:dkim-signature; bh=N6rqbYpfS5pcWnhkyceNm4nCsA9xdZ82hdVcREX/cMw=; b=lhKxrB11jm+s9WTQZeHDWB8KJSG5fMrUFrK0H7yhKxcSu/exgWxlicd6If/XfejhuYmesh pWcqUn+RSw07kPgHOWu+15G4zhw4ZgLadJ//FkjUYYMIDP6EZQt0TSuNOq1BmjWW5jWjcG BVEkKTzDd2wdLpUO6krXarJysgeGplk= Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-566e869f631so187015a12.0 for ; Fri, 01 Mar 2024 03:29:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1709292569; x=1709897369; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=N6rqbYpfS5pcWnhkyceNm4nCsA9xdZ82hdVcREX/cMw=; b=kRvOh3uhMhBru7q5NYUgAiX7Mk9RkiyQQre+gVdLXU9WRsWjVxaq/GeW6ubXCADLvV OuyVKN61wBilU5g8Zxq5Xjc7oPRDu6vsyNg7/zbDJN1X5o9S5MIc3oYRMRBEjtwB4yv2 oHHPE1kYjC3RFf5/U7qiHlqtX9gKFQdlQzj5e6hDwKyxT/bGlla/WKCryfe8BJ/H+eaL tQc2hO5pfXWF+sc2IBkJq7SaVbGPO2VW3anClIZCogIEJ3nFu8uMmNGGb4B1I1SLmi60 wAF3vCVo5wniq63iFf82A20WStwkbOxH/0Hi20lh/KKI8JPz/yk7Zw+NSFyCZvRV+sM4 M1PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709292569; x=1709897369; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N6rqbYpfS5pcWnhkyceNm4nCsA9xdZ82hdVcREX/cMw=; b=I9NSGu7nCIGiJO8cnGLNjp9TaFjQ63xv59eRSudK8C6jWYfo/vbR2l57OGCT+IKwfD zmqQIRUsQOo15ZcDdHPJlbsALH4vMwtJjouXUdPDYgcB/48SM0E1BtSVpOa5oO7SuBz2 0pMiyipUlor0lVn7QkKpznpv7BoaznANxCAKyi/AqzXQU6ktyJKl6yU4JWJcyDcioUGS FA2+6BBvx6TbBVxcE0ADSoR9rCXaNJ2m3+zn4S5OOaoxRCHVaawt/aF6N2Gy5m4U0OWw NpVoiCIRbzB7pOm5hZ+NkEnrl6cPSiFFhxTDJC0zVD04RVSK9pBiUiNTZLy0MbCVTJst BhEQ== X-Forwarded-Encrypted: i=1; AJvYcCUGwvNoYH07MgUlpwwEjhsWVAjpy68OLFsGeBbBYHHk75tFFRMVunuinbooCyYboZbbC5iWelKFXFNo9EbPUS9wWV8= X-Gm-Message-State: AOJu0YwJj6hlCLUWCCJ3lLXN9ROW90H/fm8jSMXAPAkTIIRwjmM/6lbZ SG9hHyOCcvDgwNXR1SO3z50jt+98oEkNoGh2V6gDRqBCqN80ZtEWJtuZg1bw294z4ypjsmCZd3L tkXjlx++CMVvN2bgs6PXrCsVMILJDjiOC8WkKcg== X-Google-Smtp-Source: AGHT+IGhWExtL6QtBViwPNAoKlHWs7DOlO2fT48mVk9Foe5Dl0xsN+CFFn8dgQruLadr4n6Yxb7nj2ska+hps6+i1zE= X-Received: by 2002:a05:6402:222b:b0:566:6640:10e5 with SMTP id cr11-20020a056402222b00b00566664010e5mr938238edb.12.1709292569232; Fri, 01 Mar 2024 03:29:29 -0800 (PST) MIME-Version: 1.0 References: <20240301091455.246686-1-alexghiti@rivosinc.com> In-Reply-To: From: Alexandre Ghiti Date: Fri, 1 Mar 2024 12:29:18 +0100 Message-ID: Subject: Re: [PATCH 0/9] Merge arm64/riscv hugetlbfs contpte support To: Ryan Roberts 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E34FB14000A X-Stat-Signature: x184raf4x5ojssk4ep8xqhr3q38ci4hs X-HE-Tag: 1709292570-767578 X-HE-Meta: U2FsdGVkX18ptz5NBMrRJW2vIQClLqc09xQ8Bzq03WU9h4kkN2vhimOIQlXMA/z91trcd/hCfcf2q3g53I0DxwiaBqDxDZgybUm0UyqnbNgvaBL6nYNIkpvOg298xHlixFmZPZVQ9wdEv4CdzaTCCzyy5afM1QXIHKiESgu9Bb5WcTbHUm1rFwrcLyhZ34Wqnd3sICB1x4wWPXeyNGyKav5tbqjtUiCQj9RuQ/VYmPMWBIpBfsWsEB5BzD7Mnrjy6WDR/ts+JxxEqr+t3/iNe8t6z2PLhL2cy4l9nyYGMTvWB+psuU6WulCCEgRaaeHnXOCFVEtxn8puSMXn86VP2ySAwL0k721nYWh9r+XbALVHhqq75gG3gcIOYvcooDDTyz77etjyK3bHDexsh4zcUNMDpFDcKXRdsbnPqwlQbnsln76Lcs+hfPSDSCsPbbEon0p77M28NzlKZ1AbcuMeZiileV3/E2PTOkr5mIeyZNH8ebfCa6qRzsEt0lBZ10+XGkgvKk68jnuK89+hiEbvl6e76uEbsVA9hqm3PRd7Yo0UZQBJdc40IIohn7A2+q+/lNRnAII/5I/hOJwtWY+iNqwdjRgzSpY+e8UooZ9HVGx9T94irDhZC6z0RMvCcmZXzS00+L4u7QvhMscjery5eMR11ZPK7rx4k9lcm/efsCTQYsOoOg4nw3RftdBzoOOfyqMDvOmFJ2yoBoU7HWYxOID1flPfzjv16NWqNHLSNOc926g3wCCUB6Rp7+jh5tJEoPGBOs6yjp1ohgNYuRwUhK9Ts9+CDUdTyKrL0+SY8vyF4s7SfrfI9O8BOp6dv01W0L9z2tmwsySa+fnmP+2r8ZqdDfhQZN6bwofQFyGTLbGBsF62uPGXKhjD3p7sUFGJfb68kkyt7yBfR3eXj4t5TemnFzDCEfbrL/Dnw5QA/BR9f8/PE0w3a9A8pbmaUo5uitKm5m3Z9rt79FCn+o/ 8v9u8SWo umzMBTw7hjhlKel/MW05hJ074qZdJmOxMNS0f+x6FQLx/qzAQxyoW5NI3zpRPpLRONswRwNRptoGC1LfdjCdjdIbsehZU/qZRs94ZawI007vHOI+rel4lHTspkZ9PIkpNWzRGnKIebDAxiDaEpOiExi8B51PgZZjRNOW1T0uSUUUI55fzSyQzctwDftPQclTdxu3JQIw+YsjegbCkr9pu7QVo1BnE70Qo1eJYcF7MWui6uo9RUCqjy8UsGEJ8TgA9PRdNoDdKRvwyYdTOwx2jSKXdvo1deixMe44qdzfF+kQCBbutAe0IJldEKYpiigulmQWXnZ00A/mMx0bG2fa+Xtp5cPBnmeNH45/Bnf804+be7q3HY7qgC9jOtjLofV5R4PXjWkW/P4+e5jg= 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: Hi Ryan, On Fri, Mar 1, 2024 at 11:45=E2=80=AFAM Ryan Roberts = wrote: > > Hi Alexandre, > > I confess I haven't looked at the patches yet, but this cover letter rais= es 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 implementa= tion > > of arm64 and riscv. > > > > Both arm64 and riscv support the use of contiguous ptes to map pages th= at > > are larger than the default page table size, respectively called contpt= e > > and svnapot. > > > > The riscv implementation differs from the arm64's in that the LSBs of t= he > > pfn of a svnapot pte are used to store the size of the mapping, allowin= g > > for future sizes to be added (for now only 64KB is supported). That's a= n > > issue for the core mm code which expects to find the *real* pfn a pte p= oints > > to. Patch 1 fixes that by always returning svnapot ptes with the real p= fn > > 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 actu= ally > written to the pgtable is arch-specific and well abstracted. > > > > > The following patches are just merges of the 2 different implementation= s > > that currently exist in arm64 and riscv which are very similar. It pave= s > > the way to the reuse of the recent contpte THP work by Ryan [1] to avoi= d > > reimplementing the same in riscv. > > You seem to be talking about both hugetlb (which uses the "huge" pte help= ers) > 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 b= oth 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. Sorry my wording was ambiguous :) Thanks, Alex > > Thanks, > Ryan > > > > > This patchset was tested by running the libhugetlbfs testsuite with 64K= B > > and 2MB pages on both architectures (on a 4KB base page size arm64 kern= el). > > > > [1] https://lore.kernel.org/linux-arm-kernel/20240215103205.2607016-1-r= yan.roberts@arm.com/ > > > > Alexandre Ghiti (9): > > riscv: Restore the pfn in a NAPOT pte when manipulated by core mm cod= e > > 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 > > >