From patchwork Mon Dec 4 14:21:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13478499 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 66F70C4167B for ; Mon, 4 Dec 2023 14:22:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18E6D6B0128; Mon, 4 Dec 2023 09:22:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 13E0F6B012E; Mon, 4 Dec 2023 09:22:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB0F06B012C; Mon, 4 Dec 2023 09:22:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D1FDE6B0125 for ; Mon, 4 Dec 2023 09:22:11 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 93609C02B5 for ; Mon, 4 Dec 2023 14:22:11 +0000 (UTC) X-FDA: 81529350462.13.F7189E9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id CF6EF1C001E for ; Mon, 4 Dec 2023 14:22:09 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.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=1701699729; 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; bh=GsBjlqWdTtqgOxvGGH4v93t8i0Uklxk4bjGdGt4vg9o=; b=O7W00iLM+1uLHjHJLWEhdfl1gy5Fl3LpqElgf0w4Ic164NxEq7GqTjeIrmBENSdgbcjKT5 I+jvtQuHSzmzvPoOnQ58lcYUEzd3ftujOpSgS220PqOrYiYaU5HxsOyvubdrKU/dnqeXAs f0Ein3bBRfU7ctKBu4yWXgjLCRuuPLg= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.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=1701699729; a=rsa-sha256; cv=none; b=fH/vbkXvJ8WvnfD7293my0VwO3euTTiFC/c6OSVnX6PswGSD/rFH1j8BVei7Yk7/bkop8M xHB/5jodhYmQX0cVR0qfJfOpe+II8oKBLVoTstfUQJecHy6TgoPOS1uXJRuf8UBq9EsbUo tnTZNr8XLEs9C0239Y9WvdvGaeJDm/I= 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-60-Bad9lET6NLK8wnUArWRxyg-1; Mon, 04 Dec 2023 09:22:06 -0500 X-MC-Unique: Bad9lET6NLK8wnUArWRxyg-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 7602885A5B5; Mon, 4 Dec 2023 14:22:05 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.195.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id C73B42026D4C; Mon, 4 Dec 2023 14:22:03 +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 09/39] mm/huge_memory: page_add_file_rmap() -> folio_add_file_rmap_pmd() Date: Mon, 4 Dec 2023 15:21:16 +0100 Message-ID: <20231204142146.91437-10-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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: CF6EF1C001E X-Stat-Signature: e86muraxap8eu7wh6afz4i37ws5ctzq5 X-HE-Tag: 1701699729-734515 X-HE-Meta: U2FsdGVkX1/1SduIWi3ng0y8EY0tfSDrDAJi2tYbM4RclSqbImgkxxqZJxi5w2xpFip4lHXDJX70G/PFD0j8f2UGmnic+7gJCSxe7AgqgvJqkyJ9RJbF9WjxFvcxTmQEBOZ4KIbkafc+qnbjMmfR69NXe+/j6PgP/yGJIS0HR1JBOCzayj+KmaeEss/hmOr1pIP+DjaAWx5YeIqZM3Y/RM5/prQKnjed8SGUsolwILKJigqDMLJ3EppDKywntAZaNLSoRZ5CwXezfWGuoBe/0XSGy/P2O/Y9HnMKDpvrIrt8Cn431vmL+ND8Orf3lsgYNs1w5isKFPdfNHIaEb8dYhXrbEc83CkPJFrPJkAbSjnbRoKXXkehz1r8xLcVI84Ph9EPEgHtHVxMGZCqTm+0UFhmHmravNW/PoPUjfNUo2BoGKlUOz0gkBPWQcNUoF4r6OfQV3JrNXKmQ6h8XsSh2Rn45mif+tG4uvgUqOpdwcRpBFiluKPWcOuEAAJuzAoaEOY0VensE9SEWju8AwXclbM+pwgH0nupoqutPHSAmh2KJXcpWTUYzicaj1890RpkKJUSXTi7BIM3AdPES4iCIRQ9Ks27/XwfT0y7w8jn9TPf9VfmUSoeMjSHETap9xfYZ6BDt16yr/fLLOQu+awbDslDHc/fRznNUDqc0A1DetFmhxTp0sBsW1qfbfMSqlvVgT5CjxA9dpQvf6WC9mDtPo8srqor386e1qDk8R6dH+AJ06J9yla+INcAxr6/JFNI+I8hs7CEtUPuew8LMNwlNxT8Td4eHfEjEUXBwqKWJBFyEujUYILeRAok5TOl4KnO5Jh9HyhuCXc4iFjIBytWHNw5IC1ReQNzfaw+ICBU+ax9bP2FRPq0vKEiCIsCGROGQa+FvbWjvcSrEFeqMYHMIwHjHUeAHW2Nosx1H2c0vt4OpKIS01ICshnn8KaVzxPPS1rUP8Pe/rDZmDc5kvr zLF0naqm 7kqVcf/7D8hK8jeI+Q7eWy3DPv9atuOBbwSk9dr0DA4AxVeuAexNfYGbaR22w/pmHJ2tzD0myxnGi65FL5OjIsc7X4glIC9jSpARwSYsLbd6sMq+Rzv8FdeWGK8CA9kOgLVCs 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 remove_migration_pmd() and while at it, perform some folio conversion. Signed-off-by: David Hildenbrand Reviewed-by: Yin Fengwei --- mm/huge_memory.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 4f542444a91f2..cb33c6e0404cf 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3276,6 +3276,7 @@ int set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw, void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) { + struct folio *folio = page_folio(new); struct vm_area_struct *vma = pvmw->vma; struct mm_struct *mm = vma->vm_mm; unsigned long address = pvmw->address; @@ -3287,7 +3288,7 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) return; entry = pmd_to_swp_entry(*pvmw->pmd); - get_page(new); + folio_get(folio); pmde = mk_huge_pmd(new, READ_ONCE(vma->vm_page_prot)); if (pmd_swp_soft_dirty(*pvmw->pmd)) pmde = pmd_mksoft_dirty(pmde); @@ -3298,10 +3299,10 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) if (!is_migration_entry_young(entry)) pmde = pmd_mkold(pmde); /* NOTE: this may contain setting soft-dirty on some archs */ - if (PageDirty(new) && is_migration_entry_dirty(entry)) + if (folio_test_dirty(folio) && is_migration_entry_dirty(entry)) pmde = pmd_mkdirty(pmde); - if (PageAnon(new)) { + if (folio_test_anon(folio)) { rmap_t rmap_flags = RMAP_COMPOUND; if (!is_readable_migration_entry(entry)) @@ -3309,9 +3310,9 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) page_add_anon_rmap(new, vma, haddr, rmap_flags); } else { - page_add_file_rmap(new, vma, true); + folio_add_file_rmap_pmd(folio, new, vma); } - VM_BUG_ON(pmd_write(pmde) && PageAnon(new) && !PageAnonExclusive(new)); + VM_BUG_ON(pmd_write(pmde) && folio_test_anon(folio) && !PageAnonExclusive(new)); set_pmd_at(mm, haddr, pvmw->pmd, pmde); /* No need to invalidate - it was non-present before */