From patchwork Sun May 26 09:22:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13674213 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 822B9C25B75 for ; Sun, 26 May 2024 09:22:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0060C6B008A; Sun, 26 May 2024 05:22:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF7756B008C; Sun, 26 May 2024 05:22:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D99446B0092; Sun, 26 May 2024 05:22:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B87366B008A for ; Sun, 26 May 2024 05:22:42 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 75421A2DDA for ; Sun, 26 May 2024 09:22:42 +0000 (UTC) X-FDA: 82160006964.21.90B10FC Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf25.hostedemail.com (Postfix) with ESMTP id 6F3EDA0004 for ; Sun, 26 May 2024 09:22:40 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=pass (policy=quarantine) header.from=csgroup.eu ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716715360; a=rsa-sha256; cv=none; b=5Jjd3pro+0jVjJLERCyvDCDTS4ARl4q5kJwocPiDBWRx/VILIdOxzC42ZH0QstsOvrgklS z0TC7Wdqtwh9wxuNuVIohGOgiTEHWeax0EZQAofLC1k5xgRDLCUSupidchwBb06FB6yU71 SwFUjung0Y+5Wqfti7jUhy33bgXFkiE= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=pass (policy=quarantine) header.from=csgroup.eu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716715360; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ddfv5gpI7P8gGugZkgjO40A/v+Kp2wMHqZfqCWDK/F0=; b=pHrmE8aN3utQeayT+v8ZcEzk5UtZ2vAk2wb8wOdmDTph0CMPchVMDjRm+BLeay71PAQM6v xRyvs5PZYo0aEFOC43zL3jLfVrrzr1WAOAmwmCtrpP0s2gKB6YzZ4Rg3MTy31pfmEeHTrF T2EWGn5YpjYUhox/T7Lpmpkn2r2xnSU= 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: 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= X-Rspamd-Queue-Id: 6F3EDA0004 X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: pt1jqqrzzs38hkbfwydfefdmfmbk19zr X-HE-Tag: 1716715360-344887 X-HE-Meta: U2FsdGVkX1+JZ66o2K4hu7/BR90xKvp0pmbbbfLzNMqBx2/qdvOPNR+zadu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lDtvsjMOMKDxg5cNanvMyY= 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 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 /* * 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) pte = ptep_get_lockless(ptep); if (pte_present(pte)) - size = pte_leaf_size(pte); + size = __pte_leaf_size(pmd, pte); pte_unmap(ptep); #endif /* CONFIG_HAVE_FAST_GUP */