Received: by 10.213.65.68 with SMTP id h4csp848401imn; Thu, 22 Mar 2018 09:52:38 -0700 (PDT) X-Google-Smtp-Source: AG47ELsJLef9gNchjuwk9R1luNLjiHx7LiBSCwD+R1Z9/+ifNL3oxo8ShVspqR6YvA9XAuZmthwh X-Received: by 2002:a17:902:9045:: with SMTP id w5-v6mr26485356plz.104.1521737558690; Thu, 22 Mar 2018 09:52:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521737558; cv=none; d=google.com; s=arc-20160816; b=GjKjmWijhzosTqR+br2oxLdD7toTQEQh2Vj1IhuyVLtdllOmwLG5dqyC0Gr1WnLaKL nOacd4nBolY/nJOdHjhITfsSr4ZA3WUijdM1nuAkb7tZ00TapDtWoTy8Ft2b2ecnIRUW b+c5Y3Hlr5zlrXe/zIWQYnCbLC3n3VVKzC3kCjtlYLYhuXHKMxkizMDO8epfJqBDfLkM Jmt4iraHto3MFuDLoZ5kT5JkPN+Ptv2Nn3JX4pN9Ph11pPiWY8D4sow0yVii1ylzGjZy dFsl55yt28jfovLQ8PkXe3+yMqCTq7nBJl+zwiFPQ1KHm/06LPjJDWjS2J5dpSTWXtVC 9vnQ== 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:arc-authentication-results; bh=/jj9SEMDWULmX0N3vGUn/oHpoYaIXVnaLfBPgnOkGMI=; b=UhqNS9QVI8/ApCKlKZoEXLmykNv1PePv84ghfoiD94t+q+ourC1v1Jxo2XerW3UTg4 yUheWcrpf7n3e7zgoN9JUiMPYmlJo6tATYyktzPBIX99987CioAuoz3NCFwGDO8s0ogZ 0oC53hNufNMzkXp+kVPZ0MBcGBwhTVH10XM31trXy8AIqctPhYcn/l00aLg3JouPkZpn D8p4SrlmU0traGSCWWE41KFJOugpEi2Bks1VRaOxX8TierHdvP0aZhd2VJN38az+g+SJ HSI73Cne1WgM6jBF1YfVJuX/sEAHCeXc5HPyuskWeAxk/boxmLCFhK5+p0FUZnkEKyPy jE7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=VKPMvZoy; 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 e193si2079433pgc.785.2018.03.22.09.52.23; Thu, 22 Mar 2018 09:52:38 -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=bombadil.20170209 header.b=VKPMvZoy; 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 S1751894AbeCVQvK (ORCPT + 99 others); Thu, 22 Mar 2018 12:51:10 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:37668 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751628AbeCVQvG (ORCPT ); Thu, 22 Mar 2018 12:51:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=/jj9SEMDWULmX0N3vGUn/oHpoYaIXVnaLfBPgnOkGMI=; b=VKPMvZoyd200ly6hwQP1DaGqo dQwPlzcD/CzzhgYA/M7OupKgU1HPOeWM1+Rp1yAbX3nscm6eHfrBrbNko9SakaEAOZzGyOb5rMLFa LcpOb4qlSEr3iksHCLCdMWNToOuFqDxAE1FN8Pup+SMUiu/+W0EznsWXGJGtNHr0JBqP9DpI46jZi folI6fAYFHVO1g9wS6t9j3UCnhF3HzXfVvQ23reozkHnuqjLJHA2Y3g8vDed3hckAErq3X5vzfZic B7if9oSXROsHy0fXljd6BIBqTjWPaBu5X9ZuOkWg00Dw5Ls40zqS5KQ8XEx11RWlqtA4koo7kjApC 4l+3CoFMA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1ez3Qd-0006n3-Am; Thu, 22 Mar 2018 16:51:03 +0000 Date: Thu, 22 Mar 2018 09:51:03 -0700 From: Matthew Wilcox To: Laurent Dufour Cc: Yang Shi , Michal Hocko , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 1/8] mm: mmap: unmap large mapping by section Message-ID: <20180322165102.GF28468@bombadil.infradead.org> References: <20180321130833.GM23100@dhcp22.suse.cz> <20180321172932.GE4780@bombadil.infradead.org> <20180321224631.GB3969@bombadil.infradead.org> <18a727fd-f006-9fae-d9ca-74b9004f0a8b@linux.vnet.ibm.com> <20180322154055.GB28468@bombadil.infradead.org> <0442fb0e-3da3-3f23-ce4d-0f6cbc3eac9a@linux.vnet.ibm.com> <20180322160547.GC28468@bombadil.infradead.org> <55ac947f-fd77-3754-ebfe-30d458c54403@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55ac947f-fd77-3754-ebfe-30d458c54403@linux.vnet.ibm.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 22, 2018 at 05:18:55PM +0100, Laurent Dufour wrote: > > It's *really* rare to page-fault on a VMA which is in the middle of > > being replaced. Why are you trying to optimise it? > > I was not trying to optimize it, but to not wait in the page fault handler. > This could become tricky in the case the VMA is removed once mmap(MAP_FIXED) is > done and before the waiting page fault got woken up. This means that the > removed VMA structure will have to remain until all the waiters are woken up > which implies ref_count or similar. Yes, that's why we don't want an actual rwsem. What I had in mind was a struct completion on the stack of the caller of munmap(), and a pointer to it from the vma. The page fault handler grabs the VMA tree lock, walks the VMA tree and finds a VMA. If the VMA is marked as locked, it waits for the completion. Upon wakeup *it does not look at the VMA*, instead it restarts the page fault.