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 X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A368C433E0 for ; Fri, 15 May 2020 20:40:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 936E62070A for ; Fri, 15 May 2020 20:40:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="yYiOrVlB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 936E62070A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0705A8E0003; Fri, 15 May 2020 16:40:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 020AF8E0001; Fri, 15 May 2020 16:40:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E78318E0003; Fri, 15 May 2020 16:40:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id CDE508E0001 for ; Fri, 15 May 2020 16:40:48 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 85294180AD807 for ; Fri, 15 May 2020 20:40:48 +0000 (UTC) X-FDA: 76820122176.06.bikes85_241b2beadef3a X-HE-Tag: bikes85_241b2beadef3a X-Filterd-Recvd-Size: 3683 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 May 2020 20:40:47 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 90FD92065C; Fri, 15 May 2020 20:40:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589575247; bh=7/Rpg+KXflBLuZsnLoyMnGo3Y9ufgp8qwJuPpO7BwaA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=yYiOrVlBnM3aO59WMqUm3FSSQzFJGNL3VqcYNpP/dJzArRZ14W3EckZ3tyQpIm3P+ MrBsYFDV0RlVmYXRJ5hqynPd8nRvqZpfj1XibvEeXHaFByurO0jEiypqW5nKXCJHlS 5FbAPrnmkaWnlNtI5oAHxBPHONNGNE0HtTdo43GQ= Date: Fri, 15 May 2020 13:40:46 -0700 From: Andrew Morton To: Bibo Mao Cc: Thomas Bogendoerfer , Jiaxun Yang , Huacai Chen , Paul Burton , Dmitry Korotin , Philippe =?ISO-8859-1?Q?Mathieu-Daud=E9?= , Stafford Horne , Steven Price , Anshuman Khandual , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport , Sergei Shtylyov , "Maciej W. Rozycki" , linux-mm@kvack.org Subject: Re: [PATCH 2/3] mm/memory.c: Update local TLB if PTE entry exists Message-Id: <20200515134046.cf107c6a13b9604c46ad71b8@linux-foundation.org> In-Reply-To: <1589515809-32422-2-git-send-email-maobibo@loongson.cn> References: <1589515809-32422-1-git-send-email-maobibo@loongson.cn> <1589515809-32422-2-git-send-email-maobibo@loongson.cn> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: On Fri, 15 May 2020 12:10:08 +0800 Bibo Mao wrote: > If there are two threads hitting page fault at the same page, > one thread updates PTE entry and local TLB, the other can > update local tlb also, rather than give up and do page fault > again. > > ... > > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -1770,8 +1770,8 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr, > } > entry = pte_mkyoung(*pte); > entry = maybe_mkwrite(pte_mkdirty(entry), vma); > - if (ptep_set_access_flags(vma, addr, pte, entry, 1)) > - update_mmu_cache(vma, addr, pte); > + ptep_set_access_flags(vma, addr, pte, entry, 1); > + update_mmu_cache(vma, addr, pte); Presumably these changes mean that other architectures will run update_mmu_cache() more frequently than they used to. How much more frequently, and what will be the impact of this change? (Please fully explain all this in the changelog). > } > goto out_unlock; > } > > ... > > @@ -2463,7 +2462,8 @@ static inline bool cow_user_page(struct page *dst, struct page *src, > vmf->pte = pte_offset_map_lock(mm, vmf->pmd, addr, &vmf->ptl); > locked = true; > if (!likely(pte_same(*vmf->pte, vmf->orig_pte))) { > - /* The PTE changed under us. Retry page fault. */ > + /* The PTE changed under us, update local tlb */ > + pdate_mmu_cache(vma, addr, vmf->pte); Missing a 'u' there. Which tells me this patch isn't the one which you tested! > ret = false; > goto pte_unlock; > } > > ... >