From patchwork Mon Dec 4 14:21:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13478528 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 54100C4167B for ; Mon, 4 Dec 2023 14:23:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 756706B02B0; Mon, 4 Dec 2023 09:22:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 705D36B02B2; Mon, 4 Dec 2023 09:22:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57FF66B02B4; Mon, 4 Dec 2023 09:22:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4252B6B02B0 for ; Mon, 4 Dec 2023 09:22:43 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 71DB340291 for ; Mon, 4 Dec 2023 14:22:42 +0000 (UTC) X-FDA: 81529351764.16.51D8B83 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 9F7EC40018 for ; Mon, 4 Dec 2023 14:22:40 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WLketFYV; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.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=1701699760; 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=KbWS1WI33hCQDyuuf4OMcK1JcfvJiYhRWhxjjruqKZQ=; b=4AGNw1DO31PkSFZ0ToW4DO2fUiYcVr0ZKs/xx4yhG/ulDzKQpfM+pfYGZenTsqL6X5V7Ol 3lIKGeapIAA6CDjiwSteb3BlewywPD/PCnSArW5yepusr2kQp4xud68f50XK5nnLpxbAM+ pm/GhAR4qVeP7bg2sEj/Cq3ssMNczdk= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WLketFYV; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.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=1701699760; a=rsa-sha256; cv=none; b=NiLkMGEoEe+sQG46KaD0x66/O4xyyTsYTcybkX6+sVjGfrC0oPTLhU80zUomWRJoPdkGWF defD2Kv3QNB6A/sBU1nwmcxpQxdXw/Rsei51jFv9hY8JU7HpY5NjxELbo11MjqCG6bd6hH Xs3IqXA5/cRHxRQm9hicSL0yJM5gbAQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701699760; 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=KbWS1WI33hCQDyuuf4OMcK1JcfvJiYhRWhxjjruqKZQ=; b=WLketFYVLW2bNZi/GxwNRn92cCxCNk/K/BzSZpQNWXKKhph/Zn0LQmX4RZ1Xfmi1sX9Ikc 8hYOffPuVWKeTkK4JN1Fw+y6qUbPExfzHFBOE1/egTf/V1fFItqnmukuMbhyyMp1plRKSB pPHIXx6NE7leVie3PV6ZS7WOH5Q2Nvs= 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-516-d-d9o59fPPm40XM48Es9-g-1; Mon, 04 Dec 2023 09:22:38 -0500 X-MC-Unique: d-d9o59fPPm40XM48Es9-g-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 D93A9101A529; Mon, 4 Dec 2023 14:22:37 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.195.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id 460F42026D4C; Mon, 4 Dec 2023 14:22: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 RFC 26/39] mm/khugepaged: page_remove_rmap() -> folio_remove_rmap_pte() Date: Mon, 4 Dec 2023 15:21:33 +0100 Message-ID: <20231204142146.91437-27-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: 9F7EC40018 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: quto9fc39h36kogimd5is5um17kxyqw5 X-HE-Tag: 1701699760-554089 X-HE-Meta: U2FsdGVkX18ZaZiD1KP9XsU0DxXPsQHfncURjOxKA+Rt1qeNKZiyTqj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d1k6ZsHr9RZuY7XPejPJiNItJ6AU166AJy2Vrj097z5YdxBucfJ/hjP6f51Ro5+Vk5DmKm33EiJanmTA== 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 __collapse_huge_page_copy_succeeded() and collapse_pte_mapped_thp(). While at it, perform some more folio conversion in __collapse_huge_page_copy_succeeded(). We can get rid of release_pte_page(). Signed-off-by: David Hildenbrand --- mm/khugepaged.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 064654717843e..c2d7438fac22d 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -493,11 +493,6 @@ static void release_pte_folio(struct folio *folio) folio_putback_lru(folio); } -static void release_pte_page(struct page *page) -{ - release_pte_folio(page_folio(page)); -} - static void release_pte_pages(pte_t *pte, pte_t *_pte, struct list_head *compound_pagelist) { @@ -686,6 +681,7 @@ static void __collapse_huge_page_copy_succeeded(pte_t *pte, spinlock_t *ptl, struct list_head *compound_pagelist) { + struct folio *src_folio; struct page *src_page; struct page *tmp; pte_t *_pte; @@ -707,16 +703,17 @@ static void __collapse_huge_page_copy_succeeded(pte_t *pte, } } else { src_page = pte_page(pteval); - if (!PageCompound(src_page)) - release_pte_page(src_page); + src_folio = page_folio(src_page); + if (!folio_test_large(src_folio)) + release_pte_folio(src_folio); /* * ptl mostly unnecessary, but preempt has to * be disabled to update the per-cpu stats - * inside page_remove_rmap(). + * inside folio_remove_rmap_pte(). */ spin_lock(ptl); ptep_clear(vma->vm_mm, address, _pte); - page_remove_rmap(src_page, vma, false); + folio_remove_rmap_pte(src_folio, src_page, vma); spin_unlock(ptl); free_page_and_swap_cache(src_page); } @@ -1619,7 +1616,7 @@ int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr, * PTE dirty? Shmem page is already dirty; file is read-only. */ ptep_clear(mm, addr, pte); - page_remove_rmap(page, vma, false); + folio_remove_rmap_pte(folio, page, vma); nr_ptes++; }