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 885EDC433EF for ; Wed, 8 Dec 2021 15:52:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC76E6B0072; Wed, 8 Dec 2021 10:52:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D77736B0073; Wed, 8 Dec 2021 10:52:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C3EE96B0074; Wed, 8 Dec 2021 10:52:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay038.a.hostedemail.com [64.99.140.38]) by kanga.kvack.org (Postfix) with ESMTP id B11636B0072 for ; Wed, 8 Dec 2021 10:52:14 -0500 (EST) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8BD7021536 for ; Wed, 8 Dec 2021 15:52:04 +0000 (UTC) X-FDA: 78895068168.31.FBE4E65 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf22.hostedemail.com (Postfix) with ESMTP id 0A4A81903 for ; Wed, 8 Dec 2021 15:52:03 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id A5D5A212C0; Wed, 8 Dec 2021 15:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1638978722; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=03iT3JOIAlZ/O0MVJX1U57cSlZ33//YmQ2NpDHKCjg0=; b=cxpbasfR/L7CTP08RCsxC6XO1un52mKs02QCLJ7IXcbyaB6ugHis+2QkaYvVF/wnNXT3WW jEKQCH+n0hKSQPkMPGVgURi0TXpnlACK3DL4l3aZYCbMABJSBKT/2tmWXD0AIhRUSuHjWy RoFZK8WpFXunmf1DFWzaYHD3sjWegvU= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 3A68AA3B92; Wed, 8 Dec 2021 15:52:02 +0000 (UTC) Date: Wed, 8 Dec 2021 16:51:58 +0100 From: Michal Hocko To: Matthew Wilcox 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: rspam03 X-Rspamd-Queue-Id: 0A4A81903 X-Stat-Signature: mewdp451afxwczd76j4n5xpaue96fuku Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=cxpbasfR; spf=pass (imf22.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-HE-Tag: 1638978723-928014 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 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. -- Michal Hocko SUSE Labs