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 22F2AC00A5A for ; Wed, 18 Jan 2023 02:45:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 704E26B0071; Tue, 17 Jan 2023 21:45:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B5286B0072; Tue, 17 Jan 2023 21:45:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A3FA6B0074; Tue, 17 Jan 2023 21:45:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 426DC6B0071 for ; Tue, 17 Jan 2023 21:45:23 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1706B4068F for ; Wed, 18 Jan 2023 02:45:23 +0000 (UTC) X-FDA: 80366378526.28.BEFD0C8 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf17.hostedemail.com (Postfix) with ESMTP id 280C940003 for ; Wed, 18 Jan 2023 02:45:19 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=LgtkpNzs; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674009921; a=rsa-sha256; cv=none; b=xD5oJ1Eib2faT6HjtLv73kPKw1ggUej6TngLHy1O7u2NGXk5OEHjIRq2BrddCI1s3JdMBh sDX29r6c/tpzFi0POBqtJdy+kNdNk6m/c6GAAMH5RO1KQrD0+uQ8c0PNNC5FHah2WpZyNg UnLWiY+z8F2ipEx88M9khhfvdyI3stI= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=LgtkpNzs; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674009921; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MGpdnLSCsy4iJTcYeMqTf0hkShjXgJaZl556rybxYcc=; b=55jKHvi64RneT13CdhP+9HRJ0EMXBb1WJsRSoN+BXpyK5c2L61pl8io7nQquixfpeJP0DK xedd5fsF3wSEzMmTXZyrPcfXW5daVg5qbBUfog7KxZouttsSU4KJRwTcSaMLprseEtkR91 RV9oye+muUIIMdKwGf9k6iJFoLMhWkE= 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=MGpdnLSCsy4iJTcYeMqTf0hkShjXgJaZl556rybxYcc=; b=LgtkpNzsFyaJdmFoM4zFTvjFAt Ao0YdH63TZt9RuzJ6Jp2atj9NKcViphPYwdS+B9R56VTZ6LdgTBITlFfMh6TzB/XcRGNXjsOOtgu6 aIPuxzOdZSS0yVjg747/T0PwNU+0/508fiqbDMy2yO/t7mf0IfznrHag7q8RjS5XJVA4VMfqYuwl0 ulHk6RyXVZHBP8284w9PmU5Ys9jP5MaL1tYqADfmpXKvKQXHiR+iAXVdGRcYnzrfwH8PupJzp9apk +hGZy6biK6xGQhULog6BkfaGpEdf2xnt5Y/7Oy5OU1xCO7Ns1R6g+Y5KfUc2AdfpOCbogT6bTwOeC bnYjNyHg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHyRY-00AHX7-0B; Wed, 18 Jan 2023 02:44:52 +0000 Date: Wed, 18 Jan 2023 02:44:51 +0000 From: Matthew Wilcox To: Suren Baghdasaryan Cc: Michal Hocko , akpm@linux-foundation.org, michel@lespinasse.org, jglisse@google.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, dave@stgolabs.net, liam.howlett@oracle.com, peterz@infradead.org, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, paulmck@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, punit.agrawal@bytedance.com, lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, hughlynch@google.com, leewalsh@google.com, posk@google.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH 28/41] mm: introduce lock_vma_under_rcu to be used from arch-specific code Message-ID: References: <20230109205336.3665937-1-surenb@google.com> <20230109205336.3665937-29-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Queue-Id: 280C940003 X-Rspamd-Server: rspam01 X-Stat-Signature: ubpcbfwwo3cja1bbj911w4441bt36x81 X-HE-Tag: 1674009919-882818 X-HE-Meta: U2FsdGVkX1+aQp/urm+Br8DB4MJLVjr7XGMJ63X4o+4Xm9SYL1wlZeHwbZWrtrQf9VHmnsjK8V2S/fvMvAQC7MwlYZO3q+Aq0fMzPdgVvyzLPc+hEs63jvSb3BvSCykHnIXULW4BbffFCHmYTg9MHj4dkQsiXUcaF1+9UI/K4pZcES43DUcRI4rXAJjLwx7tl66hvD5SBuwV4Sbt8faa9TckoLRtKKiWAnsVgyyWPan5OVGiWWajrCM/xTw9/a81jPwh0cUhiXR3DmbA4+P6v+NC6eUGfX7GcXOXnyx6ur3nTMNuobbs6tqUdvxhNzgcNLYdcqgFq5yRNOLfs6MPGbn3FSonL5yNjOV8IXf1UhIw2glZPKLpamgiMQqs31538Ndaq55YL6EKWJ4Bt8zuVpe5V1DjUwfBuuUNl5LCsla40aUzNxyCt0dOV8R4yJEribyjcoYdm/QnW96eeX1tzt5XNLQEkTTBY28grrpGTogCwyAkkU1L9sfG+Fd01qxdATTVxWNIgWu6Kw89Tuiqz6CskmVl1xpEJGmhAgRkUzUbGy9urYt8Pw92KfBQAoL2mc7J6QJWYeBWRTZi0Nsyt4gWKv4Xzb/IbRcFlSoHgd2yDBOCKVOw1cV80amwioIA+gA25Tne46bx1fm8OizY6Hy6BPauW/quqWZWOZnoTokGsMF2HrPCoWJv7f5hzTYqQB7w6WkrkPqh5VEPTpRQluBU8Vc4PoRoJh+o1+KuHTRLSOOfRVxNOEsLekrNQGM4EW7vMJ3/heJhWhowuy0tekc2hOZI7/IQu5J0qtNbfskkwBOacP5yOPkv0fcuaIqWsxe6Xm5zjhna2RQFSmdHaekw7pIVPQBcCEIl9FP5fjU/mAyUDmkTCCcL16/WV0KsgHLB4TpFx5dadCP8yCXl7w== 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 Tue, Jan 17, 2023 at 05:06:57PM -0800, Suren Baghdasaryan wrote: > On Tue, Jan 17, 2023 at 7:47 AM Michal Hocko wrote: > > > > On Mon 09-01-23 12:53:23, Suren Baghdasaryan wrote: > > > Introduce lock_vma_under_rcu function to lookup and lock a VMA during > > > page fault handling. When VMA is not found, can't be locked or changes > > > after being locked, the function returns NULL. The lookup is performed > > > under RCU protection to prevent the found VMA from being destroyed before > > > the VMA lock is acquired. VMA lock statistics are updated according to > > > the results. > > > For now only anonymous VMAs can be searched this way. In other cases the > > > function returns NULL. > > > > Could you describe why only anonymous vmas are handled at this stage and > > what (roughly) has to be done to support other vmas? lock_vma_under_rcu > > doesn't seem to have any anonymous vma specific requirements AFAICS. > > TBH I haven't spent too much time looking into file-backed page faults > yet but a couple of tasks I can think of are: > - Ensure that all vma->vm_ops->fault() handlers do not rely on > mmap_lock being read-locked; I think this way lies madness. There are just too many device drivers that implement ->fault. My plan is to call the ->map_pages() method under RCU without even read-locking the VMA. If that doesn't satisfy the fault, then drop all the way back to taking the mmap_sem for read before calling into ->fault.