From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C1480C369D9 for ; Wed, 30 Apr 2025 14:18:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Q9sGMxkfhSmUxYY9kPs/I9g0L6OY0L2n8uvV0LMHmBQ=; b=Way922Zadqb/DSSYt8tBYHsD91 kbc73+f4BD7zJrFae6A18X/7E8eOO5RGmbAOh157KxRls4b3EiYHdUV+mzapkheVvrYcI4MMsoPIT RLCnOWpJExCVGxmLaWxF0YhxwM9JTMoJmTD3wwIGAXeZLA69j9EoHeFe5jgeZi/m4TdK/vmDloDQk +m9wZT9ZEbjmTWIWpTXxWPd9nJ21JgQGw8GvoLOABIaqSqczV6XoAsXy9PLe/y231afFiL9cuX5Vq 5x+2+Dv4J/IuIWWNWeI3gqaaO82vbpxeOq2iXwbZ5+ozAwl4xQlw5oPcOG44BNEB1sBh+C+rXioZ3 yVhb3pRg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uA8GM-0000000D5vV-295w; Wed, 30 Apr 2025 14:18:14 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uA8ER-0000000D5dR-1Qql for linux-arm-kernel@lists.infradead.org; Wed, 30 Apr 2025 14:16:16 +0000 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 035EB106F; Wed, 30 Apr 2025 07:16:07 -0700 (PDT) Received: from [10.57.84.121] (unknown [10.57.84.121]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1C5B03F673; Wed, 30 Apr 2025 07:16:09 -0700 (PDT) Message-ID: <71cb77b8-c4b8-4d63-8b59-105440527c15@arm.com> Date: Wed, 30 Apr 2025 15:16:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 3/7] mm: Add batched versions of ptep_modify_prot_start/commit Content-Language: en-GB To: Dev Jain , akpm@linux-foundation.org Cc: david@redhat.com, willy@infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, Liam.Howlett@oracle.com, lorenzo.stoakes@oracle.com, vbabka@suse.cz, jannh@google.com, anshuman.khandual@arm.com, peterx@redhat.com, joey.gouly@arm.com, ioworker0@gmail.com, baohua@kernel.org, kevin.brodsky@arm.com, quic_zhenhuah@quicinc.com, christophe.leroy@csgroup.eu, yangyicong@hisilicon.com, linux-arm-kernel@lists.infradead.org, namit@vmware.com, hughd@google.com, yang@os.amperecomputing.com, ziy@nvidia.com References: <20250429052336.18912-1-dev.jain@arm.com> <20250429052336.18912-4-dev.jain@arm.com> From: Ryan Roberts In-Reply-To: <20250429052336.18912-4-dev.jain@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250430_071615_429617_3C3618C4 X-CRM114-Status: GOOD ( 19.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 29/04/2025 06:23, Dev Jain wrote: > Batch ptep_modify_prot_start/commit in preparation for optimizing mprotect. > Architecture can override these helpers. I would suggest merging this with patch #7 since that's where they actually get used. Then you can add a single patch after that to specialize them for arm64, which will give a performance win. Thanks, Ryan > > Signed-off-by: Dev Jain > --- > include/linux/pgtable.h | 38 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 38 insertions(+) > > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > index b50447ef1c92..ed287289335f 100644 > --- a/include/linux/pgtable.h > +++ b/include/linux/pgtable.h > @@ -891,6 +891,44 @@ static inline void wrprotect_ptes(struct mm_struct *mm, unsigned long addr, > } > #endif > > +/* See the comment for ptep_modify_prot_start */ > +#ifndef modify_prot_start_ptes > +static inline pte_t modify_prot_start_ptes(struct vm_area_struct *vma, > + unsigned long addr, pte_t *ptep, unsigned int nr) > +{ > + pte_t pte, tmp_pte; > + > + pte = ptep_modify_prot_start(vma, addr, ptep); > + while (--nr) { > + ptep++; > + addr += PAGE_SIZE; > + tmp_pte = ptep_modify_prot_start(vma, addr, ptep); > + if (pte_dirty(tmp_pte)) > + pte = pte_mkdirty(pte); > + if (pte_young(tmp_pte)) > + pte = pte_mkyoung(pte); > + } > + return pte; > +} > +#endif > + > +/* See the comment for ptep_modify_prot_commit */ > +#ifndef modify_prot_commit_ptes > +static inline void modify_prot_commit_ptes(struct vm_area_struct *vma, unsigned long addr, > + pte_t *ptep, pte_t old_pte, pte_t pte, unsigned int nr) > +{ > + for (;;) { > + ptep_modify_prot_commit(vma, addr, ptep, old_pte, pte); > + if (--nr == 0) > + break; > + ptep++; > + addr += PAGE_SIZE; > + old_pte = pte_next_pfn(old_pte); > + pte = pte_next_pfn(pte); > + } > +} > +#endif > + > /* > * On some architectures hardware does not set page access bit when accessing > * memory page, it is responsibility of software setting this bit. It brings