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 7CEBDC433EF for ; Sat, 18 Dec 2021 05:04:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8AD06B0072; Sat, 18 Dec 2021 00:04:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E3A1F6B0073; Sat, 18 Dec 2021 00:04:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D01A36B0074; Sat, 18 Dec 2021 00:04:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0224.hostedemail.com [216.40.44.224]) by kanga.kvack.org (Postfix) with ESMTP id C04C06B0072 for ; Sat, 18 Dec 2021 00:04:18 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 7A5108CA47 for ; Sat, 18 Dec 2021 05:04:08 +0000 (UTC) X-FDA: 78929723376.26.A25FBE7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf10.hostedemail.com (Postfix) with ESMTP id E87A7C0037 for ; Sat, 18 Dec 2021 05:04:02 +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=7CfBdCGGB5KqQySfvwvT6lyY1v+XtNbClXHvrFXEOgs=; b=l/oArGjyFvrjpr8xJM2Bh5UEYA gNZtRT594LAgBAix0ykvezlOODRZeD95aySCrdyXGNrqxmCv8zV1FHSXYEl3/z8KEN9uCgGhIVcpd D2dHUyDdcA5bS9uRG0ZRbPHLD2tG/2SvHOOXEotOyWAxnnp815jRLFzz50QZub2tpxyxpsNf6GBXJ GvmES3DEGCG5bSsWyr2D02uUmcLNFnmFhnqQKAWDt3ct6BPpBp2vC+ujiuOKPjV3NNtDJyPDqhQAc Tpfwv32S7tW8OX/+XoVusNugubRU/zT+X4Wdy41LWBvmPeNkFF+djqyHB0ZQG1FfyRVLLbWLIxRPf GMP4LRpQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1myRsf-00HK7a-6n; Sat, 18 Dec 2021 05:03:37 +0000 Date: Sat, 18 Dec 2021 05:03:37 +0000 From: Matthew Wilcox To: Nadav Amit Cc: Linus Torvalds , David Hildenbrand , Linux Kernel Mailing List , Andrew Morton , Hugh Dickins , David Rientjes , Shakeel Butt , John Hubbard , Jason Gunthorpe , 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: <02cf4dcf-74e8-9cbd-ffbf-8888f18a9e8a@redhat.com> <0aa27d7d-0db6-94ee-ca16-91d19997286b@redhat.com> <0de1a3cb-8286-15bd-aec1-2b284bf8918a@redhat.com> <719D2770-97EF-4CF5-81E6-056B0B55A996@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: E87A7C0037 X-Stat-Signature: 8fqy44q8kasrzm7wefuojx39z8zjcfzp Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="l/oArGjy"; spf=none (imf10.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: 1639803842-48307 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 Sat, Dec 18, 2021 at 04:52:13AM +0000, Nadav Amit wrote: > Take for instance memcached and assume you overcommit memory with a very fast > swap (e.g., pmem, zram, perhaps even slower). Now, it turns out memcached > often accesses a page first for read and shortly after for write. I > encountered, in a similar scenario, that the page reference that > lru_cache_add() takes during the first faultin event (for read), causes a COW > on a write page-fault that happens shortly after [1]. So on memcached I > assume this would also trigger frequent unnecessary COWs. Why are we comparing page_count() against 1 and not 1 + PageLRU(page)? Having a reference from the LRU should be expected. Is it because of some race that we'd need to take the page lock to protect against?