Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1697536pxy; Thu, 29 Apr 2021 12:25:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrlNntPtrpXY28oGtxaisv+LCPeArWQfOVp+oCsdW3/xypViaknRGC6yqERDoS5L83HUvZ X-Received: by 2002:a05:6402:48c:: with SMTP id k12mr1459127edv.237.1619724311339; Thu, 29 Apr 2021 12:25:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619724311; cv=none; d=google.com; s=arc-20160816; b=fXYtixFpXaUKvultiQELXsOGFmT10a4jhSnB4DR6byZgfGYYUo00WP7CN5ejs29Jgu gilKAxAROZQp59VWFOkyKya7WQlm7fMisPT0v06Ufq3HgLDWg8fvG53uW3CuWwtOnDpm atUWsvp2Mnhrqv03fcAu8fgEjpSlrlqjQEOpcwg5EDlzdN5cDGCSbkCAY98O9V8e7jYx dzNbYWD22ghQKcs8mjfcYf22j9huG5qZCdu6tC2uBupsXZnSMHkqetaojcWOt2rHmYjI jPGQL2+h7/ECnCiUeH5C8U+MRVpSYE4HZiEOhrOmTuLhEP7Mv1rY+SOi01z94cf7kf5C 1ujw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=nrbq9B7dG+NCQxkteDtV1okkrNphDZCfGcOZNCMSQkU=; b=pR+Zcb07tVs1wooIMRg1RJBe+apwvhe+iCzoamK4elnFv7C8osnp05NOFjo7VuLcxS f/lN6barMPCtDmmvdFmsc8n5z5ZTVloEGa+7Z2GEnXdj6Sm0dIbJxUs1q+R9Gi+Posfn JqElJPeVlLvD4xP5j3MlFM3kiPKUFpwTBTqkSljsB1bsJhwTlhWvss0AAbjC/zhIwNuk +zjjTEeNhZrACML9d0pXicfNM5+Fe/1lZxR8DsezGT4/sogPYuYVr4EdLpqqi9NA1aW7 vQdJgPOEpAHSIRPzSTn/fqXzYKRDFHe5Y1kNneq5MqYQ86T+W8nake/A/K3JoeNaNx70 U3hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-14-rsa header.b=X7rNkDBM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lespinasse.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz12si927471ejb.109.2021.04.29.12.24.44; Thu, 29 Apr 2021 12:25:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-14-rsa header.b=X7rNkDBM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lespinasse.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233767AbhD2TR7 (ORCPT + 99 others); Thu, 29 Apr 2021 15:17:59 -0400 Received: from server.lespinasse.org ([63.205.204.226]:59883 "EHLO server.lespinasse.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242622AbhD2TPQ (ORCPT ); Thu, 29 Apr 2021 15:15:16 -0400 DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-14-ed; t=1619723668; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to : from; bh=nrbq9B7dG+NCQxkteDtV1okkrNphDZCfGcOZNCMSQkU=; b=2aFz00E0Y24Rhdz7Fqx5QsvnOFlMBK1oW0+IhoIU9Irj5snllxZmt2t1v5ilB6npR5/w5 gaVcVTxxmISCbNZCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-14-rsa; t=1619723668; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to : from; bh=nrbq9B7dG+NCQxkteDtV1okkrNphDZCfGcOZNCMSQkU=; b=X7rNkDBMH428Ypz2fZG/kkDKqTWsYVMzTG+fA/iXVsd6nSYsDKIT4PYIS8Cme++SNHnZh gmU0NDZXd4iTNvb7sVYdFR/ZPQYQVFdMMc75zP9tCObIoNqx/s2PATVl9JF56lzXUdlkESP 7dQphM7PjcxgdcjddepwWQMWw8RZc5/PGaGiHpARm/Un9y4uGL/3ok28vtoJJgrauQaH+1f S5YqOHXFtRfvQqg8Qou7DgyKFbBh1INSxBaiIwweReMIWHs1lYBNm++XqrDmNfxv78wcs8Z jVgi867PySjlJzDpRZPFiWMLwQoW3mT+NET6t6HBddX60PBj2FmYNtwc3PDg== Received: by server.lespinasse.org (Postfix, from userid 1000) id 3E71D160305; Thu, 29 Apr 2021 12:14:28 -0700 (PDT) Date: Thu, 29 Apr 2021 12:14:28 -0700 From: Michel Lespinasse To: Matthew Wilcox Cc: Andy Lutomirski , Michel Lespinasse , "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: <20210429191428.GD10973@lespinasse.org> References: <20210407014502.24091-1-michel@lespinasse.org> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210429161234.GG1847222@casper.infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 29, 2021 at 05:12:34PM +0100, Matthew Wilcox wrote: > On Wed, Apr 28, 2021 at 05:05:17PM -0700, Andy Lutomirski wrote: > > On Wed, Apr 28, 2021 at 5:02 PM Michel Lespinasse wrote: > > > Thanks Paul for confirming / clarifying this. BTW, it would be good to > > > add this to the rcu header files, just so people have something to > > > reference to when they depend on such behavior (like fast GUP > > > currently does). > > > > Or, even better, fast GUP could add an explicit RCU read lock. > > > > > > > > Going back to my patch. I don't need to protect against THP splitting > > > here, as I'm only handling the small page case. So when > > > MMU_GATHER_RCU_TABLE_FREE is enabled, I *think* I could get away with > > > using only an rcu read lock, instead of disabling interrupts which > > > implicitly creates the rcu read lock. I'm not sure which way to go - > > > fast GUP always disables interrupts regardless of the > > > MMU_GATHER_RCU_TABLE_FREE setting, and I think there is a case to be > > > made for following the fast GUP stes rather than trying to be smarter. > > > > How about adding some little helpers: > > > > lockless_page_walk_begin(); > > > > lockless_page_walk_end(); > > > > these turn into RCU read locks if MMU_GATHER_RCU_TABLE_FREE and into > > irqsave otherwise. And they're somewhat self-documenting. > > 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() ? > 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. -- Michel "walken" Lespinasse