From patchwork Mon Dec 11 15:56:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13487465 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 4C81AC10F05 for ; Mon, 11 Dec 2023 15:58:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A74AD6B0127; Mon, 11 Dec 2023 10:58:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A25E86B012A; Mon, 11 Dec 2023 10:58:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8015E6B012B; Mon, 11 Dec 2023 10:58:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6B3586B0127 for ; Mon, 11 Dec 2023 10:58:11 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3C7A61C0F75 for ; Mon, 11 Dec 2023 15:58:11 +0000 (UTC) X-FDA: 81554993982.05.75F8AA9 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 7D8451C0025 for ; Mon, 11 Dec 2023 15:58:09 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gXhLSx8w; 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=1702310289; 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=VER2ukZQXsfAHa/RpU4plqm2RzyVwEC40zuZNC17KhY=; b=Xz+FW9moqk9YbVMhUxdL+SHNUcp+43MhdyyRfzImZg43Wyj9D6IxQvfJz8xCx91oNnFFF7 Kl31MEyzTZiW0xwSajnZ/3jBPW6aMbwktjSGxZzfwa+lziFdHEgD9PeNiOddsCZbwl5oSV Uw6d0LZeH6A6EYCEvU3fjwyPi8+ExQ8= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gXhLSx8w; 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=1702310289; a=rsa-sha256; cv=none; b=lEzyaVKEDW7SJBnIZf7SHpQj0pnZ4ECDnzFZ4E5o46my435T6T+BUqxpv7VFQ35F2cmncX lCPPpFh6fT71HSsd5NhZ+wxKq/Myph0n3idztVJ+fDR+9uk9IoyUG49w83DiJieF0ytqXW tHzFEngIEDAUkVmZeNSWzQdIEBKG7Vs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702310288; 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=VER2ukZQXsfAHa/RpU4plqm2RzyVwEC40zuZNC17KhY=; b=gXhLSx8wfWrx+SsqvBXh/5A6QnWb3MraItxEdms0AYXbBmLOn1F7PP4FbeiaWZO+HUp6tv uR6aQNCJiR6TP175pkE1MhfuTlR2u/3vQzmT+dpIarTC8P5b5CcwTeTzPxjmONpcyQc0nb z/bwRemW2NiHpt+wwtL53pr3CxdVAFE= 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-554-O8xKFmHWPGuFDgNfrHONmg-1; Mon, 11 Dec 2023 10:58:04 -0500 X-MC-Unique: O8xKFmHWPGuFDgNfrHONmg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 6E3723C28642; Mon, 11 Dec 2023 15:58:03 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.192.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 094C11121312; Mon, 11 Dec 2023 15:57:59 +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 v1 26/39] mm/khugepaged: page_remove_rmap() -> folio_remove_rmap_pte() Date: Mon, 11 Dec 2023 16:56:39 +0100 Message-ID: <20231211155652.131054-27-david@redhat.com> In-Reply-To: <20231211155652.131054-1-david@redhat.com> References: <20231211155652.131054-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Rspamd-Queue-Id: 7D8451C0025 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: muq6wfdp7wciryrswgpfynngru14ryj7 X-HE-Tag: 1702310289-238543 X-HE-Meta: U2FsdGVkX1+OH210Zd0EaftnVyCyRQ6KEPtgmQAdoh8Mi3+dqI+P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wwp3r0AaDuGsVhKjOzC8NqltEBqUiQL7BMR6fyny5e/q7tHVcabDSSYgPBTfwmSddVtw== 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 de174d049e71..4d90c9548ec9 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); } @@ -1624,7 +1621,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++; }