Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp225470lqg; Fri, 1 Mar 2024 03:29:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWnXcofjnhHl7Suq0PShPpDGtYTJkoY21mc5foJKYAGqOTc6MpdfUEfz0FA4ZPruVDLY1O0TdA0gJBmEm3eLFfyohHtnlg0qONivY7lrQ== X-Google-Smtp-Source: AGHT+IFysCqPi1Z0vxpPE5Kre6q43P62UIQpRi/Uj/qGmFnLM0JgJ9aqGnVedxO285F/l7uBlBKM X-Received: by 2002:a17:90b:889:b0:299:87ba:8a2 with SMTP id bj9-20020a17090b088900b0029987ba08a2mr1310873pjb.41.1709292580671; Fri, 01 Mar 2024 03:29:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709292580; cv=pass; d=google.com; s=arc-20160816; b=eK7YGn1h89Rq559OTBepFtFpg/ZI+stD1B4RfSjxwRSz2eXPgzt/2yOCfWBh/ZzFnj YdocS3msGsgBRXVieJzPS6upt1lsUnKN0a5SW4MrvdJrQj7WmzUn2cUu27hz1u74G73E 7ZLsEJs977tDVy5oJFC0JYBJFHG1urXcYzIsrdUz7uIIXVe6MK2/pmv8JIJQPqO7qsYL MNvvw4inWhb9vaUhVDsA53kbenPpIabPhIMek+NAmJWNjGbtVIioB4uk0a92Yu15DnMH jtktjq4aon9lP+Zckn50oYzEc86AqTp3I87LTU0A4JnoMX1W3lfl3HWXH4dYNp6s2Gbm 3CQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=N6rqbYpfS5pcWnhkyceNm4nCsA9xdZ82hdVcREX/cMw=; fh=qFSbEQiUOSQc7Qh5coC9oIKMarg8vJn/heimGubTtMI=; b=T0faf0sNdpK2UcAk6POOlXqNM3lKFeUMleLqfClXSmHIx15niRKXypizlXITEsmAFR 72p21rheiJLmWDdEJE3Naa/fXlQMepgYAx7bVretZZByQguH/yknLyoHuw5/Rkwfhg/0 nP0+SqDUlxnl0IF+rLzH8BUnQa796x+2ydlL70kwCcwHSX1cSMMmoBgGhj/nIZH4UOgs ad/Vdz+p22VG1DoCgv7R4IQd+yVXDRLgFMo4MMLRjY9lNIrtarcYzH8P+u+3c9Cu06zx NPzozi+90gUK2mJ/gUYL1d5JwQeo9Uyd3Exczzeq9as0Dy9VUmd2fg4FERZ3cQqibtvB GzyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=WneJFLwN; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-88342-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88342-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w3-20020a17090aad4300b0029b09d0be08si3525458pjv.103.2024.03.01.03.29.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 03:29:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88342-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=WneJFLwN; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-88342-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88342-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 52DE2287DDF for ; Fri, 1 Mar 2024 11:29:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CABE96CC00; Fri, 1 Mar 2024 11:29:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="WneJFLwN" Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 7B0B74438E for ; Fri, 1 Mar 2024 11:29:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709292573; cv=none; b=ETYXOmoQzutl6FahQC8tW42+os+Oe/NLAP8nDHXgKwdQwVoL99aFnfN9wmUON6doGMHfRC5f4qA/AVyVbFfQ0rPsgps0fzgAnw+VnzvmInjtoAipLu7aSrzbwJ/+IMIfn2elES62sHhhY9EcEZ5wPb/zFOD4BgzyMOndE4O2dAE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709292573; c=relaxed/simple; bh=JP0454diuQRJWxe3AgLViK7eNSSpoIs2Qcd44phtQ1U=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=B/BVNsbzRymOy7LJqwz422YWk5b5ZfBXxVbOCHTnAp3Thqo4OxnBBvVsgQxNA5h6ZRQsY8juto36oytfRQmvHtITLDeG/9Fu06mkZs905sVxS1YPxXm5ORxekB3RtT4yRhKreV2KBiAQEUS9nfcHPDYvjB283mXb8ELzdi+XIQM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=WneJFLwN; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-566e869f631so187016a12.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=vger.kernel.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=WneJFLwN6GrhP8pFgBS6R0ZlODnnxQ5/+Fwgw7iE4P73MuAQZJg7fD81SfFJZ7zRuj iQDickLD/WqKwsOXPs7MHdO2/AqOgf7Je0Rg+JNOFlR/Cxg3pa3GA9e93LT7OGgFpbG8 QroQbl8YBtUhK+HKlWMuq/VgaxMXi08u/q+btGX7qGytIjKXJIZbR6bkV+lO5lLmLSZB Psfnoa/QS25ow6X5YtQrEGEmO2nxD5VGnsorMPTFcvteMzov9AT5+X6BCBz1LwxDIh95 rv30ZkijHSW1rWV7Tnxp8cnL0caZtzrzrxQofUAf++mdp/bCfMdN/UCGTOGIJJ1mOryf EbHA== 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=cyXOl0E72rpdaX3X5Wp7sEAID+vnTG2zleShUJQIw1U4UxzxUqi8UWp+0nYWKJijQX AuIT6kQZvBjM9LNZFnRPr3XhfSoXytA0YA3nf7uBuVJBbst5kXEOp5JK93562LIWUUTD WN28JaOITmK2czb+6dF8ht9kyTphAsPr92hLteM9hdvL2b1KEFqROdrdOME5rKTxuXTw jFpWj8wvwV1M5zlSC++ZfTgPPGEBG0KnBz+CJ6o6cL1lHJI8M35MB1TJTzfM53IaT1G3 rY1k1P8Mzv+s6Ra8VfB6R6PV2aDpnM//F08kyproGxp5SrxLTr9EPW4ekX7NSDfjPrEU 1Ndw== X-Forwarded-Encrypted: i=1; AJvYcCUwwxUpqMRjJ0MrIkSGVo8BAhEOJho864pvnbSiVDdo6aX67qbAGuEPwSqA8s2h64rmlGdqQgkkWAgwINfRkdLNZPutG8Rm9wuTbhAc X-Gm-Message-State: AOJu0YzrDRRy0YzQNe0/FVorkfgUIthCBlJIaY8pkCYEg1iQ4swpERJ4 x4Xdfp4Zd+ORf0HOxtVdU1UN7gW3enrKLDVfznSQzV2GWv5c+vSqS+v7uq6YIawN427IVgIur4k //1Z6DTOqWE9e4epnUTf44Y2jAofrbYh/8FdTfw== 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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 > > >