From patchwork Wed Dec 20 22:44:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13500639 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 E1098C3DA6E for ; Wed, 20 Dec 2023 22:46:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E39698D001C; Wed, 20 Dec 2023 17:46:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DC03B8D000D; Wed, 20 Dec 2023 17:46:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5DB18D001C; Wed, 20 Dec 2023 17:46:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id AEFF88D000D for ; Wed, 20 Dec 2023 17:46:19 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 963EF1C0BF1 for ; Wed, 20 Dec 2023 22:46:19 +0000 (UTC) X-FDA: 81588681678.07.E8E3B3B 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 C97EE40013 for ; Wed, 20 Dec 2023 22:46:17 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ByDGAS5p; spf=pass (imf12.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703112377; a=rsa-sha256; cv=none; b=JCUUsrdmIcSdsKKDFzbke16RPLykSVgn1tTwg5P4av4lHUe/MmW79rzZgCDj0MJ12eeRNT qlTM3klipmfLIP/N3OYOK542UC9g7thBg0/vPPvoAXFZRZK9fwG5d7uTlyDN4d4Gvh55Pi t2Foc4yWmg7mHi1T6W1All2f+ic3C0s= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ByDGAS5p; spf=pass (imf12.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703112377; 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=hbXwGjN0pCeXqd5W9uMe29zoEexoygHhqKeEUbLF/bA=; b=BIRDTetVzyiukMHE3914KAw2AlJEu5VLxqeamk087disX3HwBCaCAdTw3eBjhXzp2VX6a8 VWRpvzqdSYdtN2g3vjZgJXG/fkLypHyYna8y71586roSsUvLhiyjpsnxcjW8AnshEZCiSF Ff3kVgrGAfBVxdlzDQ3wK/XuQsRpCQo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703112377; 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=hbXwGjN0pCeXqd5W9uMe29zoEexoygHhqKeEUbLF/bA=; b=ByDGAS5puFBZwl9BJNlPCWBANHjmmbOEssD9lLxW37krxu+qvItnW9G7wc0v/i5lZmDmt4 znVft8knsWNMODY7YutHojYL72WuzWmMZN538xAPZopk3Ev1GeC0XI0h8528nqrYHepG1g /1RbQyuoPgMJ1K6xvQDCtALj5jYbfUQ= 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-482-jF4_JFJ2M8CdeF3OMNX_YQ-1; Wed, 20 Dec 2023 17:46:15 -0500 X-MC-Unique: jF4_JFJ2M8CdeF3OMNX_YQ-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 11D821019C82; Wed, 20 Dec 2023 22:46:15 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id E63C540C6EB9; Wed, 20 Dec 2023 22:46:12 +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 26/40] mm/khugepaged: page_remove_rmap() -> folio_remove_rmap_pte() Date: Wed, 20 Dec 2023 23:44:50 +0100 Message-ID: <20231220224504.646757-27-david@redhat.com> In-Reply-To: <20231220224504.646757-1-david@redhat.com> References: <20231220224504.646757-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: C97EE40013 X-Stat-Signature: 7yhtez7c7xii64677mcdu5aq7m6zye44 X-Rspam-User: X-HE-Tag: 1703112377-345619 X-HE-Meta: U2FsdGVkX1/LwsTM54mmgFScVBtjTNaKn+Mltc8hX+S9l8UUAB6yePaWfAn50/JqbrqX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x9nO0691ZYovNP4gFKzLqhtRfQ36N6Ymrlcw0O+fEkUwrbUXikcmHz2Q== 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 9cdea59fb4c03..15ec9c729ae58 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -494,11 +494,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) { @@ -687,6 +682,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; @@ -708,16 +704,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); } @@ -1625,7 +1622,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++; }