From patchwork Thu Dec 19 16:44:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13915288 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 C01E9E7718A for ; Thu, 19 Dec 2024 16:46:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 54CB86B0082; Thu, 19 Dec 2024 11:46:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4AEC46B0083; Thu, 19 Dec 2024 11:46:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 300966B0085; Thu, 19 Dec 2024 11:46:18 -0500 (EST) 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 112426B0082 for ; Thu, 19 Dec 2024 11:46:18 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C277BB0E7B for ; Thu, 19 Dec 2024 16:46:17 +0000 (UTC) X-FDA: 82912284798.03.6472C7B Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf21.hostedemail.com (Postfix) with ESMTP id 73A581C0002 for ; Thu, 19 Dec 2024 16:45:12 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf21.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734626761; 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=vxpu9hpxVezNNfPXO+EkxJEzB3KeAziYK7om5MQJ0nQ=; b=G2k+iTPyQGl5eHV8IHbRbzpaRqpB+Ja9LA+ZJ2fA7d3pP09mwmNLbZu9thC4x80ybNLZyd 3Y2EDse70/63vzMTpsefJ/QfJGMXynHVUWH3FkmKur9PAnev0UjDfa79WC26Qw+ccvxbbl Nsq5unpXwCZOaF+Beuksj+1BFBmsF2c= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf21.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734626761; a=rsa-sha256; cv=none; b=e6wUNBii25aW2V1uWHEWLH/O4HSG53UkMQuV5tWnUh3ulUasw+ANJCgwlGRRlOEN75GKXb 75qAUbO7uLBM5XPmJozQLubutimCkwx/UYZ0i+pFQO1mgrA7EvALl5sqkiNTKMlhrD7Ovx WEm9bUocuF9iYFiPJ/i8WdNPhXRGkxI= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5FF7A1D13; Thu, 19 Dec 2024 08:46:43 -0800 (PST) Received: from e123572-lin.arm.com (e123572-lin.cambridge.arm.com [10.1.194.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 60DB33F58B; Thu, 19 Dec 2024 08:46:11 -0800 (PST) From: Kevin Brodsky To: linux-mm@kvack.org Cc: Kevin Brodsky , Andrew Morton , Catalin Marinas , Dave Hansen , Linus Walleij , Andy Lutomirski , Peter Zijlstra , "Mike Rapoport (IBM)" , Ryan Roberts , Thomas Gleixner , Will Deacon , Matthew Wilcox , linux-alpha@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-um@lists.infradead.org, loongarch@lists.linux.dev, x86@kernel.org Subject: [PATCH 01/10] mm: Move common parts of pagetable_*_[cd]tor to helpers Date: Thu, 19 Dec 2024 16:44:16 +0000 Message-ID: <20241219164425.2277022-2-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241219164425.2277022-1-kevin.brodsky@arm.com> References: <20241219164425.2277022-1-kevin.brodsky@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 73A581C0002 X-Stat-Signature: 8b9ff195ghtnigaf4qgqcx3kumo98ixm X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734626712-250855 X-HE-Meta: U2FsdGVkX19hG6A14f+L4OUEeOkPl9n5LjZHtqBjtTbuaxsfeTTUokXdnzykzOXIG4oZj1v3AZSUCcZ/NHJRyxkYbL/RFi52TfGjx4ccSvosNS+1XK4gftaNlac+1LMIGZQWfJe6D0U8KpmcuDl8W6J7trjPGkQur58q+NxiibwKOE/M2RUTwfUyF/nGhNBaZxtgstvt5xyp5f8Ii29+NllDCItrUL4i3uzloyZQ6rqIB1Iul5wqjRxyZ0re4D2UnNwJas2UffD+voqC8m4/PnPWgTPNoLw0j5VxdkMRNj5rOGGa1kvTEC3E7jhJs/C3IPKkC6hCnaRCyWgPOS48G7D5RA74qSyflkT+j5gkkO4DINreELcU070fT3WFAk9FyAJae/DGj5zMsZtiLhI9Wic4UXMo2ySxT1YW47Ny3th6CD2PbmEG2IfEsMdb86wumjBPhfXxXx1xnUEyyCRqL+9lV5yJqhgmX9ivaF7OApWPAlYBftP06h+R3efrKuSEgsAxqviYp7UJblbYfwn1A5TnT88dsOh+4aeirgkWaoyGyAKkerzp9PqxBelwZmyk6pTUuewPmUU8mVGGI8XO35VyH/yEeqGqyh1nY6V1YX1D79qjT2BWzDToKmYgIKObC25ZW3a+4Ld8zsz1NrZfZtIfiRVClClw/Npqa6A7lgXVd4n19C7xDajCzrjqTufAarKLjl7ZBaHCLf8K/fzusFmvbmtHvIeXN4rg3tQeU2m4syh3/XdBFnoZ4n51zKXtXH7/cFE0HGJ4hk1cgGKYgwiL2jXJUaQDplZPq2XpaXugVmYm02WiVkwFsv1mAyNNI7CxfGKH74iAQgghOXB5iEvaRtDNqIonpCRkAbtorSjx8TzH4wuuOS3geq78uC5oR48ebbKjYHUYxpqFSKZKCuNVHEuYrgryBpEc+N8MGE0FzA1vXYk/+y9PSQNzJVbE6nZB8iPbSQbq47OE2Cc nu2IXB5w Q+y5XOuwKOxlwY0/L1rctn2sN17+Yg7WN7ZuBS2wY7pNsbE0RczkIlyEpwgKwpmPJQGx44FdOXij6PfGZ8OI7rBIaobAqKonGTWljnBjQ5ou4HrwlqPy9I7xQuWHZyIFzRYCM332zRqAMLbM+LfOxy7bn94qQgDGCCWaa4eFqRreTjGhMkBXBnCIFpJ35pC8nS+tvonuVe+K3Fi+SiE+fXg3Ee3jhFiTIyIMJC80mMRWfU/TKbIV0V9RK4LyCRhvJaMsFhOkeZ/MLdiXJwedA4LbTu/iR24JyOTdSbc5NLsTdaDDz2h0TEc7QXY4Iw9gnDVlIltaeqp0ks1Y= 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: Besides the ptlock management at PTE/PMD level, all the pagetable_*_[cd]tor have the same implementation. Introduce common helpers for all levels to reduce the duplication. Signed-off-by: Kevin Brodsky --- include/linux/mm.h | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index c39c4945946c..a5b482362792 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2915,6 +2915,22 @@ static inline void pagetable_free(struct ptdesc *pt) __free_pages(page, compound_order(page)); } +static inline void __pagetable_ctor(struct ptdesc *ptdesc) +{ + struct folio *folio = ptdesc_folio(ptdesc); + + __folio_set_pgtable(folio); + lruvec_stat_add_folio(folio, NR_PAGETABLE); +} + +static inline void __pagetable_dtor(struct ptdesc *ptdesc) +{ + struct folio *folio = ptdesc_folio(ptdesc); + + __folio_clear_pgtable(folio); + lruvec_stat_sub_folio(folio, NR_PAGETABLE); +} + #if defined(CONFIG_SPLIT_PTE_PTLOCKS) #if ALLOC_SPLIT_PTLOCKS void __init ptlock_cache_init(void); @@ -2992,22 +3008,16 @@ static inline void ptlock_free(struct ptdesc *ptdesc) {} static inline bool pagetable_pte_ctor(struct ptdesc *ptdesc) { - struct folio *folio = ptdesc_folio(ptdesc); - if (!ptlock_init(ptdesc)) return false; - __folio_set_pgtable(folio); - lruvec_stat_add_folio(folio, NR_PAGETABLE); + __pagetable_ctor(ptdesc); return true; } static inline void pagetable_pte_dtor(struct ptdesc *ptdesc) { - struct folio *folio = ptdesc_folio(ptdesc); - ptlock_free(ptdesc); - __folio_clear_pgtable(folio); - lruvec_stat_sub_folio(folio, NR_PAGETABLE); + __pagetable_dtor(ptdesc); } pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp); @@ -3110,22 +3120,16 @@ static inline spinlock_t *pmd_lock(struct mm_struct *mm, pmd_t *pmd) static inline bool pagetable_pmd_ctor(struct ptdesc *ptdesc) { - struct folio *folio = ptdesc_folio(ptdesc); - if (!pmd_ptlock_init(ptdesc)) return false; - __folio_set_pgtable(folio); - lruvec_stat_add_folio(folio, NR_PAGETABLE); + __pagetable_ctor(ptdesc); return true; } static inline void pagetable_pmd_dtor(struct ptdesc *ptdesc) { - struct folio *folio = ptdesc_folio(ptdesc); - pmd_ptlock_free(ptdesc); - __folio_clear_pgtable(folio); - lruvec_stat_sub_folio(folio, NR_PAGETABLE); + __pagetable_dtor(ptdesc); } /* @@ -3149,18 +3153,12 @@ static inline spinlock_t *pud_lock(struct mm_struct *mm, pud_t *pud) static inline void pagetable_pud_ctor(struct ptdesc *ptdesc) { - struct folio *folio = ptdesc_folio(ptdesc); - - __folio_set_pgtable(folio); - lruvec_stat_add_folio(folio, NR_PAGETABLE); + __pagetable_ctor(ptdesc); } static inline void pagetable_pud_dtor(struct ptdesc *ptdesc) { - struct folio *folio = ptdesc_folio(ptdesc); - - __folio_clear_pgtable(folio); - lruvec_stat_sub_folio(folio, NR_PAGETABLE); + __pagetable_dtor(ptdesc); } extern void __init pagecache_init(void);