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=-7.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 3D397C433B4 for ; Thu, 29 Apr 2021 23:56:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A4599613B3 for ; Thu, 29 Apr 2021 23:56:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4599613B3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=lespinasse.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 34B3A6B006C; Thu, 29 Apr 2021 19:56:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 322866B006E; Thu, 29 Apr 2021 19:56:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1EAFB6B0070; Thu, 29 Apr 2021 19:56:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0073.hostedemail.com [216.40.44.73]) by kanga.kvack.org (Postfix) with ESMTP id 04FDE6B006C for ; Thu, 29 Apr 2021 19:56:35 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2896E181AF5C2 for ; Thu, 29 Apr 2021 23:56:34 +0000 (UTC) X-FDA: 78087066708.06.A5A8B27 Received: from server.lespinasse.org (server.lespinasse.org [63.205.204.226]) by imf10.hostedemail.com (Postfix) with ESMTP id 78F9040002E6 for ; Thu, 29 Apr 2021 23:56:22 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-14-ed; t=1619740591; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to : from; bh=DHof6otQeyq3kPdCHUB3Te2GYUAs+CCH3DH/j9hxypY=; b=gs7x6dJ8vx6PTqvvqdwyHRMG/pO6+U0GhwzIR0Fn4QvNHBX48vgCkUdvF8GSPoehHrH5+ Z2dV3Y/OVFm+lAuAw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-14-rsa; t=1619740591; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to : from; bh=DHof6otQeyq3kPdCHUB3Te2GYUAs+CCH3DH/j9hxypY=; b=mXotcxjzULnIIDf3BYVw2kgfwHN2xHsAzbN/7NwWDrQbqLEY5OlVf7uE083PyzV4kBZZu dLygHm4w03H4sAIkeO7Q5vlDa+Rk+baQDdXOSLRDXHJd555UfFJ9o3XJBvXB7zDhbqSXZ2Y ZEAsKHtONfdO0BUOkEEx/EDV9Ib/vUmn2cuEHVXQvTmbnkCfGGtMvBlvtM41T90eB9Y6Dyv VMDSzx9GnnmPHUm/e8SBrVxDipiQL/2jM23HKI1Keh5EaVxWy3CPAr0IoMXm4YGdZ1Tc77c Wy9kNUMlrx0Kl23crZMUS99Iitm+xFqOKKpqw+299l5FMpbpkDlu1oP8LihA== Received: by server.lespinasse.org (Postfix, from userid 1000) id E69DA160309; Thu, 29 Apr 2021 16:56:31 -0700 (PDT) Date: Thu, 29 Apr 2021 16:56:31 -0700 From: Michel Lespinasse To: Matthew Wilcox Cc: Michel Lespinasse , Andy Lutomirski , "Paul E. McKenney" , Linux-MM , Laurent Dufour , Peter Zijlstra , Michal Hocko , Rik van Riel , Andrew Morton , Suren Baghdasaryan , Joel Fernandes , Rom Lemarchand , Linux-Kernel Subject: Re: [RFC PATCH 13/37] mm: implement speculative handling in __handle_mm_fault(). Message-ID: <20210429235631.GG10973@lespinasse.org> References: <20210407014502.24091-14-michel@lespinasse.org> <20210428145823.GA856@lespinasse.org> <20210428161108.GP975577@paulmck-ThinkPad-P17-Gen-1> <20210429000225.GC10973@lespinasse.org> <20210429161234.GG1847222@casper.infradead.org> <20210429191428.GD10973@lespinasse.org> <20210429193456.GI1847222@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210429193456.GI1847222@casper.infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 78F9040002E6 X-Stat-Signature: qgi5oj4e9oxkurqtktgt1yauwe8w9sq9 Received-SPF: none (lespinasse.org>: No applicable sender policy available) receiver=imf10; identity=mailfrom; envelope-from=""; helo=server.lespinasse.org; client-ip=63.205.204.226 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619740582-382530 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 Thu, Apr 29, 2021 at 08:34:56PM +0100, Matthew Wilcox wrote: > On Thu, Apr 29, 2021 at 12:14:28PM -0700, Michel Lespinasse wrote: > > On Thu, Apr 29, 2021 at 05:12:34PM +0100, Matthew Wilcox wrote: > > > One of the worst things we can do while holding a spinlock is take a > > > cache miss because we then delay for several thousand cycles to wait for > > > the cache line. That gives every other CPU a really long opportunity > > > to slam into the spinlock and things go downhill fast at that point. > > > We've even seen patches to do things like read A, take lock L, then read > > > A to avoid the cache miss while holding the lock. > > > > I understand the effect your are describing, but I do not see how it > > applies here - what cacheline are we likely to miss on when using > > local_irq_disable() that we wouldn't touch if using rcu_read_lock() ? > > It's the same cache lines in both cases. The difference is that in one > case we have interrupts disabled (and a spinlock held? i wasn't clear > on that) and in the other case, we just have preemption disabled. To add some context - the problem we are trying to solve here (and a different instance of it in the next commit) is that we are trying to map and/or lock the page table, but need to prevent it from being freed while we are trying to do so. Disabling interrupts or taking an rcu read lock are two mechanisms for preventing that race, but the structures accessed are the same in either case. > > > What sort of performance effect would it have to free page tables > > > under RCU for all architectures? It's painful on s390 & powerpc because > > > different tables share the same struct page, but I have to believe that's > > > a solvable problem. > > > > I agree using RCU to free page tables would be a good thing to try. > > I am afraid of adding that to this patchset though, as it seems > > somewhate unrelated and adds risk. IMO we are most likely to find > > justification for pushing this if/when we try accessing remote mm's without > > taking the mmap lock, since disabling IPIs clearly wouldn't work there. > > I think that needs to happen _before_ this patchset. Creating a mess and > then trying to clean it up later isn't a great way to do development. Agree we don't want to create a mess... but I see that as an argument for not hastily changing the way page tables are reclaimed... -- Michel "walken" Lespinasse