From patchwork Tue Jul 2 13:51:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13719683 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 A87E6C3064D for ; Tue, 2 Jul 2024 13:52:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 42DEE6B00B7; Tue, 2 Jul 2024 09:52:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3DD8F6B00B8; Tue, 2 Jul 2024 09:52:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 256C06B00B9; Tue, 2 Jul 2024 09:52:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 06BDE6B00B7 for ; Tue, 2 Jul 2024 09:52:01 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A39AA1201E6 for ; Tue, 2 Jul 2024 13:52:00 +0000 (UTC) X-FDA: 82294951200.12.87618E3 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf19.hostedemail.com (Postfix) with ESMTP id 7D6D41A0008 for ; Tue, 2 Jul 2024 13:51:58 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.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=1719928307; a=rsa-sha256; cv=none; b=lcmBTy8Yp52UAaiJornPh1q0ANgaIhACha2KrLoSYyGNPaMvh+o9fW+19Ql6BTlqLRXUUy rWQ071U8rQ79wqyjV4yAC2y5ht5PqXIYZlyVG1AuqwMqeLHqa55ap0Wn/g6aH0aSulWoYn Wzef1He3AAqDT0EcbzsLr0rfdF1fuYw= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.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=1719928307; 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=XzOg91sDK1hwoFPCHuMptEqxh9SprEvaPrCX2efe22U=; b=eLo9rZir1ykRSMMffzj0LXqax/ZTqmzU+FFF4ex0Kc32LNo6I+Ekw+GqQl/ga9LpI/MZ8U 0a0k7QOIsjoDUmt3wiOvFAlCCwpjfRhDYssZsSA8mtbMS0+LbgLf4PHi1BrLXphqW2aHhq BofPW1Zjy2LsBhkSECJGA+MkxqemPHc= Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4WD4841fp7z9v6W; Tue, 2 Jul 2024 15:51:32 +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 C9od68sRy3VN; Tue, 2 Jul 2024 15:51:32 +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 4WD4805RNyz9v4J; Tue, 2 Jul 2024 15:51:28 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B678D8B774; Tue, 2 Jul 2024 15:51: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 BGNhRIrkHoLm; Tue, 2 Jul 2024 15:51:28 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.233.12]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4106F8B764; Tue, 2 Jul 2024 15:51: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: [PATCH v7 07/23] mm: Define __pte_leaf_size() to also take a PMD entry Date: Tue, 2 Jul 2024 15:51:19 +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=1719928274; l=1803; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=NqqR+DBf4uYbt5gP7om6e3QFNLkHAAKdU42xGKHVcEo=; b=yV33hLP9H4xcUhyFxDXIt5LnxJgWqrCn1V5Xykpxq478yOcZTAZhwgAiteylu27VRD9Xbv6er iD0lsuBP5qqBVXJsr9LvPuLb4J+Nh0P8vxx5LpDXoG49QzJ3MzMfoS4 X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Stat-Signature: e5gi8eqqjh8wuoohwtuyxa4ofz6g9sk6 X-Rspamd-Queue-Id: 7D6D41A0008 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1719928318-245117 X-HE-Meta: U2FsdGVkX1+M/UyK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eQbE+3LjZUnykb0URSo4pvVA8LiWuw+sre0oLuFtXuSC2XY9wqbDGvFNQ+Qihc8aKPtbgSo5nTK9z7/CgI= 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 2f32eaccf0b9..2a6a3cccfc36 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -1907,9 +1907,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 */