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 6673FC433EF for ; Tue, 12 Apr 2022 09:26:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0AE476B0078; Tue, 12 Apr 2022 05:26:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 05EB16B007B; Tue, 12 Apr 2022 05:26:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E688A6B007D; Tue, 12 Apr 2022 05:26:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0147.hostedemail.com [216.40.44.147]) by kanga.kvack.org (Postfix) with ESMTP id D5E976B0078 for ; Tue, 12 Apr 2022 05:26:47 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 83F129F331 for ; Tue, 12 Apr 2022 09:26:47 +0000 (UTC) X-FDA: 79347697254.26.5C96418 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf06.hostedemail.com (Postfix) with ESMTP id BE05E18001D for ; Tue, 12 Apr 2022 09:26:46 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 45B7E21607; Tue, 12 Apr 2022 09:26:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1649755605; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/z3vs/uGK6fYvmeCC8WIfRK8ClbBQCivi/ZueGKwhRg=; b=CCrJGkWfhf6K63aXfS7Jy9M27QPYITldqJDk62cMjm8rShXsPSTfaSbMCd89qcKLPcq/WD ijjxP4UWux1A00vzr3NrHXBek0Dub9htK3YCODbp8WDaJCmMRNlYmiYGeZZJUt5ZdkOoJB VYM1Xtr6rDcVf9p3AJC95woI4H5RGdI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1649755605; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/z3vs/uGK6fYvmeCC8WIfRK8ClbBQCivi/ZueGKwhRg=; b=XP+jAGBAXo0qytAx75Y2ByiVQmQcc1SGvd5uN+dQj41CUHsxIj501pYwWjDQ1UfpwsF853 7m3Es8sJkdcXLOAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CE71513A99; Tue, 12 Apr 2022 09:26:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id XXqKMdRFVWKDLAAAMHmgww (envelope-from ); Tue, 12 Apr 2022 09:26:44 +0000 Message-ID: <7225391a-5798-94ae-7a01-9a9dd344e13a@suse.cz> Date: Tue, 12 Apr 2022 11:26:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: en-US To: David Hildenbrand , linux-kernel@vger.kernel.org Cc: Andrew Morton , Hugh Dickins , Linus Torvalds , David Rientjes , Shakeel Butt , John Hubbard , Jason Gunthorpe , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Matthew Wilcox , Jann Horn , Michal Hocko , Nadav Amit , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Jan Kara , Liang Zhang , Pedro Gomes , Oded Gabbay , linux-mm@kvack.org References: <20220329160440.193848-1-david@redhat.com> <20220329160440.193848-10-david@redhat.com> From: Vlastimil Babka Subject: Re: [PATCH v3 09/16] mm/rmap: use page_move_anon_rmap() when reusing a mapped PageAnon() page exclusively In-Reply-To: <20220329160440.193848-10-david@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: BE05E18001D X-Stat-Signature: ywag887yk7uft4593s71uyzg4ar3kz7a X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=CCrJGkWf; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=XP+jAGBA; dmarc=none; spf=pass (imf06.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-HE-Tag: 1649755606-779542 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 3/29/22 18:04, David Hildenbrand wrote: > We want to mark anonymous pages exclusive, and when using > page_move_anon_rmap() we know that we are the exclusive user, as > properly documented. This is a preparation for marking anonymous pages > exclusive in page_move_anon_rmap(). > > In both instances, we're holding page lock and are sure that we're the > exclusive owner (page_count() == 1). hugetlb already properly uses > page_move_anon_rmap() in the write fault handler. Yeah, note that do_wp_page() used to call page_move_anon_rmap() always since the latter was introduced, until commit 09854ba94c6a ("mm: do_wp_page() simplification"). Probably not intended. > Note that in case of a PTE-mapped THP, we'll only end up calling this > function if the whole THP is only referenced by the single PTE mapping > a single subpage (page_count() == 1); consequently, it's fine to modify > the compound page mapping inside page_move_anon_rmap(). > > Signed-off-by: David Hildenbrand Acked-by: Vlastimil Babka > --- > mm/huge_memory.c | 2 ++ > mm/memory.c | 1 + > 2 files changed, 3 insertions(+) > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index c4526343565a..dd16819c5edc 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -1317,6 +1317,8 @@ vm_fault_t do_huge_pmd_wp_page(struct vm_fault *vmf) > try_to_free_swap(page); > if (page_count(page) == 1) { > pmd_t entry; > + > + page_move_anon_rmap(page, vma); > entry = pmd_mkyoung(orig_pmd); > entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma); > if (pmdp_set_access_flags(vma, haddr, vmf->pmd, entry, 1)) > diff --git a/mm/memory.c b/mm/memory.c > index 03e29c9614e0..4303c0fdcf17 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -3303,6 +3303,7 @@ static vm_fault_t do_wp_page(struct vm_fault *vmf) > * and the page is locked, it's dark out, and we're wearing > * sunglasses. Hit it. > */ > + page_move_anon_rmap(page, vma); > unlock_page(page); > wp_page_reuse(vmf); > return VM_FAULT_WRITE;