Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp279520lqt; Thu, 18 Apr 2024 15:12:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXTzs6XvtVE7RwFFi2w4cdZaZcGlNZINBGA+ZsDlsdS4DzkJVK+ShpQTORaAB0TfdSIa9Ikwoo+sg6qnRCA/mO3xZbPy058CJcyTXmUMw== X-Google-Smtp-Source: AGHT+IHu560jMorHY79aJRpT7TA49zZguOWXMdcrSI38tFY5KSDUF2sSoK8bLGTDBLu6D0mZWeDQ X-Received: by 2002:a17:906:d975:b0:a52:71af:405d with SMTP id rp21-20020a170906d97500b00a5271af405dmr214882ejb.56.1713478335918; Thu, 18 Apr 2024 15:12:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713478335; cv=pass; d=google.com; s=arc-20160816; b=tLZ2k75+ToGKTlYlFLPUtbBg6x9tWZv+gpVnlnUhVyqbOl8IC9MncV6gQxCROw+ONz 4bDSvXS8FdaCup4eSgsXuqJ3GaquA3PA+4pTI0U60/PiVbVMaE+gcqj6Mv7yOt07KuQx /1gM2zQoUmZjTwSAHMGHK8WLcQ6jFfU0UqYll9knQQsHoaOoqPNFloSQjZvZHJlaSdHK XnRb8XOgBpGiH3pcnVSbV8SK6S8NIKuUOaORklUSteqrlRTfuH8rFflJnlwQOIipbJBq sEpwaXG1Ge0w3WUreSTHWcQ8T4HSkcIg8zfIl1PlbJITztfCyFFUdxNn+3njenttYhZL DS/A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:to:from:cc:in-reply-to :subject:date:dkim-signature; bh=fJWNYLKtKkE3VgEEb7txo69kf/MROzgyItmd/8X/Bkw=; fh=WlDz+t8tgt8NuohXfXmSPyynpbOxsSM880wBkh78scE=; b=upFxkzoOm11uqhj93L7+NXs+Gl8Xq9nYcXJ5Yhl5JAKamOZcG8Qfub9A/g1QSjnzPw m0UfmAG+SbJYvjtLoer4wWY+HDkKC4aEBasI89XAGByw+uHI50f3ZUXdcIpl+QSa7Bk0 r4rY4CxXdyWQmz+pam6cqMUQ3/pvPaquH0FzkpPwaA5++P8lSRGxoOPc4cd2t68SPCz1 E6stCwVonHprgtAM+FtvMw4y9BSMRHIKmWdToneoO6npb+jiuJuJZ4ZNhSKn/rpWo9zx Chla8wyTNTI0A2ZkiHysQZSYLOcSg+FsHQJcknYGyz1Xiy06fN7mpdGVFUeF3R3XYJJa TGOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@dabbelt-com.20230601.gappssmtp.com header.s=20230601 header.b=zDheyhDn; arc=pass (i=1 spf=pass spfdomain=dabbelt.com dkim=pass dkdomain=dabbelt-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-150826-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150826-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id oy9-20020a170907104900b00a46b108619asi1317105ejb.52.2024.04.18.15.12.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 15:12:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-150826-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@dabbelt-com.20230601.gappssmtp.com header.s=20230601 header.b=zDheyhDn; arc=pass (i=1 spf=pass spfdomain=dabbelt.com dkim=pass dkdomain=dabbelt-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-150826-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150826-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 62ADD1F22BD9 for ; Thu, 18 Apr 2024 22:12:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF1C7199E9C; Thu, 18 Apr 2024 22:12:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dabbelt-com.20230601.gappssmtp.com header.i=@dabbelt-com.20230601.gappssmtp.com header.b="zDheyhDn" Received: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.41]) (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 ACEBA180A67 for ; Thu, 18 Apr 2024 22:11:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713478320; cv=none; b=qJ9e97KGivtovLbcTQiV6K9EbF7XYMOi5YpXrr5iXhx6ivGDypN941q84fT3hOeGl4MSAbHzFo0LWvCggO8XpNhnm/QTKcofZNKlDYsGE5gGWV0MVH7L4pThCWuitF4UpilzoGxSxjzphr+j67nBtyuzwbQ8mgYRCImCfXfsuGs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713478320; c=relaxed/simple; bh=qC73A3C+2ySXkYRdhc6wiS5hdCuQCzyFsXeqp/DMf2w=; h=Date:Subject:In-Reply-To:CC:From:To:Message-ID:Mime-Version: Content-Type; b=gGrszSREAQhzv4KuKyg0gdosuURTAvwA6YF0dUhPAHYhQ0QeaoUl9umU537t4IsxBbF1O8xonTb31DrbUQVeSumfEPsatLDTBxfcienOxek1ribRfbLvHQfT14RElLKg2pMW/peemeUXWuD7dKznePQkHqbUTx5cgZ5KUm8SXNA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dabbelt.com; spf=pass smtp.mailfrom=dabbelt.com; dkim=pass (2048-bit key) header.d=dabbelt-com.20230601.gappssmtp.com header.i=@dabbelt-com.20230601.gappssmtp.com header.b=zDheyhDn; arc=none smtp.client-ip=209.85.160.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dabbelt.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dabbelt.com Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-22ec61aaf01so833626fac.2 for ; Thu, 18 Apr 2024 15:11:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20230601.gappssmtp.com; s=20230601; t=1713478318; x=1714083118; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:from:to:cc:subject:date:message-id :reply-to; bh=fJWNYLKtKkE3VgEEb7txo69kf/MROzgyItmd/8X/Bkw=; b=zDheyhDnes1JFgEb7i7lavl61MoAOiTBxb0W4oMg1oV6h4nwVnyGvQPlc/EOT9cING dHak2xF2NisrUCnaHNcrig7gQQXANiOeLOJj66w1aW12agsBDJlDTH4h2aKdFF+BgPpx XPQKpaVpSEN2sPvFN28+Jdsyqcgv/ea6Wi6M2hO8kW4GD77xJ4Niis991ryVbYAGvhtL quRpnFMRAXYFrVdxpR+KzoGaA6ARa7IG59vN1BRIrIMx+Q0fV96XJglo4EkA1zlR1Lwo m7LU8g4OD8/O8+4D5eNRXq7KyVerZsNQ76PBG7Xi4w3l2Bc83uIYGuVXDMcKT7kPeDnO K88A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713478318; x=1714083118; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fJWNYLKtKkE3VgEEb7txo69kf/MROzgyItmd/8X/Bkw=; b=ZpoZ+RkHuxeYIvQSk6oKh6r94QNIs/cerufNxA24XAsFTT8zref/EIY7DeVxf1zhXb +rPxE+bnEVxSsoHaeDamFTuiVp7Ef34a+7CV8NY5PEj9j2e2VWGmZMQOVfrn0PWLw7MH fpe9GEDpN+jVTsGZqeNaft3IiZ6/i5IeYC32WCWqd9w0h43Jgv7mUiT0oanP8eb1yxf1 1GpyL3CP4+gM2z5uMtU39R2Xri7RCZBbGvCc7drziDObKj20WvCjPZxy2+pu/PDjm9vy WC58Dqi7YrFNA1a2y0//g1S16IICKOoiVpsgRHla5J7fokWAaCv8FQ88DcnvR80jYPBq YepQ== X-Forwarded-Encrypted: i=1; AJvYcCVLPOdA9FVMalwar0eXr0fhcoiftq9lwVfb2czUpdDeiDwyLWlj1T+s/30CZ62ab+cHcFFXd9nuk09iZ9LLoiNMo9c1ywiA0cvuQLJT X-Gm-Message-State: AOJu0YzodU9SO6PFDrc3JEVrYQwPvllBMYgwHBHFnFjaMthTSkq9q2wQ b0rN0w5CeX1+o6CQGI4DamFGl9f9ELWlkcoS+AcDsIIggooEiidT7xRpTgudtl8= X-Received: by 2002:a05:6870:d187:b0:232:ff53:44fe with SMTP id a7-20020a056870d18700b00232ff5344femr362648oac.38.1713478317422; Thu, 18 Apr 2024 15:11:57 -0700 (PDT) Received: from localhost ([50.145.13.30]) by smtp.gmail.com with ESMTPSA id q9-20020a63d609000000b005dc9439c56bsm1877624pgg.13.2024.04.18.15.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 15:11:56 -0700 (PDT) Date: Thu, 18 Apr 2024 15:11:56 -0700 (PDT) X-Google-Original-Date: Thu, 18 Apr 2024 15:11:55 PDT (-0700) Subject: Re: [PATCH 0/9] Merge arm64/riscv hugetlbfs contpte support In-Reply-To: CC: ryan.roberts@arm.com, Catalin Marinas , Will Deacon , Mark Rutland , Paul Walmsley , aou@eecs.berkeley.edu, akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-mm@kvack.org From: Palmer Dabbelt To: alexghiti@rivosinc.com Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On Fri, 01 Mar 2024 03:29:18 PST (-0800), alexghiti@rivosinc.com 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. Acked-by: Palmer Dabbelt in case someone wants to pick them up via a generic tree. I'm happy to take them via the RISC-V tree if folk want, no rush on my end I'm just scrubbing through old stuff. >> 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. > > 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 >> > >>