From patchwork Sat Mar 2 07:00:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13579438 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 E1FD4C5478C for ; Sat, 2 Mar 2024 07:00:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C1F486B009B; Sat, 2 Mar 2024 02:00:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BD0136B009D; Sat, 2 Mar 2024 02:00:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A96AB6B009E; Sat, 2 Mar 2024 02:00:40 -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 8B6456B009D for ; Sat, 2 Mar 2024 02:00:40 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CFD6D8065C for ; Sat, 2 Mar 2024 07:00:39 +0000 (UTC) X-FDA: 81851200998.16.5129E17 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 62CE9A000E for ; Sat, 2 Mar 2024 07:00:38 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=XQc5W0yi; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709362838; 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=P6Vo8WTO8b4LilggPskpKKneeK4Jr+pGiDxU0jDjxQw=; b=hHFYrX7+GbfMfSH+xmikftY5R+//F6JJ8MZnfVKAZoX4rOI6/P61v+7MIjDj7sLgJwrn5S VDgUi0VuKoqceozZNMNFAB2AoQrLQTerDls22jp02n7qYqsKM7JJB3apDj2LLOA3GE1/mo rhqSEuRvI4snAB7V5wulzaozAwpewOo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709362838; a=rsa-sha256; cv=none; b=tr2SoC1g/r7FtW1IolExk12f9LM2MY67iwDm+27TtMtGNBrW20evvQJhUvJnbrZ3uAHbw7 H4IxwzAFCg0T6K3NbCyY46fiY/ZJsg9NgrlCkX4tz5jWb9N4a9ISEezZfQEX8FFQtlzZxa fSxDk4E0ogx6UaRKlaRR78k8IpKVuhc= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=XQc5W0yi; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=P6Vo8WTO8b4LilggPskpKKneeK4Jr+pGiDxU0jDjxQw=; b=XQc5W0yiEYAbX9mQX8VXlgBr51 IWwGniKZyjbwaIuAQUn0mQrjitvhYKnmTHS7XWBXL6LGMBR9oW77tc0Q6NHYuYbjbEay87OIy3gHA W6x/zg0NNMlL9AOlVTLm8NpHUIb0GNveD5hwFZo4k4AuJ/x6QolBrgxU+69AdlrzgoCqkpc6YkKnY zl9M+v5dGZiPiEseX8S+T5Q7wzAI5YOKfulWURCXdNC+wv8pN6xBypolUv9d6lY7jpuWK304M1fuF vGGDXb/w3DltU40WHhv+ZiZIkbsd3tL5YGLrhnGxdGLf7h3MOojyu0h7mQyhfOC2AyyVe16e5O3OS P01D3s3g==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgJMH-0000000D2fi-2ZpZ; Sat, 02 Mar 2024 07:00:33 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Kent Overstreet Subject: [PATCH 3/4] page_alloc: Inline destroy_large_folio() into __folio_put_large() Date: Sat, 2 Mar 2024 07:00:29 +0000 Message-ID: <20240302070031.3108523-4-willy@infradead.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240302070031.3108523-1-willy@infradead.org> References: <20240302070031.3108523-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 62CE9A000E X-Rspam-User: X-Stat-Signature: j6a7r1bofsfsnyquexyho4g8hkjn3gi4 X-Rspamd-Server: rspam03 X-HE-Tag: 1709362838-33931 X-HE-Meta: U2FsdGVkX1+4TqpgFnWh2ZZ5J2v/ASWQgjMMk4ZKmU8D5Q12PfL9CY1AP1h3DPt5+QDluAbM1N+EPWayExmU71KJfXzgk24OSpXJ5caxD1sq6MsPQpLF0SdSeEVPIqrR207/W61U9HfjlQfjf3gURvYqjWd6/G1k4Nw8g7EqAU6KxM5ukQNaMjW9VjLMVlf0Lzur3QyDgsZORSeXgUKUm1RcyV/IyqPlvhtpOQs114I+T/ljEEVyE3HLKeKi7HNO07aT6S7EHPH6k3iE+JY2ZTgPymvlPZG5Ys/sy6QdDgNqHd9ODFmBOz+YP5+ayv7bpXRmQMek/PFy+SIiqhkvsM0lXdXvhXmuTVmYQCmvo4WLkcytfsin6/6f+/QIufWJIZPrPWb6WqLp7nkONtEa2MG/eeDqhc2ADYypfMS4E6S2eXXTkVt7Z5pZO/6qY8MUGSUVw5jBc+thp04wpMVwJI0xkcDRJzCAeOHQjLjvWGJ4vcqsT2vnajDvSxnCnBj+28IJcdSGzfDKM5V0CIoOUn4oOErs/Fn9oyBs2ta2SZCAUejLNku/VAPLIY6v5SJNrFbgoalfBI22eIMheAV06FmiX61Sww2ji7p54jVqLuALjQDc14w7JuW98xAUbje1L50mnjCyAl62qXhdrDMp4Xp1sWfKigO5e2of21KQVdGAKUFmqQ/2Wfh4PaF4CN4yLSGbp0LEvlpt58ADgDHi2DCKssQKKmnpaUhg2QTAUnzkotxb65NsnmspRIC+fs/dDIlmfBlEKGGNzbcEw78v+YbW8wLxMDxLVhrj5M63hWFFWYlQVlegasaMeQ39SMndnRQwKr8Wc/maA9Yo3D8AJymCuBOl4D4mwnkPv1RgRI8Z6ZayS0YylDGgPDycGeOC0tF/qAb3YxuS/2rkn3EGQ/Rscyx4/pQo 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: destroy_large_folio() has only one caller, move its contents there. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 2 -- mm/page_alloc.c | 14 -------------- mm/swap.c | 13 ++++++++++--- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index cfbf2bbc6200..9445155a0873 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1315,8 +1315,6 @@ void folio_copy(struct folio *dst, struct folio *src); unsigned long nr_free_buffer_pages(void); -void destroy_large_folio(struct folio *folio); - /* Returns the number of bytes in this potentially compound page. */ static inline unsigned long page_size(struct page *page) { diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a51cbae62501..8d1f065f6a32 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -582,20 +582,6 @@ void prep_compound_page(struct page *page, unsigned int order) prep_compound_head(page, order); } -void destroy_large_folio(struct folio *folio) -{ - if (folio_test_hugetlb(folio)) { - free_huge_folio(folio); - return; - } - - if (folio_test_large_rmappable(folio)) - folio_undo_large_rmappable(folio); - - mem_cgroup_uncharge(folio); - free_unref_page(&folio->page, folio_order(folio)); -} - static inline void set_buddy_order(struct page *page, unsigned int order) { set_page_private(page, order); diff --git a/mm/swap.c b/mm/swap.c index d1e016e9ee1a..d8c24300ea3d 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -127,9 +127,16 @@ static void __folio_put_large(struct folio *folio) * (it's never listed to any LRU lists) and no memcg routines should * be called for hugetlb (it has a separate hugetlb_cgroup.) */ - if (!folio_test_hugetlb(folio)) - page_cache_release(folio); - destroy_large_folio(folio); + if (folio_test_hugetlb(folio)) { + free_huge_folio(folio); + return; + } + + page_cache_release(folio); + if (folio_test_large_rmappable(folio)) + folio_undo_large_rmappable(folio); + mem_cgroup_uncharge(folio); + free_unref_page(&folio->page, folio_order(folio)); } void __folio_put(struct folio *folio)