From patchwork Fri Apr 5 15:32:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13619213 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 330AEC67861 for ; Fri, 5 Apr 2024 15:32:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE01E6B0085; Fri, 5 Apr 2024 11:32:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A69736B0096; Fri, 5 Apr 2024 11:32:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 909D36B0098; Fri, 5 Apr 2024 11:32:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 71E426B0085 for ; Fri, 5 Apr 2024 11:32:37 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 32373160161 for ; Fri, 5 Apr 2024 15:32:37 +0000 (UTC) X-FDA: 81975870354.14.70C5527 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id 6A69680027 for ; Fri, 5 Apr 2024 15:32:34 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=gRINT0Mh; dmarc=none; spf=none (imf30.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712331155; a=rsa-sha256; cv=none; b=mVBFDfIWa38zm2ELUYZ8N2QnT/gJ4+hehzgKCFYKGUpNIS/6UIZ5mo+iQEGtshocPlg4Va oJjbWuhafu0q0S03gtPkZjlFjIPC5Yg3qXduiuZzgUwJP15mLWGuE5yCE5BJ3XOqGcSFlm ajMz6+rauGcswhDPXCaEiqaYcpLQtHQ= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=gRINT0Mh; dmarc=none; spf=none (imf30.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712331155; 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=m0vyIh5uB6p22xAiJJA+OgJNMzei5CA7Cs4sH8v9iE0=; b=jgmJRRC54QBYM/EUFLv8q6qrAAve7P8xHtgddYmMRJggTBuWY5tzYrwbIIh4tXuKUH8Ghn jD2FRMRM2GYh/PH+ikUguHNm6uQwTwqW4l87t6EVpzJiSZX/9DqwkpGFt2aK+TmQfTdtUE ne9y5wtMK/uEu0JnwBtAeuQ1Ts5x1uk= 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=m0vyIh5uB6p22xAiJJA+OgJNMzei5CA7Cs4sH8v9iE0=; b=gRINT0MhFOnUzvWURQjUA7sRPJ PPyn5O4TmyrN2IHtXMOB6tnvGAo71940Oy5fc1rBosDuKTKoVDB5HwM/XbHKn+bNQ6qdp11Afs8Ck TrPsNCT8i/eHqEXe/N/dEH/fwB5RHKEd3iw1ovnvCLwI6sIUYJAQFyYFgFmDssZpSY9JHnUjxezpd 5kjfeC8FRdSgenlTCtPuj6i6yRYrim5wavDLrlkNOaaV8hYgwoazovoR6o+1eNkboODKVzZOof2Z+ Q8TkgeGushIgKbgc2v6WxCob9DGnx+uYLi7joxbtDsZdzZ4V0mDCmxzEiRHhRZ/2+7Mixi1GEt7s3 0pBzTw2w==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rslYM-0000000AkxF-0pSL; Fri, 05 Apr 2024 15:32:30 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 3/5] mm: Inline destroy_large_folio() into __folio_put_large() Date: Fri, 5 Apr 2024 16:32:25 +0100 Message-ID: <20240405153228.2563754-4-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405153228.2563754-1-willy@infradead.org> References: <20240405153228.2563754-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 6A69680027 X-Stat-Signature: scj4b3oqor5auq3sq4zu3yo9jqzipsxf X-HE-Tag: 1712331154-859358 X-HE-Meta: U2FsdGVkX1/lIsnPK3O5buk3B/1c7RY/M4Qwjon+6GV1EXXVI4wsM6W4aDOAo0Lw08ylrDhtVilM+KUmUKmEfmmN6kBosZ8L1Rw7gwNb6/kQAltxQKrrWZQAT1+3j6kLFh85xRRXA/KhRFq5F7hE0kK3VcX4vgRfFOwpFfhhFkCnjwpJFxe+S/3fpUfOGaQCgvKpUue1izp8DI1aXrZJeb2JX3pbxFfTOZ8PLiohApAdbxvNgf3cVKT4fZ0lG25nl/+j4+mOvMiOibohv4dceH8F/2GG+6rtWOXk33kvFu8kRMrnMJEq77DSyK+C4VWJrtIBxbvilgWg7pGpNp0XIjs7RBI3kFa3hVbFkFhHCqCTkvj7tK/jmWKvV+v8zC66emNP84zEJ3S66U4P46LUAqKKDz4ZWs57yHDJ16mR0NdfZFVP0vza7OsKdOTOjUTZ/FbTHCqFYb3kdhfvW0sfGzdVjjkZNRrNDyTX21fus3oiHrQWgPpdFj90bB2KpgH12DcDSuyg+DLm1Qh1Hg2Lq+nQCaBRcQU26WratOD3DulGUlMn1h/md4usg923J8Y1koaJ8VBBrNCkqfuj9rTEmtL6AF8mUovIOe14iYamZ9lzRGpUayA8tLGd72PlpzhjduT9PV/4SNFBOWs6rl+wvN/5+AsFuJuC7RW+wZ+dXDna3CBpOrd48oS4azRkXxQAMftLazCEeHQMiEXZo+A1Y9OWqke2A9KgKRp4fHPY0HzK7jJIoUugeTD9ezgY1xMxfsomsMvMaUU3gaEzCgBE313eRpJ+uro39ddsdXF2j/kCVB+Xdp+6/XNRMldpu6MpC4cYCvIJ3KRTfRxWgkNjvdC7noj4X+zlN7LiXoPdB9YFiuaqnQ2Ri6uJ16b6mCsWrvOppZahnVpldwQM0XEuROOopgf0i3XSDyQ2DpLgO6S6IdLkcY2t9W5PBGBrwksWuUagGEK698Sk9Ob1vDp ZWtABEEV 6aG232UmbSPnn71qAQ+pNJ53fRJDqCv2wPkbPpGZaJ8aZrgqEK4sAqeonIum8zpUL1lLx5nRuhN6iRjjKsldXvqoILgQfWcuMKNgrIrud77tqoEEvIwqO7rQxjyu0w3u9XslSXJbeiEXkqFWBb4KhW3iVahgi/H3Pw4obeXEYUpdWpvjljjuKy0bcU0XqjNwycyAASikmwR7WkeoURNBMiHjJUiqk/+GIT/hj 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 d7d311d13712..b9173e230804 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1318,8 +1318,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 8d255f18f6db..171b7863868e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -565,20 +565,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 4643e0d53124..4cfb98304742 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)