From patchwork Mon Jun 24 14:45:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13709596 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 463B7C2D0D1 for ; Mon, 24 Jun 2024 14:46:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5A9D6B03DF; Mon, 24 Jun 2024 10:46:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C09236B03DE; Mon, 24 Jun 2024 10:46:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD0B96B03DF; Mon, 24 Jun 2024 10:46:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8D3AD6B03DD for ; Mon, 24 Jun 2024 10:46:37 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 426DDC10C1 for ; Mon, 24 Jun 2024 14:46:37 +0000 (UTC) X-FDA: 82266058434.07.5730E1B Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf21.hostedemail.com (Postfix) with ESMTP id E44421C000F for ; Mon, 24 Jun 2024 14:46:34 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf21.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719240382; 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=bLA/IyV+Vz072mej7hfUjzvBe8FyLqapKuPBNRIxOz8=; b=yRvwajHF39xhKHiKa8BwUx+4YqktgrWN+5MexAKSDCp2bL/X8X1i0R/4j/uufMb/Ye0Hpf j7p9Y+qMjVBWk+fifVDN0zJdounnINqfhD4mm3jt5hlzONcGASbYsjbGug8Cn1hcbmlQtH 4cPfHyXvrApe8hzXTlKi6uuWGXbd7uY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719240382; a=rsa-sha256; cv=none; b=tNNlynQjMWeCmWfdiK5QCWc4xGtQPTnZhY9Cscve5xLX4wBe1JvcTjfMJWI1ECkpPoseAv lETxKL99sJio4aeMrsltHl16J4XJQX0fw1LtXSRWnVl1FFTMU7CBzEQJyp9smnWCbfQ762 K/vguqO4C1xzeBhCoL7J5QlqpN1SnlM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf21.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4W79kk1DQ3z9vFt; Mon, 24 Jun 2024 16:46:06 +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 RNZLCqwLMOhj; Mon, 24 Jun 2024 16:46:06 +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 4W79kf30CPz9vFR; Mon, 24 Jun 2024 16:46:02 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 60E048B766; Mon, 24 Jun 2024 16:46:02 +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 BYiPVjqr0x0I; Mon, 24 Jun 2024 16:46:02 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.233.33]) by messagerie.si.c-s.fr (Postfix) with ESMTP id DD71C8B763; Mon, 24 Jun 2024 16:46:01 +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: [PATCH v6 07/23] mm: Define __pte_leaf_size() to also take a PMD entry Date: Mon, 24 Jun 2024 16:45:33 +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=1719240333; l=1803; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=ApxdfzE7YD3L0IuoDaV5UxphNVd36HJ10PPOy4i4Q1E=; b=1v+yyodsHwTDtnfuXp4KYWw6pFDlQLxE6onELG4gmqQFzzC3JFznfnCZIj1YRQX5maLeosEdw aX+0l4dc5DyCrQ40QfdOuwE/SbzAUjyU7xAx4ONIHh8xK0XQvMR6nQq X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Rspamd-Queue-Id: E44421C000F X-Stat-Signature: 9huw74ngsu1b36btt7ta6pomcjmkiwuw X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1719240394-644914 X-HE-Meta: U2FsdGVkX1832o9HwPFcaVIhLF8IAMubHO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32uwOGUNRYa+2Iv0+ekk3sPzZgFFO5OKsccqMvmj0KbRvJ9AyCtDeWQGOw= 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 18019f037bae..3080e7cde3de 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -1888,9 +1888,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 /* * We always define pmd_pfn for all archs as it's used in lots of generic diff --git a/kernel/events/core.c b/kernel/events/core.c index 8f908f077935..b2ca11bdc11e 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7609,7 +7609,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_GUP_FAST */