Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp687993rdb; Fri, 2 Feb 2024 00:16:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMq91vw2heXtJwt8cfT+0fFx7Rq/wA8MGhP0sxWGjbFeTynO4VGPdjgCQ7lCkA93Jrc9pN X-Received: by 2002:a0c:f210:0:b0:68c:8429:1a2c with SMTP id h16-20020a0cf210000000b0068c84291a2cmr1211711qvk.3.1706861782169; Fri, 02 Feb 2024 00:16:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706861782; cv=pass; d=google.com; s=arc-20160816; b=a7mwJCj4yq5MjJB0MU46CWaRg1QnGZEla8pfy4H8kAZ5VbZxUs+K4w8WvzxKT4qCPa ZiVYmtMf7qR9Jts/omKmqDGt1RmpyBm1af/Qm1EUSAtSrc3vfahLBFm/7Q1XcSkaw75g fW8AiqLgmIL66RzuQDGpFEE1StZ702E0XhEzKXtLvxRmbXW+uCAYI58hC1e51uCF5vD+ VYlHeB/e+cmBIaI+o56jYA81VbLAaiH92qpxxPUkfgL3Bg8HHiW+PQBOVqfxzPEsXr7t 1jCiQ23MSVY+bKLshpnDm/gVmkmgnXwOD98LPM3XVXfCzH1kGxzaSt2Bz2L9bfaT8jot YO5Q== 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=yy+Swr2xbZSqDvn3ENPl3Nu9FCFS8f4PKsB1GCbCKzA=; fh=Cb2drRDEfKbirVcZtZIlkPySEj8oiBlxzboy0GQHUkA=; b=feNyN8uBNzvQc2Waw0oirIYkMwjg16EsB/sGLlMr/lcLJU+00vmlsu1vQaDv/ILlHx pQ7/1Cf3ftxFAnsoX3t7f/3Y7kfr/6by7mRZeSA5z7Q1H4PcspQh/AE7sfv3tU04C4Bn aP5+qsT1P/2sVx5ScVYh6To2Cp2IImWxarxKUTFynwn68GI0mEa4vDveUap2AJMqoy6w d1pW2h9WuZnfOV4IS+Q9dpJRN3fXushjTqrH9VVVAgVLQntidlVYFe7CIIpjgOGAl+j+ bGgaQIKfc2cMXZud2FF7vUICt4yLNLkFPFs76XaA6ektxDrms0eL82kbY1qvj6XupQi3 M7tQ==; 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-49437-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49437-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=1; AJvYcCXXbeFXacAaCWg4J18VHZEuLRFtKBXxkO/36lMxxAoNYVXINBaecG9szXkCtm6Ywj/xrI6rEvAfqy5LW+9UumSx4H7XwUqBJueJe8so+g== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i12-20020ad44bac000000b0068c469b28f0si1438292qvw.479.2024.02.02.00.16.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:16:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49437-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-49437-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49437-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A06821C2A0D3 for ; Fri, 2 Feb 2024 08:15:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB6FE51034; Fri, 2 Feb 2024 08:09:50 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 717EE50A8F for ; Fri, 2 Feb 2024 08:09:48 +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=1706861390; cv=none; b=iQ40t7IUBaIx3+P+8vkjIJTPtG11b2qwVI4YPN5ypyDnK8cWI0rIKda4ldysH/DJWf8Wn0zJ94dp5PCCsfTK75AOto1Q9BqIC43GhhYZ0YwAmMCEJ24xL0JFlsbUxcPdDdFER5ltz34SB0S79hAMXlipYsWIiWXPwCqtJjrglxI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706861390; c=relaxed/simple; bh=ExbEqfvzT1fzU5mx7AphI5+/hTRoouLXcKYYJ84Z8nk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kPZ3lxuJ9WR64mI48xcvP6EX+aXTt1+EQc8YWdsdVTDznQOhh2NTGkaRxcWWI98wpI/LM2qVQies9z5h2pOn0Nf9ez0pbqphy7AHISmbU4ubRXkdqDoOger/g+i6T0mnEXS4KSdAQrhuWDI+FfW64NgzUqVRBn/igzT367x1i3I= 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 599431BF7; Fri, 2 Feb 2024 00:10:30 -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 6D8E53F5A1; Fri, 2 Feb 2024 00:09:44 -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 , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , 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 v5 24/25] arm64/mm: __always_inline to improve fork() perf Date: Fri, 2 Feb 2024 08:07:55 +0000 Message-Id: <20240202080756.1453939-25-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240202080756.1453939-1-ryan.roberts@arm.com> References: <20240202080756.1453939-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). 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 353ea67b5d75..cdc310880a3b 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -1213,8 +1213,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); @@ -1279,7 +1279,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); @@ -1361,8 +1361,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