Received: by 2002:a05:7412:a9a8:b0:f9:92ae:e617 with SMTP id o40csp33118rdh; Wed, 20 Dec 2023 15:07:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGan9ENpqtBErvInYT7M0HYADtVdlA1ekcj6ysjJh9yDz03jf+hwCUlaT5llYpwXScMg9eF X-Received: by 2002:a05:6e02:2145:b0:35f:b286:99bd with SMTP id d5-20020a056e02214500b0035fb28699bdmr6853993ilv.30.1703113670128; Wed, 20 Dec 2023 15:07:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703113670; cv=none; d=google.com; s=arc-20160816; b=bjwLB9DIn9KPrsQ8f6Gt2KaEfK4YjHQGahBx+ha6vx0g3TMC3ohMAtOPIXXBoY3K9K Gx/zCAFlr6DwDLCCwKOGyK2DUftEYjI5u/hWpluibctnZ1f1vONynKe27sTZTPOVX+IZ aJYFouXxiPxJpzDqivbNOMvsKkPIY0b7SNHgOOvAx2uuFAiyeVfYPuFUoH+1i3dszBMW 2nFlRENZbl0xwYHN6EzrDuq6vw9TSkH/BFj/2OxB9++EkpJWDWXuLZ1LaoKCtOVMqPvu 4Sy/87xwfpdBKLzrF6O4mto9WtQAikYGkB50k+iG1oPtNPqidE7qZbNM9pZIlGN961VI lajA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=eh/NeqNby3APEgZIeJ5Gbh/kC7oqyH0NpFSKRwTjdSA=; fh=UlFXU+hKOMcm6idRzNfe3Pu+B5L1f7aeir3C6i/NWQA=; b=jR2fP050SkdbMENXQxEZGTLzyAc80V3r1qNOXKSWyN2JA5MJG/L16ZAXgzCRbBSzsi 41OwAcDX7a+4fKduYYxPOMQMY13Wyl8ncm5hHWQxqX1sTcxGVDUMXRxAvvp3jjyqKWq7 ExarujGyHEg1WPmTQB+Od30HyzgCygNCXNJyUp7cj8OSarHN5wfiPV/Kr2RgFF6BDm7L Emwtc+osPc0gyiRIycz2slZDonNqsgryahHlGK8XikUjmzyIx5CQe50mRefsDUxkqg3Z 7zye701ifN5K4iCfgDsy1qd24SOwg3Q7ZFjOl4m8hUgcl59jVtXPzQIbDYqcAN0XRmAA HLwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X1EgXdOy; spf=pass (google.com: domain of linux-kernel+bounces-7602-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m19-20020a637113000000b0056a36ac322fsi459348pgc.514.2023.12.20.15.07.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 15:07:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7602-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X1EgXdOy; spf=pass (google.com: domain of linux-kernel+bounces-7602-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C243F2832B4 for ; Wed, 20 Dec 2023 23:07:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 223455CD1E; Wed, 20 Dec 2023 22:46:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="X1EgXdOy" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1204879466 for ; Wed, 20 Dec 2023 22:46:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703112404; 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=X1EgXdOyFPsmvtIfea/CPW5Zz2voWuHtSd54QeBrrX+MYP9B/gTL9HZqGJRuYSBrpbHKsQ cQaQo08h6zF2SSlrRw7I6Bo9PvDQAiEGg6NPKlNfVKX7jxR2FIESD24uvc+asriIffjZFr Up+OM8M34e9iwRhFSiTgLVG57Me90pI= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 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)); -- 2.43.0