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 60C79C433EF for ; Sun, 19 Dec 2021 22:03:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CBDED6B0071; Sun, 19 Dec 2021 17:02:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C6B206B0073; Sun, 19 Dec 2021 17:02:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B32D36B0074; Sun, 19 Dec 2021 17:02:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0195.hostedemail.com [216.40.44.195]) by kanga.kvack.org (Postfix) with ESMTP id A44AC6B0071 for ; Sun, 19 Dec 2021 17:02:43 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 6B84D8249980 for ; Sun, 19 Dec 2021 22:02:27 +0000 (UTC) X-FDA: 78935918334.29.A375C60 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id 0B4E680049 for ; Sun, 19 Dec 2021 22:02:26 +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=ik7CaEEGpXRuQZR++uVqSeU17yFR4TjXp+S6ZiNh9rg=; b=az+/fZN5Ak/kbQo+9I5FXY8TPy EEJRR5S7BVufkP1mfPhtDSNGSqLr2ZEviQuohFwoOg6UM3YcEMkuWwP2FJR3nvR1Odmg2rftJqhgl 9LYCodt4Rm3ZbuX0A0n0iN6asY0sEY7mxrzqB3U4RSB8Wpm7xZl1RE/FgPnMbOLvmB3AkEZIk8pss LCDPPSjNEf8EVmlvojXs+Udpopt0vieHfI4oCKJ/ayr2TOScFkepZ+vOlOh1YpVX9ZjpQbpTo8wIa EXnAzIZQlFrL/8Xw7EX3Me2vGZgLjBEAM/gkwHupiutdFzvNkHp/ZmNIUJX3jk2rnjGQr908Rtxtr Lyzw4W4Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mz4Fm-0014AH-18; Sun, 19 Dec 2021 22:02:02 +0000 Date: Sun, 19 Dec 2021 22:02:01 +0000 From: Matthew Wilcox To: Linus Torvalds Cc: David Hildenbrand , Nadav Amit , Jason Gunthorpe , Linux Kernel Mailing List , Andrew Morton , Hugh Dickins , David Rientjes , Shakeel Butt , John Hubbard , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Vlastimil Babka , Jann Horn , Michal Hocko , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Jan Kara , Linux-MM , "open list:KERNEL SELFTEST FRAMEWORK" , "open list:DOCUMENTATION" Subject: Re: [PATCH v1 06/11] mm: support GUP-triggered unsharing via FAULT_FLAG_UNSHARE (!hugetlb) Message-ID: References: <4D97206A-3B32-4818-9980-8F24BC57E289@vmware.com> <5A7D771C-FF95-465E-95F6-CD249FE28381@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="az+/fZN5"; spf=none (imf30.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-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0B4E680049 X-Stat-Signature: csg7adkobimpiq4w5tk436hdgo3rkgpu X-HE-Tag: 1639951346-826046 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 Sun, Dec 19, 2021 at 01:53:36PM -0800, Linus Torvalds wrote: > On Sun, Dec 19, 2021 at 1:48 PM Matthew Wilcox wrote: > > > > Yes, agreed, I was thinking that we could use "not mapped at all" > > as an optimisation to avoid doing rmap walks. eg __unmap_and_move(). > > So the thing is, it's a very dodgy optimization for a rather simple > reason: what if somebody pages the page in? > > So even "not mapped at all" is questionable. > > You have to check that it's also not a swapcache page, and hold the > page lock for that check, at the very least. > > And by then, you're really in a very unusual situation - and my gut > feel says not one worth optimizing for (because anon pages are > _usually_ mapped at least once). I'd like to get rid of ->mapcount for file pages too. And those are definitely never mapped in the majority of cases.