From patchwork Wed Dec 20 22:45:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13500649 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 52E15C3DA6E for ; Wed, 20 Dec 2023 22:46:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2AE68D0026; Wed, 20 Dec 2023 17:46:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ADB058D0022; Wed, 20 Dec 2023 17:46:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 841E08D0026; Wed, 20 Dec 2023 17:46:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 69CBA8D0022 for ; Wed, 20 Dec 2023 17:46:50 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 44AFC4041D for ; Wed, 20 Dec 2023 22:46:50 +0000 (UTC) X-FDA: 81588682980.12.35FAB92 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 8D8B84000E for ; Wed, 20 Dec 2023 22:46:48 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Zpm5g6Q0; spf=pass (imf12.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703112408; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fTcpbW98US35msxaiX+BCXxL5QAKVhrGk2lkGfrSlfw=; b=26mZEhHOIoGrfe31swK1jubcp+0XIGToviQNtzLD3V3iqlMKFYJUALZqE3HmojVForwAQI YaDXrHhOd1qc8aK2s/G3Xyxniby/RIUgsPsSKv5XoLlnDFKvNKl3fY5f10FWHrGeTp9ry7 25fOzSKK40/1EZRplZ0bLMTZHhGNJyI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703112408; a=rsa-sha256; cv=none; b=hcbPzvC5oy4/RU3oYrkXjpRn+pNuW0vTF2PvmGUuYjYlRDlzAIYtSsJjKriE9kBM6/Yd/P A/giLMKdGd4fmUtOVuCqcVy7EywoRfmUbLbdmkeVQoNFyzdHcD6sx+2f4iG8U3lfZW1JH6 S0WT1UKaI8SFJrJWC7kijHBGhACLQco= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Zpm5g6Q0; spf=pass (imf12.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703112407; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fTcpbW98US35msxaiX+BCXxL5QAKVhrGk2lkGfrSlfw=; b=Zpm5g6Q09NBAYfk/y7xEWtjLQ13Z7H/pZ/npKNe5aL54NWJPfTdJa5DtQ0wDzcoICT1yI8 /uZ5XVJAnlLOKIhmgruZo3oLWAaZgihTldbMVBPCmF84fOVX6FPOciSzISQABQr1JqvgaH J8I+turVCO0bhI3blCwko9nzUZ6HIR4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-612-7CmBAUaHOZWiWfdpU_xHgA-1; Wed, 20 Dec 2023 17:46:42 -0500 X-MC-Unique: 7CmBAUaHOZWiWfdpU_xHgA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 034AF85A58B; Wed, 20 Dec 2023 22:46:42 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F08C40C6EB9; Wed, 20 Dec 2023 22:46:39 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , "Matthew Wilcox (Oracle)" , Hugh Dickins , Ryan Roberts , Yin Fengwei , Mike Kravetz , Muchun Song , Peter Xu Subject: [PATCH v2 36/40] mm/memory: page_try_dup_anon_rmap() -> folio_try_dup_anon_rmap_pte() Date: Wed, 20 Dec 2023 23:45:00 +0100 Message-ID: <20231220224504.646757-37-david@redhat.com> In-Reply-To: <20231220224504.646757-1-david@redhat.com> References: <20231220224504.646757-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Rspamd-Queue-Id: 8D8B84000E X-Rspam-User: X-Stat-Signature: trwup7rr95gznjigfcj9pzk5j5f15z6t X-Rspamd-Server: rspam03 X-HE-Tag: 1703112408-630035 X-HE-Meta: U2FsdGVkX1/Jhw8liwNhmeW/Qyihi4bn7NVUtTl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mP1kafNe4D0riouAR94x1GFn4W4vjwEeteFOlomk9wKHw+IEJF7dLX2qmixgQNllqVr9WGr+1GKvQq4RcOA== 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: List-Subscribe: List-Unsubscribe: Let's convert copy_nonpresent_pte(). While at it, perform some more folio conversion. Signed-off-by: David Hildenbrand --- mm/memory.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index dc2a8e6858179..d995ead7a3933 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -785,6 +785,7 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, unsigned long vm_flags = dst_vma->vm_flags; pte_t orig_pte = ptep_get(src_pte); pte_t pte = orig_pte; + struct folio *folio; struct page *page; swp_entry_t entry = pte_to_swp_entry(orig_pte); @@ -829,6 +830,7 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, } } else if (is_device_private_entry(entry)) { page = pfn_swap_entry_to_page(entry); + folio = page_folio(page); /* * Update rss count even for unaddressable pages, as @@ -839,10 +841,10 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, * for unaddressable pages, at some point. But for now * keep things as they are. */ - get_page(page); + folio_get(folio); rss[mm_counter(page)]++; /* Cannot fail as these pages cannot get pinned. */ - BUG_ON(page_try_dup_anon_rmap(page, false, src_vma)); + folio_try_dup_anon_rmap_pte(folio, page, src_vma); /* * We do not preserve soft-dirty information, because so @@ -956,7 +958,7 @@ copy_present_pte(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, * future. */ folio_get(folio); - if (unlikely(page_try_dup_anon_rmap(page, false, src_vma))) { + if (unlikely(folio_try_dup_anon_rmap_pte(folio, page, src_vma))) { /* Page may be pinned, we have to copy. */ folio_put(folio); return copy_present_page(dst_vma, src_vma, dst_pte, src_pte,