Received: by 2002:a05:7412:a9a8:b0:f9:92ae:e617 with SMTP id o40csp27455rdh; Wed, 20 Dec 2023 14:58:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IGz/F8xNczAGrqP42ik29FEhT3JfuinodhP4CyWS9ICuA9IzBMQ7ufUfNuS0WuaCv0jDfMj X-Received: by 2002:a17:906:ce33:b0:a23:701b:a160 with SMTP id sd19-20020a170906ce3300b00a23701ba160mr3427399ejb.38.1703113096230; Wed, 20 Dec 2023 14:58:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703113096; cv=none; d=google.com; s=arc-20160816; b=EkBRchkb3yK7Qxoodvr+KZtsh4UJmt3hWi+9VapZKg9US/nZ7UHhhKN7zZM0ufEMHm Q9gz4+OJsR+a5TOC2Qz/q3s1bsAqU/t52nniyhN0dei9nOqknp/lu/eozWoFeH87kq7N BS4P29J4BIDuvdoaXXnzG88DAmUZChOIOgPL+76BiX99Z9i26mpoSMsaHXqSOL2rqf4j SxctC2KyT4AMmeG9zyMCeH+ukzqdytNoxsj/8hFyh84w7klDGvWRHtyE6XbKmpYKNXSY eemz4cnd6sAEbhBPs2wPUQjpN1dCNPFO88oQATzyur5yiEvmNHz+2BvKAWZk1KMw/FTn iwgA== 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=G1DHm1KAW70S05Ll7y3nAT3Y+2rV8NSuluKMu+qR6Lc=; fh=UlFXU+hKOMcm6idRzNfe3Pu+B5L1f7aeir3C6i/NWQA=; b=QmH3Dk5HU58lmb5VdyrNr+NBuEuVQ8Q/6bSNZcYJuTbDw7oAut+N5Cz+6h91sxKHLJ pV0n+8+7wMTOnGMabO2ysJtb1E/BPaM/2KXrkHUh/VpsQO/Se44uBqHFHMVRkV6B6Zzj Gl+FeH1rKkNX/ng6d0Tj0dZd3jRm3HYmrCSQ9NCe7vku0OwzCSziYDlj240b5h3DffdZ Y2eMUJ20KAyRhEu7z+QgVNP5z4gpQ/7Yg1uoiBHK678xZCzJBSGwqB5JZVUqEthCMQVI U4h3xeL6uhCahhisvGF530iIzrL1IIseCEAiNKtQ2CoyARmQpOMADsC4BLcEteTutt3U uY6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Fh/CoeYi"; spf=pass (google.com: domain of linux-kernel+bounces-7573-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7573-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id zr14-20020a170907710e00b00a23701d586bsi242842ejb.9.2023.12.20.14.58.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 14:58:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7573-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Fh/CoeYi"; spf=pass (google.com: domain of linux-kernel+bounces-7573-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7573-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 am.mirrors.kernel.org (Postfix) with ESMTPS id CEAAA1F245B4 for ; Wed, 20 Dec 2023 22:58:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7D745D4B0; Wed, 20 Dec 2023 22:46:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Fh/CoeYi" 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 68CEB51014 for ; Wed, 20 Dec 2023 22:46:20 +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=1703112379; 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=G1DHm1KAW70S05Ll7y3nAT3Y+2rV8NSuluKMu+qR6Lc=; b=Fh/CoeYi9hoJX1wwGfYFrxnSvjIV6maK09xIpKwsmRRKwpsiO79JaaBbvFEgd3P0o1oEME m+zpWpcALwdA/A3OntKBJV9XKOYdvK9l+bFWuKBuXgO8gi9kViN1plpjNAZhx9J5rJY+ZE Ro7+q4sFfuS1FT1zJu7Z/6ZL+5iYZHI= 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-365-LtmkEP2FNZWZAiW0FRkA1g-1; Wed, 20 Dec 2023 17:46:13 -0500 X-MC-Unique: LtmkEP2FNZWZAiW0FRkA1g-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 97715848C07; Wed, 20 Dec 2023 22:46:12 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8000340C6EB9; Wed, 20 Dec 2023 22:46:10 +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 25/40] mm/huge_memory: page_remove_rmap() -> folio_remove_rmap_pmd() Date: Wed, 20 Dec 2023 23:44:49 +0100 Message-ID: <20231220224504.646757-26-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 zap_huge_pmd() and set_pmd_migration_entry(). While at it, perform some more folio conversion. Signed-off-by: David Hildenbrand --- mm/huge_memory.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 1f438326b69bc..e7bc0f38ddc53 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1898,7 +1898,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, if (pmd_present(orig_pmd)) { page = pmd_page(orig_pmd); - page_remove_rmap(page, vma, true); + folio_remove_rmap_pmd(page_folio(page), page, vma); VM_BUG_ON_PAGE(page_mapcount(page) < 0, page); VM_BUG_ON_PAGE(!PageHead(page), page); } else if (thp_migration_supported()) { @@ -2433,12 +2433,13 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, page = pfn_swap_entry_to_page(entry); } else { page = pmd_page(old_pmd); - if (!PageDirty(page) && pmd_dirty(old_pmd)) - set_page_dirty(page); - if (!PageReferenced(page) && pmd_young(old_pmd)) - SetPageReferenced(page); - page_remove_rmap(page, vma, true); - put_page(page); + folio = page_folio(page); + if (!folio_test_dirty(folio) && pmd_dirty(old_pmd)) + folio_set_dirty(folio); + if (!folio_test_referenced(folio) && pmd_young(old_pmd)) + folio_set_referenced(folio); + folio_remove_rmap_pmd(folio, page, vma); + folio_put(folio); } add_mm_counter(mm, mm_counter_file(page), -HPAGE_PMD_NR); return; @@ -2593,7 +2594,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, pte_unmap(pte - 1); if (!pmd_migration) - page_remove_rmap(page, vma, true); + folio_remove_rmap_pmd(folio, page, vma); if (freeze) put_page(page); @@ -3536,6 +3537,7 @@ late_initcall(split_huge_pages_debugfs); int set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw, struct page *page) { + struct folio *folio = page_folio(page); struct vm_area_struct *vma = pvmw->vma; struct mm_struct *mm = vma->vm_mm; unsigned long address = pvmw->address; @@ -3551,14 +3553,14 @@ int set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw, pmdval = pmdp_invalidate(vma, address, pvmw->pmd); /* See page_try_share_anon_rmap(): invalidate PMD first. */ - anon_exclusive = PageAnon(page) && PageAnonExclusive(page); + anon_exclusive = folio_test_anon(folio) && PageAnonExclusive(page); if (anon_exclusive && page_try_share_anon_rmap(page)) { set_pmd_at(mm, address, pvmw->pmd, pmdval); return -EBUSY; } if (pmd_dirty(pmdval)) - set_page_dirty(page); + folio_set_dirty(folio); if (pmd_write(pmdval)) entry = make_writable_migration_entry(page_to_pfn(page)); else if (anon_exclusive) @@ -3575,8 +3577,8 @@ int set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw, if (pmd_uffd_wp(pmdval)) pmdswp = pmd_swp_mkuffd_wp(pmdswp); set_pmd_at(mm, address, pvmw->pmd, pmdswp); - page_remove_rmap(page, vma, true); - put_page(page); + folio_remove_rmap_pmd(folio, page, vma); + folio_put(folio); trace_set_migration_pmd(address, pmd_val(pmdswp)); return 0; -- 2.43.0