From patchwork Mon Dec 4 14:21:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13478537 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 A3507C4167B for ; Mon, 4 Dec 2023 14:23:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C85B6B02D4; Mon, 4 Dec 2023 09:23:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 92C236B02D5; Mon, 4 Dec 2023 09:23:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A1BF6B02D6; Mon, 4 Dec 2023 09:23:05 -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 67B366B02D4 for ; Mon, 4 Dec 2023 09:23:05 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3984F16027C for ; Mon, 4 Dec 2023 14:23:05 +0000 (UTC) X-FDA: 81529352730.27.A4B93DD Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 8A22214000C for ; Mon, 4 Dec 2023 14:23:03 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EONB3l3o; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701699783; 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=eN0JAnAR2NtaQAP/A7ZBLwE/xmH/RpNbwyJWy6g296A=; b=K99/wGpRE4zT6tI/rAgKSqmZCVOGQWaBsc5G6RyUNFeljX5k64A/ROTE8yjI1AJudEKsL0 18lXEwJ1ISP6oMmW4P0x6oo+QFGBXc0H1YXqzl6PQFtIeNJ2BzNanZagWXj8c0+rk/4dXl AODIfDvwsrbVTLKvMjWWq8U12jyGgkk= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EONB3l3o; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701699783; a=rsa-sha256; cv=none; b=qNOpLAaWoOspHzndNWyKHonA9OVLojfU+ld/OVj/oRYVHyYaJUzECnyOHEfblqs16LHkpg /vOzwHsf02na/EzzRHm0Ty+q6Kx2d2DePtF8No63Eoz9ZzHqLLmEF3cq4TtRxa3yz5yqtq sdhA499KvLoWM74PA5TJHgba0Ven1Dw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701699782; 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=eN0JAnAR2NtaQAP/A7ZBLwE/xmH/RpNbwyJWy6g296A=; b=EONB3l3ojxov4Ve3dgw7ma24nawN1SGb46mepEH/CdviEWJr7ixqypo1uFjfj7fx1sjLim PZqfecHzlD/ly68F/8EPNFazlaWZ0IZCc5k5MYpD/J9nLrl0Wg7QUusOD4a4taRRnwwE+T spSYrzsmQ9/WVy7k5vuE04yjyS6wroc= 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-340-G29icLgwOhGGlLJZvf5FDw-1; Mon, 04 Dec 2023 09:22:58 -0500 X-MC-Unique: G29icLgwOhGGlLJZvf5FDw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 2DD81101AA6F; Mon, 4 Dec 2023 14:22:57 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.195.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EE922026D4C; Mon, 4 Dec 2023 14:22:55 +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 RFC 36/39] mm/memory: page_try_dup_anon_rmap() -> folio_try_dup_anon_rmap_pte() Date: Mon, 4 Dec 2023 15:21:43 +0100 Message-ID: <20231204142146.91437-37-david@redhat.com> In-Reply-To: <20231204142146.91437-1-david@redhat.com> References: <20231204142146.91437-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Rspamd-Queue-Id: 8A22214000C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: za8wj56fqfepk4xxcpjfq1xxd5zk8d1f X-HE-Tag: 1701699783-527154 X-HE-Meta: U2FsdGVkX1+qA8ikfdJV/42iCtA7jckfx+8VTxfXEmIM4qOa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4xxriFfgDu9653vk/40ix6WxB7Xj9znK57ZspUa8eEqb5ShaPAd+r2ZU+gkqrfX6djgffSPOXS7A== 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 eaab6a2e14eba..ad6da8168e461 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -781,6 +781,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); @@ -825,6 +826,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 @@ -835,10 +837,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 @@ -952,7 +954,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,