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 67882C433E0 for ; Wed, 20 May 2020 01:26:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 35413207C4 for ; Wed, 20 May 2020 01:26:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589937981; bh=6AZyfxeStk9BMps7zFSgzaqvLw2zumjttdsiUTuiNgA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=h64Ibam8lFmhNln4dt3ePKd/2GM7a7A9aRB6sFdyH1D6XLZ1pmGYk9X8ZeMtWhz3s lGJgVWGtsgnbm55qKr2ll8HdUj81jKbY7InXdhFAxD4+EF0Ar7iSuPJ7GYE7R+28Qv UsgKGjO9crJ4D1txO2uGkJq+19O7+gweWnLM+RBw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726595AbgETB0V (ORCPT ); Tue, 19 May 2020 21:26:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:36922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726348AbgETB0U (ORCPT ); Tue, 19 May 2020 21:26:20 -0400 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 8FE0220756; Wed, 20 May 2020 01:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589937980; bh=6AZyfxeStk9BMps7zFSgzaqvLw2zumjttdsiUTuiNgA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=lF50fRFZsZz5wrn3GA/OeEY8bbfIUAnbQyNmLNbxrFG6roWJNjnlhClJqc3yRCYzu aBJXOWiExX3Hiv9Lzymb5Ce57FdtfFoIiZSXhl2hKmLs1TuYEgptgZ2iLpTTOFzhWm JbuegdY50rdNUA/VlY5RaoJ1srHk3yVjtI2NOkEE= Date: Tue, 19 May 2020 18:26:19 -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, David Hildenbrand Subject: Re: [PATCH v4 2/4] mm/memory.c: Update local TLB if PTE entry exists Message-Id: <20200519182619.2c5e76d3f6b25d71702abbe0@linux-foundation.org> In-Reply-To: <1589882610-7291-2-git-send-email-maobibo@loongson.cn> References: <1589882610-7291-1-git-send-email-maobibo@loongson.cn> <1589882610-7291-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 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org On Tue, 19 May 2020 18:03:28 +0800 Bibo Mao wrote: > If two threads concurrently fault at the same address, the thread that > won the race updates the PTE and its local TLB. For now, the other > thread gives up, simply does nothing, and continues. > > It could happen that this second thread triggers another fault, whereby > it only updates its local TLB while handling the fault. Instead of > triggering another fault, let's directly update the local TLB of the > second thread. > > It is only useful to architectures where software can update TLB, it may > bring out some negative effect if update_mmu_cache is used for other > purpose also. It seldom happens where multiple threads access the same > page at the same time, so the negative effect is limited on other arches. I'm still worried about the impact on other architectures. The additional update_mmu_cache() calls won't occur only when multiple threads are racing against the same page, I think? For example, insert_pfn() will do this when making a read-only page a writable one. Would you have time to add some instrumentation into update_mmu_cache() (maybe a tracepoint) and see what effect this change has upon the frequency at which update_mmu_cache() is called for a selection of workloads? And add this info to the changelog to set minds at ease?