From patchwork Mon May 27 13:30:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13675242 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 CE85EC25B7C for ; Mon, 27 May 2024 13:30:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 630436B009C; Mon, 27 May 2024 09:30:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E07E6B009D; Mon, 27 May 2024 09:30:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A8D86B009E; Mon, 27 May 2024 09:30:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 277D56B009C for ; Mon, 27 May 2024 09:30:28 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D829541163 for ; Mon, 27 May 2024 13:30:27 +0000 (UTC) X-FDA: 82164260094.04.2BF34FC Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf30.hostedemail.com (Postfix) with ESMTP id BE09480020 for ; Mon, 27 May 2024 13:30:25 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.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=1716816626; 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=EvYMtuouinBr8WHe20VZQSOrHDgdpezRWdfbShqnTac=; b=FBeSbeZihA2NEUvdW6AhVeL6uS3b3CCocaGBJzk/9AD+JH9yDRc8F07DxpJGxfsPm8S4ys C+r1eZr50jfYOyKwcHDDrhe3yJDlvgQGooPF1o1eyysdc7t9RUaLRMEozLqNmHFMLj9g79 qe5DUByxv4ePiPoHZivehfROPxYa/n4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716816626; a=rsa-sha256; cv=none; b=WGsHTQWQivkxrAGj6R8NXQy7mv5mJXS8hqPx6Rr02TK5wJ2FeqSwL12i+3NDqUoX/oXJbC jCkT8dcP+aAz9H8KT6tjxRkZvtEUxt4KqTJA10t/v+h6hanuUyiCRWRju23tC9kDza4aBp d24mDasrEg5iFpuElGl8eZ8P5ofdwfc= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.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 Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4VnxNH3X8Nz9syd; Mon, 27 May 2024 15:30:23 +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 lK-Qu1YbbiXB; Mon, 27 May 2024 15:30:23 +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 4VnxNH2tB8z9sqS; Mon, 27 May 2024 15:30:23 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 5D3D88B773; Mon, 27 May 2024 15:30:23 +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 hmmxoWXQmTJi; Mon, 27 May 2024 15:30:23 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.232.49]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A92238B764; Mon, 27 May 2024 15:30:19 +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 v4 02/16] mm: Define __pte_leaf_size() to also take a PMD entry Date: Mon, 27 May 2024 15:30:00 +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=1716816600; l=1803; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=UzfhNq5PmSTEAt037maHDDYdpiu9u0KQG11+Ji9a3Ko=; b=QTMHKiCYoXWonuyH5nH6U6kLDwMLXHwSww1cSyPU33riwsvrJQGt9NlFB1qDR9YbUHKo9aZhD LWoqX2Vka/mAIu3z8TYAq2rQ45aYu14RwGhgdDeAjsMt9EKpC5bwNit X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: BE09480020 X-Rspam-User: X-Stat-Signature: ogxtrpmb3bq9n64mfuigzudjhrq9yw89 X-HE-Tag: 1716816625-294571 X-HE-Meta: U2FsdGVkX19NSlB8JCYVBLNlGMbaszmcARBxYgDkKMueEIyLBAQ5nNpzeu2y2FE7Ch78NVJkM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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 f0128c5ff278..880df84ce07c 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7596,7 +7596,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 */