Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp44502rdh; Tue, 13 Feb 2024 08:56:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV2Zeei/5B8muZMkm3koEqJgQ1ZeNDkISWaGSORa8+VHP3hP5TAnAd2s2aEP1/Herf/7lMY4Jeil8CCte8+yyEnD/CPmr/g88ycag6R2g== X-Google-Smtp-Source: AGHT+IHWg06+wLCXOHbe9UVras2rJdYwIDgTqOiAj5jrZ8p6QMOCy/AyvQGcndQpVcAFf9S3yQx4 X-Received: by 2002:a17:906:ad9:b0:a3c:a56a:faf3 with SMTP id z25-20020a1709060ad900b00a3ca56afaf3mr3978738ejf.67.1707843363855; Tue, 13 Feb 2024 08:56:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707843363; cv=pass; d=google.com; s=arc-20160816; b=MoIuPEgv5HY+anMVH25B99oU8y2RazKFXLWHahvlAjiSz4Tc24rNOLH3FsQEfQCPb7 BDBUYxAEbHdEZatqPaXZTqni5as/8fbqFkpQLiL1491yn+wWlgqadkqc6LhBzfNll07B PkWYEug3aOYRp3qPdwTy/952A1ZV4+7pN9ZkzsQToCtNsznbj2FTUzqAzbBjYucwJH5u KudcOu5jRqt7V7a4niQ43/01/mn3Cnt6Cc8DAXUPq1qNzR4TBmPrVMcbTKUmowSNSz3c hYiYYdvSd8OPSJ34paxNjLQ92J34xszJe7mjw/vWnD0b7Y8UerpG7GeZB4qEC5xnFUQl KqpQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=pKy9PTkFCzw9Fg7LIOJJ205iugMhHVEDB4xfQm61ZR8=; fh=yXvEkbWwWc1w7J/TfDz4dGzrtCO6H9UZVtWbzzDQ4po=; b=Em+zeV3z1F6b1Z4j6TJx2sw3ewOMHNcqSRRWk6+cVukXymH0YzmVBBRR4R/FOZNoVI BCgvJ+Pzvjqcxb5skfn2+yEUQmBgmnCmqwtro6ZCr9cUS30QlAV2f+muyjJ/M2K7tI2P 2BZaoYwqZ5iDIq70EeV+OAZzoybXPFALnxVVaWd0w8nlm7n2V/Jl9hD+dtcOIuCqjcRO hA1KpBb1jUI0akkANx4js3pgR/tlAFWmfZury9a+mFrl2d08P5wOuuziWPz+u3gKqLvk OLSJRf4dUGY30EEnkGiBYZPHUZ2tVAwJwAvgYt67Oh2LRR2H+ewe13a1FjJnNTnAZ0xT pZTQ==; 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-63948-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63948-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCVOe8PrJ6KTCumPY+p1EZFwGi773iLj9ImppXT5+nMsqjQYiiXKt/dqL8bqnhXMHUM9lzXTTnw/qhb2VxHzvPKeCvYsC4KrLLunv1V3bg== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id rn18-20020a170906d93200b00a3d2b261366si96721ejb.664.2024.02.13.08.56.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 08:56:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63948-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-63948-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63948-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9900F1F2836E for ; Tue, 13 Feb 2024 16:56:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8CD6C5F866; Tue, 13 Feb 2024 16:55:57 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A14D3BA57 for ; Tue, 13 Feb 2024 16:55:55 +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=1707843357; cv=none; b=Av1rJ5afkFUtQeQsCyCdqohcB36+ioiQsccHkFk8b3+fZ07CJ3lw5ctLDnVfCfxiErQm+9XURXbEksaHqDvBPFBlcL6zzqouZkMqD1nvDkemv/aHleh+BLLcKwOFetjuwolkwwOmQEYF9r5/Xki+FIOQKCI3G68IwbHkrcllG2c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707843357; c=relaxed/simple; bh=OlqJ2fXyLvszO74uYT8l1d7byfWBYIMFbndu+5mdxmg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mZIt3W1cboX1OlqYsezSfeUTH4/jKHjLnbVNR4oOONKrmwxF4vgCIlLYYGWOGzgyfohjed5eopL0wXihmQAPOBldnRoE+y6kSv6wxFGgjoxHufTFn00DZl62W0Lo7qscacwBJ+emBMcVLI9nslW3b7aLFSnDt4xi3tGxPrVrwQo= 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 6FC74DA7; Tue, 13 Feb 2024 08:56:36 -0800 (PST) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.36.130]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6CD3D3F5A1; Tue, 13 Feb 2024 08:55:51 -0800 (PST) Date: Tue, 13 Feb 2024 16:55:49 +0000 From: Mark Rutland To: Ryan Roberts Cc: Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , James Morse , Andrey Ryabinin , Andrew Morton , Matthew Wilcox , 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" , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 24/25] arm64/mm: __always_inline to improve fork() perf Message-ID: References: <20240202080756.1453939-1-ryan.roberts@arm.com> <20240202080756.1453939-25-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240202080756.1453939-25-ryan.roberts@arm.com> On Fri, Feb 02, 2024 at 08:07:55AM +0000, Ryan Roberts wrote: > 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 I have no strong feelings either way on this, so: Acked-by: Mark Rutland Mark. > --- > 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 >