Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp381774rdb; Thu, 15 Feb 2024 03:11:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVyW2bBLWx5PJz2HPGlC5jiEggRU+dJL5Ixh+jyj8sK+lYmy8Pen97s3tlrnapRFy1rOd50rabVqMGIrQiKPUUHnQcw70VRVvoS8QHiWg== X-Google-Smtp-Source: AGHT+IGYX6ZmGDMNDVb4fK5RHipPuKK8yfXz3/sPMbfQOVQ8MrDve5NsMocxIyT0l+eKFFxcSJmK X-Received: by 2002:a17:903:249:b0:1d7:5d88:f993 with SMTP id j9-20020a170903024900b001d75d88f993mr1447852plh.41.1707995504578; Thu, 15 Feb 2024 03:11:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707995504; cv=pass; d=google.com; s=arc-20160816; b=XqauWAiZpLBbV4970QnxKFGvLPyk6xiR7XVEiO6RUDUBym/VGG71gBCMXpm5mjkAHl jNJFakmboAS002CiC/qhmm4/ze09w8GnviR5u41NXVDU8lwhnRUXjVa89ePTrF/AlQhH LY8ZckFi0ML9jbFh1fTuNDNvJv3Gc1zdalZ/AZ+/gxTJe8o5EVR/D7wA10BPYAch4PLj V0W9Rw/kMSV3SO1vqZQ5w2FIvWHt+VnUOgf81hOvRRAxeInKQ5ngheVnAHnVOkf2hrov VaMCWylGqC8F9BfX+nQnY+km8g5w2ljum3eOe7GAFp+28YaVBoD1KEkrsLHUpk+nl0Wf ggMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=PAVJHyGMAUnF7AjViDJ+K3AaQu9PJj0R+gebBFLO5LA=; fh=Heagowc1O8zVDXTyU76nJjOwDjz9r3Gi+0zmhF4ZELQ=; b=F2o8mHslSsJq1ahA6UUZVIY9yMDguQEC1ElpA5+PQLJt3u3dsL1ZfJwXD13HDgIi/Z KbTuKb3DO2b8v3gqAiOsUqdtCh09rZxL3exhQ0u8eVbuuU5iwRPifIVB6ehV/EF4tUE8 XK6eWbS7uMFqPUU4orauMF+e/32BmxAs+Vz5oJZbkZlPTLd3ZMlGmKcmL0IIsKaFZEvY 4EHbVocH0L8Ihi9W2kZgMEZ23N4QjLhP8HQRizrM4n3loIC5JmDEOUpNfHSyu4rC/Daa /gFz+w26j3AYBBEm+KHCtFCpQ7IFpXEDzQ0b83ngRbHCpSQ32rWb5p6yWPgtqXDIWCpA 3ZCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-66655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id f3-20020a170902ce8300b001da21d3aa72si151351plg.441.2024.02.15.03.11.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 03:11:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-66655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 206E2B2CA0A for ; Thu, 15 Feb 2024 10:40:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38F66131750; Thu, 15 Feb 2024 10:33:20 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6FF6384FC0 for ; Thu, 15 Feb 2024 10:33:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707993199; cv=none; b=fRouSnQaQBuWEi1EAz0GniIXYifCbss4HCkEAqolYa5j4awccZhG6kil8TuqxlpdlH9uBT0SegX9wzGul4H4ohiVLoXASLbajEVEADBjG2Q7RpLzk1V9SYyhb2AJtpxjSul+50vZL6VOSbZFSWh8r5qJjjIKLm9DhK7YBukA0jE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707993199; c=relaxed/simple; bh=BKVaPuYqBaCIkAqRyGQu29xHpMe0/fa3OcqaDOFtyTk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VkazlLNyb6J5MgMuYGlhwSPYTA1s5KdSNlGPdYRVBKGSyAIIk4spvGECd9rMwx65eiFK1/8QLx0aow7k8YeEVH+ZpeT/BEOaIya5QdsLH5g/5rbTzOAHnLAj4GmCxNCDa+3nG3jtAcxfWf+ihl0BIvkxSjKk478a/jh9P6XmNEM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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 EBA3215DB; Thu, 15 Feb 2024 02:33:58 -0800 (PST) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E26CB3F7B4; Thu, 15 Feb 2024 02:33:14 -0800 (PST) From: Ryan Roberts To: Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , James Morse , Andrey Ryabinin , Andrew Morton , Matthew Wilcox , Mark Rutland , David Hildenbrand , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 17/18] arm64/mm: __always_inline to improve fork() perf Date: Thu, 15 Feb 2024 10:32:04 +0000 Message-Id: <20240215103205.2607016-18-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240215103205.2607016-1-ryan.roberts@arm.com> References: <20240215103205.2607016-1-ryan.roberts@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit As set_ptes() and wrprotect_ptes() become a bit more complex, the compiler may choose not to inline them. But this is critical for fork() performance. So mark the functions, along with contpte_try_unfold() which is called by them, as __always_inline. This is worth ~1% on the fork() microbenchmark with order-0 folios (the common case). Acked-by: Mark Rutland Signed-off-by: Ryan Roberts --- arch/arm64/include/asm/pgtable.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index d759a20d2929..8310875133ff 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -1206,8 +1206,8 @@ extern int contpte_ptep_set_access_flags(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t entry, int dirty); -static inline void contpte_try_unfold(struct mm_struct *mm, unsigned long addr, - pte_t *ptep, pte_t pte) +static __always_inline void contpte_try_unfold(struct mm_struct *mm, + unsigned long addr, pte_t *ptep, pte_t pte) { if (unlikely(pte_valid_cont(pte))) __contpte_try_unfold(mm, addr, ptep, pte); @@ -1278,7 +1278,7 @@ static inline void set_pte(pte_t *ptep, pte_t pte) } #define set_ptes set_ptes -static inline void set_ptes(struct mm_struct *mm, unsigned long addr, +static __always_inline void set_ptes(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte, unsigned int nr) { pte = pte_mknoncont(pte); @@ -1360,8 +1360,8 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma, } #define wrprotect_ptes wrprotect_ptes -static inline void wrprotect_ptes(struct mm_struct *mm, unsigned long addr, - pte_t *ptep, unsigned int nr) +static __always_inline void wrprotect_ptes(struct mm_struct *mm, + unsigned long addr, pte_t *ptep, unsigned int nr) { if (likely(nr == 1)) { /* -- 2.25.1