From nobody Tue Dec 16 11:30:27 2025 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6E058F68 for ; Sun, 26 May 2024 09:22:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=93.17.236.30 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716715365; cv=none; b=TTy9LcLbs5VNlJrir1qJjCy6y0NRitmV+qfbZHra/jVLXy7EuiVyje5zgyrGANn4XnP12WGvJQxSjoUQaDsznfvrSUzH/RXWc/XoBboymbsA74svJgf8y2MHw+n0Q1hnlUQcOKINSTSwi1p/jRZaFyxZbXT76ZPpPPuL+BWIAoo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716715365; c=relaxed/simple; bh=s0v230Xc7IJyTCzXwq1gOyIUEEd5goqZgRWHhBUOjyM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Lb8BrKa/PFxTtwwfrZTYkL+lYXOhvbDWOEl98gSy+ZMHy9TOYKzPTZiV6rdJr5ja4OYT5JUdUyhzAx0rgcuXo7UDLK0KorrOQQ1H1TrNjyEzKlCwiXJ+WIQlW4+v2T1FThk+UymlRKz5kOARIfdj7PLrgDf3L+CgM0TYYUmMqcU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csgroup.eu; spf=pass smtp.mailfrom=csgroup.eu; arc=none smtp.client-ip=93.17.236.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csgroup.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=csgroup.eu Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4VnCwj3wtqz9syd; Sun, 26 May 2024 11:22:29 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tK8ikVq4xNEL; Sun, 26 May 2024 11:22:29 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4VnCwh5qPkz9sgJ; Sun, 26 May 2024 11:22:28 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C37CF8B773; Sun, 26 May 2024 11:22:28 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id tdNRQ_4X6OiL; Sun, 26 May 2024 11:22:28 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.233.45]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4B4348B764; Sun, 26 May 2024 11:22:28 +0200 (CEST) From: Christophe Leroy To: Andrew Morton , Jason Gunthorpe , Peter Xu , Oscar Salvador , Michael Ellerman , Nicholas Piggin Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH v3 02/16] mm: Define __pte_leaf_size() to also take a PMD entry Date: Sun, 26 May 2024 11:22:22 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1716715343; l=1756; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=s0v230Xc7IJyTCzXwq1gOyIUEEd5goqZgRWHhBUOjyM=; b=rCtDW0DT5+DoZXoldqFbMp06NL2nENWDatDS8buR4SL2R3GFrWIrgloj7aNHCvF3/9Q5uhBAU kYyHH8b71LDAXUtZ2nXcDOUIUa0EE9u4cfhVm+9NAz3lMJrif7acaTk X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On powerpc 8xx, when a page is 8M size, the information is in the PMD entry. So allow architectures to provide __pte_leaf_size() instead of pte_leaf_size() and provide the PMD entry to that function. When __pte_leaf_size() is not defined, define it as a pte_leaf_size() so that architectures not interested in the PMD arguments are not impacted. Only define a default pte_leaf_size() when __pte_leaf_size() is not defined to make sure nobody adds new calls to pte_leaf_size() in the core. Signed-off-by: Christophe Leroy Reviewed-by: Oscar Salvador --- v3: Don't change pte_leaf_size() to not impact other architectures --- include/linux/pgtable.h | 3 +++ kernel/events/core.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 85fc7554cd52..514e05730df1 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -1801,9 +1801,12 @@ typedef unsigned int pgtbl_mod_mask; #ifndef pmd_leaf_size #define pmd_leaf_size(x) PMD_SIZE #endif +#ifndef __pte_leaf_size #ifndef pte_leaf_size #define pte_leaf_size(x) PAGE_SIZE #endif +#define __pte_leaf_size(x,y) pte_leaf_size(y) +#endif =20 /* * Some architectures have MMUs that are configurable or selectable at boot diff --git a/kernel/events/core.c b/kernel/events/core.c index 724e6d7e128f..d37512f2ebf2 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7585,7 +7585,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm= , unsigned long addr) =20 pte =3D ptep_get_lockless(ptep); if (pte_present(pte)) - size =3D pte_leaf_size(pte); + size =3D __pte_leaf_size(pmd, pte); pte_unmap(ptep); #endif /* CONFIG_HAVE_FAST_GUP */ =20 --=20 2.44.0