From patchwork Fri Jan 3 18:44:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13925790 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 63098E77188 for ; Fri, 3 Jan 2025 18:44:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E48406B0093; Fri, 3 Jan 2025 13:44:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DF4216B0095; Fri, 3 Jan 2025 13:44:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C95A26B0096; Fri, 3 Jan 2025 13:44:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id AC7736B0093 for ; Fri, 3 Jan 2025 13:44:36 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 25B9CC0A49 for ; Fri, 3 Jan 2025 18:44:36 +0000 (UTC) X-FDA: 82967016552.27.2663F86 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf07.hostedemail.com (Postfix) with ESMTP id 6AA0540002 for ; Fri, 3 Jan 2025 18:44:34 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1735929874; 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=vSoOMdn+/GfqJnDjyLF0mh7cPRiC2LKGG844rQUUfqE=; b=GE7CdlvY9uZmPZuBBScBhLp4ggHYgtPGqOGciI+0xi4nb6fjJFj5KKvhuN22Fmp4IPTb4j 6dJUTWIz84Er8pya51ZQ+2nJPy3uFzV3lEkO0L9rulSvOU63YlWeQPeMoGcs0vETPgeLt9 1s/w6d7lTcCbxBO/PC0sugvjTFEu0ac= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735929874; a=rsa-sha256; cv=none; b=GawkmYZd20NUBP7f15Lw7wPrFX8jDJEH8C3YIM5orj6a8z8htdHU3ZNU2vYhvxtN+zxgVg NytKPuDdEj9W60fryZhzZnL6lIej1kOmDqwL8jTWzzoZVDG4NgfwP3DfJVA+GU/d/iPauS hr+q4wzbCoG4BtA+lDlCRQnVOUCZ9cg= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com; dmarc=pass (policy=none) header.from=arm.com 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 A16E7150C; Fri, 3 Jan 2025 10:45:01 -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 6B3F53F673; Fri, 3 Jan 2025 10:44:29 -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 , Qi Zheng , 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 v2 1/6] mm: Move common part of pagetable_*_ctor to helper Date: Fri, 3 Jan 2025 18:44:10 +0000 Message-ID: <20250103184415.2744423-2-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250103184415.2744423-1-kevin.brodsky@arm.com> References: <20250103184415.2744423-1-kevin.brodsky@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 6AA0540002 X-Stat-Signature: 6w63xg4x4qjxxi6bqd5w1cnzrkm8jug4 X-Rspam-User: X-HE-Tag: 1735929874-506660 X-HE-Meta: U2FsdGVkX1+pOyNbPYNlm7q+RHWbUb1l+HDx9O4bVsgnflK/ffv5vVgQD0w64AYg9UOXGtVPQc9z2Egc4TNRzf1Vx/G7XejqWKNg1KTX0eSARHsz8J17IdsAVmvPlc0fj3k51d5Geu+nmlt4KBTj3kMpkSIG8J9t8s7I4A78s5zElqkcumTtMEEPcOiUc6s3qq3v28UALX7ooJ644nUt1pbN7HSvpmzzlNzELILpKeNWm5AHY+lFHfXvPpIflOdTXhs6xplLUxAC4we0GwsKzdSvDNb/gwjLdxydcH8mfPrG5RXGENotQVoOL97yTvKLmmaubQq2YRa8Poez3svSPLTKhd1cJHh1uQaTw0x2FLKdTWSvr014dgXBBTuLafyNcqYOs2ZRt4iAzRrY/jaqHKcfGKtUJNF6StKmMKJvYezHYl5MogcWlrHSkrLe2k+ByBA/OPKXQjdqEwNi69qX3Jr23bknwIneOXhwo8Qnk8cClxg7XFzWaARglFj2qwWvx3kIl7bwIJ1K12xb3QsFPRL54nnGJO4geD4N8il5jLDKi1B/imCu5Nt2+k/HROC3wlnEmmfSdOn5kUwi4YuIsltPUoaGrMKfRA2R9eKJpjK18oNMg07TPjyP06W94dhLi+nZOffvwTcvcE1EiGp3c2zZucDSNqPV6OwDe2/0RLwJyI1D69h7FuCCfwt9mgbCFivGW/0vyaA5PHdJvOyGwcgO0Vdxi0BN2YS+9NewmQUVcg916MCFXbHrO1yDu7TOp290a2VtPPKYRtqpDaKwcNBnOQfScY5LSlJ2TsEsydskD01QPdxH7iQ23yCwfU3kKTlmQ+Y6gIieVbAud3stkdrKo+YFc5MZBH2RrZRIcTAgXBVtfj3WaTA/NMGkeSjxsk6MvHR9lZ0T8zSRX7Du0YXkdPk7qoGgSA3TmZd1Rv4bI7szcQxe0SHXvuJSQXfstqzpzUPaRvw9mNGw7GQ EhggSLbK FMD5Q/Ow1NYTtHZY86ss8Vbflv+xJj58pFBu0Uo91FVwIS56jRcF8+TaRGOMIovwgGdieEdlNS3xPXX11JGovDaqxtr+BVwCUwr9mLokaHPZnYrsQKDKjKrcx3x513bHE6tvBYpjy5Ze1VF20URCMNVoSH4SB5VsX9lwumyh7sjWoPItvgeKq4VFLoHnjoy1gUaSlleHdCGA+8DSIoVjjceXM9zXrNd1JdSO0 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: pagetable_*_ctor all have the same basic implementation. Move the common part to a helper to reduce duplication. Acked-by: Dave Hansen Signed-off-by: Kevin Brodsky --- include/linux/mm.h | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 1a11f9df5c2d..065fa9449d03 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3076,6 +3076,14 @@ static inline bool ptlock_init(struct ptdesc *ptdesc) { return true; } static inline void ptlock_free(struct ptdesc *ptdesc) {} #endif /* defined(CONFIG_SPLIT_PTE_PTLOCKS) */ +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); @@ -3093,12 +3101,9 @@ static inline void pagetable_dtor_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; } @@ -3202,13 +3207,10 @@ 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); ptdesc_pmd_pts_init(ptdesc); - lruvec_stat_add_folio(folio, NR_PAGETABLE); + __pagetable_ctor(ptdesc); return true; } @@ -3233,18 +3235,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_p4d_ctor(struct ptdesc *ptdesc) { - struct folio *folio = ptdesc_folio(ptdesc); - - __folio_set_pgtable(folio); - lruvec_stat_add_folio(folio, NR_PAGETABLE); + __pagetable_ctor(ptdesc); } extern void __init pagecache_init(void);