From patchwork Wed Dec 20 22:44:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13500647 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 784BEC3DA6E for ; Wed, 20 Dec 2023 22:46:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C49A8D0024; Wed, 20 Dec 2023 17:46:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FC5C8D0022; Wed, 20 Dec 2023 17:46:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 273F08D0024; Wed, 20 Dec 2023 17:46:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0ECA18D0022 for ; Wed, 20 Dec 2023 17:46:44 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D53A01203E6 for ; Wed, 20 Dec 2023 22:46:43 +0000 (UTC) X-FDA: 81588682686.24.4033812 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 1B7C340005 for ; Wed, 20 Dec 2023 22:46:41 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=J+NmOtc0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.hostedemail.com: domain of david@redhat.com designates 170.10.129.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=1703112402; 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=eh/NeqNby3APEgZIeJ5Gbh/kC7oqyH0NpFSKRwTjdSA=; b=6nqqOusTb1YEghqZ5xQhItveom+J4gQ3gtTlIju42up3RvUPFZCRc13EjxqSG4FVhSFiEu Y3yTV5VfP2kge2V3d17Fr+UkBbsPZxJgsw1TAwMsg3MrMa3+fHZynJtOzOuk/VTZWZam8S fdf98KY5oiMpiPe3U2TjaDZxeRploJE= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=J+NmOtc0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703112402; a=rsa-sha256; cv=none; b=u/U1R1kuneMATZy68yNVjlLSAklBRqKAcifGZ4ee9F2V5fVXgzJESoUynvNZRMIKQkrbIx dTq+FdrZIQOOBNdE2K3ypjXnSnz2H5wPF6jILlQlAhbUzPWXFH52rcmF8iXWKkXCvtofNX HM8a5cYQTRGKMDCcq+zV8T1aDbDjjO4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703112401; 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=eh/NeqNby3APEgZIeJ5Gbh/kC7oqyH0NpFSKRwTjdSA=; b=J+NmOtc0go66rDawAPBVajmuJYaoHFHbn0iuM15iVcEClZFhazgnHmRy8x20ozKH92wWIu VT4H5iQHFkipNLTL5wXAKQW4O6gcJ4AJu+fdnpwaXhYya2Yfx8H94zdfwtBXULViAHOdbM PsHe/kQGushF7lhX0FaaAyjkcortwc0= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-313-ZfLMWBpIMNiX3NN0QdVaEA-1; Wed, 20 Dec 2023 17:46:40 -0500 X-MC-Unique: ZfLMWBpIMNiX3NN0QdVaEA-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 538C13C23FCD; Wed, 20 Dec 2023 22:46:39 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1209840C6EBC; Wed, 20 Dec 2023 22:46:36 +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 35/40] mm/huge_memory: page_try_dup_anon_rmap() -> folio_try_dup_anon_rmap_pmd() Date: Wed, 20 Dec 2023 23:44:59 +0100 Message-ID: <20231220224504.646757-36-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-Rspam-User: X-Stat-Signature: wqbbanfh7mubbn8zuwsyih3yx3rjxqn4 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1B7C340005 X-HE-Tag: 1703112401-703393 X-HE-Meta: U2FsdGVkX18GbF8r2/Xo76LELMkp3sUsT0z22RsBmIrK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4rkD/aGwujHwk2kGvRtfiwDsENQ56QGqggXRkMnF22cVzp7b0X1iy1hrC1lHJNO6VjdlZaR80lIvFA== 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_huge_pmd() and fixup the comment in copy_huge_pud(). While at it, perform more folio conversion in copy_huge_pmd(). Signed-off-by: David Hildenbrand --- mm/huge_memory.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index e7bc0f38ddc53..edbca08449357 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1275,6 +1275,7 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, { spinlock_t *dst_ptl, *src_ptl; struct page *src_page; + struct folio *src_folio; pmd_t pmd; pgtable_t pgtable = NULL; int ret = -ENOMEM; @@ -1341,11 +1342,12 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, src_page = pmd_page(pmd); VM_BUG_ON_PAGE(!PageHead(src_page), src_page); + src_folio = page_folio(src_page); - get_page(src_page); - if (unlikely(page_try_dup_anon_rmap(src_page, true, src_vma))) { + folio_get(src_folio); + if (unlikely(folio_try_dup_anon_rmap_pmd(src_folio, src_page, src_vma))) { /* Page maybe pinned: split and retry the fault on PTEs. */ - put_page(src_page); + folio_put(src_folio); pte_free(dst_mm, pgtable); spin_unlock(src_ptl); spin_unlock(dst_ptl); @@ -1454,8 +1456,8 @@ int copy_huge_pud(struct mm_struct *dst_mm, struct mm_struct *src_mm, } /* - * TODO: once we support anonymous pages, use page_try_dup_anon_rmap() - * and split if duplicating fails. + * TODO: once we support anonymous pages, use + * folio_try_dup_anon_rmap_*() and split if duplicating fails. */ pudp_set_wrprotect(src_mm, addr, src_pud); pud = pud_mkold(pud_wrprotect(pud));