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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 169D0C433F5 for ; Wed, 8 Dec 2021 16:05:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41CDB6B0072; Wed, 8 Dec 2021 11:05:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CC3A6B0073; Wed, 8 Dec 2021 11:05:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 292EC6B0074; Wed, 8 Dec 2021 11:05:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay028.a.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 17CA86B0072 for ; Wed, 8 Dec 2021 11:05:41 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E237922CD1 for ; Wed, 8 Dec 2021 16:05:30 +0000 (UTC) X-FDA: 78895102020.11.031F4BA Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf26.hostedemail.com (Postfix) with ESMTP id D1C9B20019C4 for ; Wed, 8 Dec 2021 16:05:29 +0000 (UTC) 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=eXGrGkg5NtXQdY+5+PcWCQctwATeg/9zpNpzAdgrs5s=; b=sNEb/78ju3Vr/GEz17BRIjSBCp fMKLn1vqWX9wIcveNYbpvy4BSPQbE3OzfqZh0+pdaY+mBba8NCAPY7A888RUaGktOAvnQhIjjLphV cm1rWfpfXm8tVtmMs7rvngNHjCWreru0F/AYUV2GEnyEMp9VxAKcd7XIAopmzw5WwB5v1hK8piQU0 fTrIwxiLeTj7xg5RjRSRHAjZ7Mr9lCqIspxdNstc+D+NyEPKyMuIpVfcKXClu7Z0zLHZYtNhIt4S+ 9nZclyuXgmqiJUsNa58CA3TF6QPADq5TYrYNDDBXz/ww6vhBLfNz6JqIzjRv+pwWfHcnKl1cCRbCb umuXbO2g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1muzRR-008YzV-Ti; Wed, 08 Dec 2021 16:05:13 +0000 Date: Wed, 8 Dec 2021 16:05:13 +0000 From: Matthew Wilcox To: Michal Hocko Cc: Suren Baghdasaryan , akpm@linux-foundation.org, rientjes@google.com, hannes@cmpxchg.org, guro@fb.com, riel@surriel.com, minchan@kernel.org, kirill@shutemov.name, aarcange@redhat.com, christian@brauner.io, hch@infradead.org, oleg@redhat.com, david@redhat.com, jannh@google.com, shakeelb@google.com, luto@kernel.org, christian.brauner@ubuntu.com, fweimer@redhat.com, jengelh@inai.de, timmurray@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v3 1/2] mm: protect free_pgtables with mmap_lock write lock in exit_mmap Message-ID: References: <20211207215031.2251719-1-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D1C9B20019C4 X-Stat-Signature: dsw46td1fkwcmmgmo45aej3tzbz7kn1s Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="sNEb/78j"; spf=none (imf26.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-HE-Tag: 1638979529-443 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 Wed, Dec 08, 2021 at 04:51:58PM +0100, Michal Hocko wrote: > On Wed 08-12-21 15:01:24, Matthew Wilcox wrote: > > On Tue, Dec 07, 2021 at 03:08:19PM -0800, Suren Baghdasaryan wrote: > > > > > /** > > > > > * @close: Called when the VMA is being removed from the MM. > > > > > * Context: Caller holds mmap_lock. > > > > > > BTW, is the caller always required to hold mmap_lock for write or it > > > *might* hold it? > > > > __do_munmap() might hold it for read, thanks to: > > > > if (downgrade) > > mmap_write_downgrade(mm); > > > > Should probably say: > > > > * Context: User context. May sleep. Caller holds mmap_lock. > > > > I don't think we should burden the implementor of the vm_ops with the > > knowledge that the VM chooses to not hold the mmap_lock under certain > > circumstances when it doesn't matter whether it's holding the mmap_lock > > or not. > > If we document it like that some code might depend on that lock to be > held. I think we only want to document that the holder itself is not > allowed to take mmap sem or a depending lock. The only place where we're not currently holding the mmap_lock is at task exit, where the mmap_lock is effectively held because nobody else can modify the task's mm. Besides, Suren is changing that in this patch series anyway, so it will be always true.