Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1549236pxy; Thu, 29 Apr 2021 09:15:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjRS3XDGIcdPqRxWJ9TXAjcItcBC/Svj8OxbdYjYfhuSj95kbi6x9WVCQRyaMRbKagZurz X-Received: by 2002:a63:e60a:: with SMTP id g10mr444873pgh.21.1619712911521; Thu, 29 Apr 2021 09:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619712911; cv=none; d=google.com; s=arc-20160816; b=hzK5m4SbAHS8FTZaFD5u+7UZR6/Fo+FCRWWCSekDLXFnU2kw3k0RmDXiAxlSNMcy21 ndzRFgkk0lT2Df/0fvKhLVozvxrfx6UIGCzRHTV7+WDcYQFm1KIuv6dfj4u3bBqA9CEZ tu64R3YfRRS+9LbkBxcjXEtH9GWm5ZwXhvcaMCC+R/84WnAGi5eLk6QE3/e4QUAklaks VdU4Z6lAKCxlC8qqOAOHWRCfsO6LiZ681rVBbynh4yUnegKJks7wvST+mDhxMbpVTvCh GGnKPqo3xbGW0xLEGg43kPwJVit8ZHEbFwp3JdL4j9yzcCPcRzawlJ7XVhUCLfg5KY9/ 21dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Sjto5L9W4yTchVWVxZGdizaY2No4aG7xse7lrOyysJY=; b=QlZo05/jJHKeRdbJKqwTrkTbwMnRvOEe9eyTKLr+w2fHRgbk3cpBms0pq5vXF7oU/N RPluNc/tuYdPUIem/r2wrwGS7Q6AVuaD9Z3AtooXezaM1oKKUSTDDNLogsh/XTloQ758 famPfnvh3it5nBk6IW2GMVczVdVO64mA+bvZE4JwBYbVHX0a/LHqs3E0put17p3VrAUu XIMhO3jJH5CPHAMAgkY1iLcstimJ1oQ7gNH3tTiTdVFFA8M+7J4L0S9vyfWKRnmU4f1A M3TrN/3lRy03FYJIMEfo12N9/qbeEdTnWIDou9/W67grtJyhRUXyRT7xty5RvS+JmX01 mQ1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="jL/C6pnO"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s2si374621pgo.250.2021.04.29.09.14.55; Thu, 29 Apr 2021 09:15: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=pass header.i=@infradead.org header.s=casper.20170209 header.b="jL/C6pnO"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237185AbhD2QOV (ORCPT + 99 others); Thu, 29 Apr 2021 12:14:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232004AbhD2QOT (ORCPT ); Thu, 29 Apr 2021 12:14:19 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAFD4C06138B for ; Thu, 29 Apr 2021 09:13:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Sjto5L9W4yTchVWVxZGdizaY2No4aG7xse7lrOyysJY=; b=jL/C6pnOsdbzk8QyLzkCXWeXYD GSITLuCJOJ72BcwJZdAMuzODezh95gYleNadR9An2m1nGxNhZKLgTlAaOMIUuvDdhrEL0qVQppor+ ZQNFVC70kXIxlcPeBr0NEbgtXxurs9pa4T0LTXqMkmJijuxLYQTbOAr15qoRrIV5qZq9MMgnK4JzO nfuv8HSClIPdLsJPbOXNZnrM/4M1hKJENxJytlFLC2Rpav7gudeGbZ5oR/rCi8j9fvUpjfqSx5Si4 dRhWYmBo9nQjJiXBTYI0JPzuDZCSvD0m6/zolk/uDYaBsu8CcTPROIombfLJpeIVw3SfnWOP0fyTZ W50CZaCw==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lc9HG-009rBw-O6; Thu, 29 Apr 2021 16:12:39 +0000 Date: Thu, 29 Apr 2021 17:12:34 +0100 From: Matthew Wilcox To: Andy Lutomirski Cc: 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: <20210429161234.GG1847222@casper.infradead.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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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.