From patchwork Mon Dec 4 14:21:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13478535 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 728DDC4167B for ; Mon, 4 Dec 2023 14:23:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A1386B02D2; Mon, 4 Dec 2023 09:23:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 028356B02D3; Mon, 4 Dec 2023 09:23:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE5326B02D4; Mon, 4 Dec 2023 09:23:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C988C6B02D2 for ; Mon, 4 Dec 2023 09:23:01 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A87A7802AA for ; Mon, 4 Dec 2023 14:23:01 +0000 (UTC) X-FDA: 81529352562.08.E64F839 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf02.hostedemail.com (Postfix) with ESMTP id AA3DC80017 for ; Mon, 4 Dec 2023 14:22:59 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cYJIXjrH; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.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=1701699779; 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=QtlsU4Oj5pegnlPsv+IBcEoRKm4An7qodS6gdDA58Hg=; b=IrTmm9hTseVRgc2B/TguCorU2Edy1SPfLKEDBMksAuUnBRul9gj8ADVJYCiBdjPjaYLoR1 20XpAtHVFrW7eumKXhYQ1eVRddTHY/14A4ApzlVnmBhxO4UzhboRfAOp5Ur2JSswMj1gtx W9sCq7+LenhzMM1yE9OJR4MnPRIw8kY= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cYJIXjrH; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.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=1701699779; a=rsa-sha256; cv=none; b=xOLMXb2/Fv9GD7Ax2/cP3nuCIUSA8ldefQJbaSg9egr2Kr2wUAL9I4sOdKemxObvc6gWO9 PvJV810THB81DPlSUd7OMcNkeEkpGUGvx3Rqj6r0ZKNqWm2qCJj1BM/Hvng8arG4ReknSe +2FPBMuAy5idx9Icghw1b2AUnHBmgTk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701699779; 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=QtlsU4Oj5pegnlPsv+IBcEoRKm4An7qodS6gdDA58Hg=; b=cYJIXjrHSW88QPY+VPCYkDv3yAVyyv/HZGn3gWiR+XXJyfc8tOwoUES9YlsWzZEGtIY7mp XvN/g00743Uomd5q+rWiLOAeXkyE+tPMvpBYRkbUWT6wboP5G8h4ubYTYEH8z4bNzNj3g0 smyVAEhycuY19q5d8sD1vmVPzhgheAw= 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-451-GtUO8C-8PWedYvC2iAxb4A-1; Mon, 04 Dec 2023 09:22:55 -0500 X-MC-Unique: GtUO8C-8PWedYvC2iAxb4A-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 483868314FC; Mon, 4 Dec 2023 14:22:55 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.195.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6440D2026D4C; Mon, 4 Dec 2023 14:22:53 +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 35/39] mm/huge_memory: page_try_dup_anon_rmap() -> folio_try_dup_anon_rmap_pmd() Date: Mon, 4 Dec 2023 15:21:42 +0100 Message-ID: <20231204142146.91437-36-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: AA3DC80017 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: d56j3nuqdgrshg18ibrxqq4rdkpr9k9w X-HE-Tag: 1701699779-831233 X-HE-Meta: U2FsdGVkX19QM+dCd+nriEl2/o4YIcejreW9v01KHB3XEZ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nsq3wAyd4uvRzHxcCL0CxKi97VjlkPK6whsHu+y8RWGBkqscXuvAcJNXS1I4/+u9g0BdibA43PmJ/Brg== 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 9376c28b0ad29..138e1e62790be 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1098,6 +1098,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; @@ -1164,11 +1165,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); @@ -1277,8 +1279,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));