Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3366171yba; Tue, 23 Apr 2019 02:30:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPMkcJePWUiErRaYcVdOYz/1laOu3ChLVP8Ui2KlyHgZyVmLtz6l00QiRl6wz2U5qHcQyX X-Received: by 2002:aa7:9813:: with SMTP id e19mr2872904pfl.159.1556011837348; Tue, 23 Apr 2019 02:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556011837; cv=none; d=google.com; s=arc-20160816; b=HTuAsADHvKdzvjleXwUfVnezX9HyPf3/Kxp9p6RZ+uboJwYg+5BrpdCRdsGEGmmIdA f+HfSBjfN67iCAeN4NdArRQHwKoLGjhSVIiGykd4Y+VRND+EoMHNmnn4eflEcaMSsx42 5U8XycIuVhdTa4DhsuqnIfH5JPfXqXqjWai5G0d03CrOqjxwCfYX4PvlkMgg8ioCVVkw Jqnj3Zbcrtad1wW/ChUIBbWU9/ykM+PFdaBcFgIimyjGHJoIuGP3aeAL4UvRIAdRYHVG bbTgrHOrFGp60eoX5iVWvkIFknG+Bqpp72qe/H5KmJ8Rome/3b8UUcuRFy+NdnI/luoY TJFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=f/iLXaVA4u+TazdBjYinG9bUUB+MWLz5zrXVIQCfKNM=; b=eRyk9bUs0ruk+p4bwk+EfHJusgUVgwtHupjAWsmVqbbXxPeD24cWWXbzluomdy16iU 6L/fDw7d+1vmfHUQX2uldaAuXWl0Zoje/1rplFf4bHL7p0laDDn8050IqNRn6/9qsxc4 9ynAp1kExKRUWg8xiOYfYUz1LzhVSPPPrVASiUeWdZ49aWGJ6auVvyt+oqbGS+cHTXCJ cqm8AAmMKjbUAR2/Btj+vI8syXEr7aP5TfxDoTcwrXsr75n/pxLQjfHN1PbilMphk/LH jvjOgpX5BsuJOpLaquO8KutIE1Vx5M2X8YtaU3oTzD7VW3wlN/uEpWTjbSwxjnOBdGQQ fCIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="nj/UAzBo"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7si7237256plt.83.2019.04.23.02.30.22; Tue, 23 Apr 2019 02:30:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="nj/UAzBo"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726818AbfDWJ2N (ORCPT + 99 others); Tue, 23 Apr 2019 05:28:13 -0400 Received: from merlin.infradead.org ([205.233.59.134]:46956 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725916AbfDWJ2N (ORCPT ); Tue, 23 Apr 2019 05:28:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=f/iLXaVA4u+TazdBjYinG9bUUB+MWLz5zrXVIQCfKNM=; b=nj/UAzBo31hclTqz5KOaLs3kN 9+Wb0SdOYy0J9KD+QyJt7yQ9LGkIckSf3t6Viqscs1prUQ4Nt0h+LzExLOrhIw4owyz+uu7FAHuG3 C71Ebgg/MAqlvq9jb6UjD/kM1r8gJIbubPgfyoRFrQF2yz+qPrZJsT/XWTY7IlvtHtNy8J3fwaByD EwipeXzyx6RcPe7VVCz2UCcTO/i/sdll1PXi3cBGsw3ByxE0j39YXUg26M35ZBMoWBEL2hNXhm/vB E+Vg6nFM30vsFHp2cPMVfjZedrFAK5S3nGHSEHY4WDip3zj+r68oY4/UkvjhHmLcExsJDw0t9dw27 scs2myCjQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hIrho-0001lo-VN; Tue, 23 Apr 2019 09:27:13 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id E48FE29B47DCE; Tue, 23 Apr 2019 11:27:10 +0200 (CEST) Date: Tue, 23 Apr 2019 11:27:10 +0200 From: Peter Zijlstra To: Laurent Dufour Cc: akpm@linux-foundation.org, mhocko@kernel.org, kirill@shutemov.name, ak@linux.intel.com, dave@stgolabs.net, jack@suse.cz, Matthew Wilcox , aneesh.kumar@linux.ibm.com, benh@kernel.crashing.org, mpe@ellerman.id.au, paulus@samba.org, Thomas Gleixner , Ingo Molnar , hpa@zytor.com, Will Deacon , Sergey Senozhatsky , sergey.senozhatsky.work@gmail.com, Andrea Arcangeli , Alexei Starovoitov , kemi.wang@intel.com, Daniel Jordan , David Rientjes , Jerome Glisse , Ganesh Mahendran , Minchan Kim , Punit Agrawal , vinayak menon , Yang Shi , zhong jiang , Haiyan Song , Balbir Singh , sj38.park@gmail.com, Michel Lespinasse , Mike Rapoport , linux-kernel@vger.kernel.org, linux-mm@kvack.org, haren@linux.vnet.ibm.com, npiggin@gmail.com, paulmck@linux.vnet.ibm.com, Tim Chen , linuxppc-dev@lists.ozlabs.org, x86@kernel.org Subject: Re: [PATCH v12 21/31] mm: Introduce find_vma_rcu() Message-ID: <20190423092710.GI11158@hirez.programming.kicks-ass.net> References: <20190416134522.17540-1-ldufour@linux.ibm.com> <20190416134522.17540-22-ldufour@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190416134522.17540-22-ldufour@linux.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 16, 2019 at 03:45:12PM +0200, Laurent Dufour wrote: > This allows to search for a VMA structure without holding the mmap_sem. > > The search is repeated while the mm seqlock is changing and until we found > a valid VMA. > > While under the RCU protection, a reference is taken on the VMA, so the > caller must call put_vma() once it not more need the VMA structure. > > At the time a VMA is inserted in the MM RB tree, in vma_rb_insert(), a > reference is taken to the VMA by calling get_vma(). > > When removing a VMA from the MM RB tree, the VMA is not release immediately > but at the end of the RCU grace period through vm_rcu_put(). This ensures > that the VMA remains allocated until the end the RCU grace period. > > Since the vm_file pointer, if valid, is released in put_vma(), there is no > guarantee that the file pointer will be valid on the returned VMA. What I'm missing here, and in the previous patch introducing the refcount (also see refcount_t), is _why_ we need the refcount thing at all. My original plan was to use SRCU, which at the time was not complete enough so I abused/hacked preemptible RCU, but that is no longer the case, SRCU has all the required bits and pieces. Also; the initial motivation was prefaulting large VMAs and the contention on mmap was killing things; but similarly, the contention on the refcount (I did try that) killed things just the same. So I'm really sad to see the refcount return; and without any apparent justification.