From patchwork Thu Aug 24 14:13:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13364245 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 C6B4FC27C40 for ; Thu, 24 Aug 2023 14:13:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A1AEF8E0015; Thu, 24 Aug 2023 10:13:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C4D52800AB; Thu, 24 Aug 2023 10:13:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 88C058E0016; Thu, 24 Aug 2023 10:13:39 -0400 (EDT) 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 7BB098E0015 for ; Thu, 24 Aug 2023 10:13:39 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 08729C0388 for ; Thu, 24 Aug 2023 14:13:39 +0000 (UTC) X-FDA: 81159191358.01.44ACE15 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP id 86B531A0019 for ; Thu, 24 Aug 2023 14:13:36 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=rDd+vA1J; dmarc=none; spf=none (imf19.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=1692886417; 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=EIzc7siWEfndHvEXduqOk/KRK5+pIbbkvQpbSnQ2XKY=; b=YmI8lTZZy1eocarADtCPtGjYFQFFG5v4VbD2RhrU2COVnEx1J6gwBWu/TOWhx1T2JN4j77 LjGN4KEdKIG1pLWRA42oqGMUbx2ox17qppEAIqpmIkOa4o2+qXG2tGtiVa6MV2dxIYdXZO rXbpTZtfK9BWpOrQEhakXtf7xwfLIsQ= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=rDd+vA1J; dmarc=none; spf=none (imf19.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=1692886417; a=rsa-sha256; cv=none; b=OqnTVFE5e0xKDMQniY50eNdYacM2tk+UxQf6BWYKW3sZGnM2n2qPFE2Slz15ZKWY8tW/rH uIn93kfXEaBGQ/PVl65Jq4D72AYKSQCjbdeBSJvQ3rofScfc9RsPVHcMAgpcNjxE7f8d/W brL5cVc7tLxi7/Ts44FgqE3ixhUNdmY= 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=EIzc7siWEfndHvEXduqOk/KRK5+pIbbkvQpbSnQ2XKY=; b=rDd+vA1J7mXhUhpKS7xBQhLnxO 6zjMkUulkoXXcEtgq8B5LYSzw1bGxbHf0Mo0f9YXXoab8qbrk/vR1VowfZAY2EmayGMXPC3PFI3vG INdLgYWPezVoomV63Vo3Xfi4nLPATvawBCRV1xkyd4weM2B4U3J06Z+UyzfWgSm42Y/KSZH2CxAnF l/oE99agDz0rr5oH8++mo9HGxB5lEj1cwk2KiyVT89P8qZS8rq5L5MRf5jv111GVhmGUbIxlvPBPK PoOtthumOBhI2Fc7FOEZNI4GZs9ERjHgzIHxpNkbEn9RoL4MQAEpOU0VRWDM/k56dFjffYqfpd3CC 6K0fGrrg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qZB5U-00BLaa-KL; Thu, 24 Aug 2023 14:13:28 +0000 From: "Matthew Wilcox (Oracle)" To: Mike Kravetz Cc: "Matthew Wilcox (Oracle)" , Muchun Song , linux-mm@kvack.org, Muchun Song , Sidhartha Kumar Subject: [PATCH v2 1/3] hugetlb: Use a folio in free_hpage_workfn() Date: Thu, 24 Aug 2023 15:13:23 +0100 Message-Id: <20230824141325.2704553-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230824141325.2704553-1-willy@infradead.org> References: <20230824141325.2704553-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: wmg8pehwtzt9c9xajgnd4d1tajhcrqyx X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 86B531A0019 X-HE-Tag: 1692886416-64773 X-HE-Meta: U2FsdGVkX1/ZRCyqgpjHvkYLS2EmOr3fC2B6aezvcBjKrYn3isSwXLBhZyeVhaCx5LSfyQeYmGz+LXwKIzhW+ep9KPjehhL/5mpLc7WbyoSvWC/Xt6BZ+JMzMNfZp7sztieN3COkLBXBpXAVTR8kUXTa2O/lacMGqU7Z8pwCxd2COT0DlB7fIju0g1Hx8z7QMg5NE5mhhzddPbIqONy30QYCvTBDelWmRyPuj+osYap+hXLil46zqH1bNSsA2Sp6z1rqasJ3tRBbrzl+1YujfvyyeS+k5Le+sd0gvQByrpJKXuUGi9xHnAUKXdCYjf60cewC99bV2Dc7Dkrmwx8B6hL6TYupGS/7oRIjFVqli2E6Gs4OVjAZcBefIOeCd8sQJ4G90R1dBWiAr66Ee3L/n9LPZtYwM/XwuhPtvLmS8MOjUga7mHP798f4wAiuicu9LYTwWziZMcF2wEC4vDzp/RFtUIG1LwFCGV5/By7qDQe2i578zFvoLIErF7arGOaCjoCf3EQeCrW0Zpjv8vGAM2+tuvd0qPvAjdW0Ei2MyL2p4nZUsUOCg8TbBnx98s3CP/jU62HsJzkJqjcYH4nFnuqRviPQ+2SJ242NXkgDulFAYzSbBmhJjb100z56ay5OnPSd6HBUgn79SX38Jdb5qSwruJ4qeERhweL6tQCb7I1MxKqp2tiMW5k1Royk6QzGoAEXYCj8iFlpTHVXA6hDzQEsR0GMycWCirRFkAEi3f6iPNrclN7IeYJvRiMFkfuXk13/Fs0Eh4qzOIaMhvQ3C7ZkIjCMz584zL82IQ02dNvJpZEh2RRl8AxwkxUplsb8ILVJGvC5R2ZsoZaoGKej7eUquiISlDEBhvo+pNdI2OYZVHYgakjG5jgSCvFDAmwnKdy5wQ7UszdkI5FemJmTKFnSaXO48ZIS9Cf3En0q7PJ43XGCW9+7npag3BXDOAMmZqqqAZyJ87l17C9LHcn CLOwzbtV 0i4FLZpMzmzchMvaSo1rOfrhXVX1q/tWR2Pl2o7jNW6ROLrZF11J6gTFQrcdaiIDg3ltuUK5hHC/JUk3UNzXV+8OmapBn6TzAP+uHkYp2wW/6cilsuHtFtcjeS+ldFgKFSEcEN0q3VGV34kOJ7ThQgE/1fbeUx1SNCZU9bXPyB6M2znVEPZYiu35JNAtfsoQN7xULS1QAS5fTxcJgyFGI4yvBT3XRyAdmZHwnFRTuLc8+rbTGxvSAlNCIc7LobNAMnqbLPJLhfyh3bqu/X+Pnbl+2lpNwsdw4mNz6pgZpFSfqGKa2EI/43z/3Lw== 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: update_and_free_hugetlb_folio puts the memory on hpage_freelist as a folio so we can take it off the list as a folio. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Mike Kravetz Reviewed-by: Muchun Song Cc: Sidhartha Kumar --- mm/hugetlb.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a82c3104337e..d1c856628bac 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1786,22 +1786,22 @@ static void free_hpage_workfn(struct work_struct *work) node = llist_del_all(&hpage_freelist); while (node) { - struct page *page; + struct folio *folio; struct hstate *h; - page = container_of((struct address_space **)node, - struct page, mapping); + folio = container_of((struct address_space **)node, + struct folio, mapping); node = node->next; - page->mapping = NULL; + folio->mapping = NULL; /* * The VM_BUG_ON_FOLIO(!folio_test_hugetlb(folio), folio) in * folio_hstate() is going to trigger because a previous call to * remove_hugetlb_folio() will clear the hugetlb bit, so do * not use folio_hstate() directly. */ - h = size_to_hstate(page_size(page)); + h = size_to_hstate(folio_size(folio)); - __update_and_free_hugetlb_folio(h, page_folio(page)); + __update_and_free_hugetlb_folio(h, folio); cond_resched(); } From patchwork Thu Aug 24 14:13:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13364247 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 5F649C27C40 for ; Thu, 24 Aug 2023 14:13:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC0132800B1; Thu, 24 Aug 2023 10:13:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D6EE42800AB; Thu, 24 Aug 2023 10:13:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC1952800B1; Thu, 24 Aug 2023 10:13:42 -0400 (EDT) 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 AF7842800AB for ; Thu, 24 Aug 2023 10:13:42 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 85FBD16038A for ; Thu, 24 Aug 2023 14:13:42 +0000 (UTC) X-FDA: 81159191484.19.771B629 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf05.hostedemail.com (Postfix) with ESMTP id D27B3100017 for ; Thu, 24 Aug 2023 14:13:40 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Op18IUhA; dmarc=none; spf=none (imf05.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=1692886420; 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=70ENJ+e43W+JEfZAYbhdnR1EAncIpy4QJD8Z04bKBDo=; b=hZM8EETPdqaig41VAkBfxBsZbGRAyWmu4SQ/Im+Y610OAV4oPCn3N/984YtM48jdc7CbsJ 1SwDCNQ0hlV0y02KLLtd4m4DSieBz8yi2HCka5H0o3uXw4i0hu0W/OvQonojPQCYqYBpTi mI5sb+/fMPcF8WCcrdxiGxabE02lRjA= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Op18IUhA; dmarc=none; spf=none (imf05.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=1692886420; a=rsa-sha256; cv=none; b=2N3xE8BLbb/TZqp1G7maOaefj4o6QNfjxVeWPFw+AMBR4NaFCrHquEbCZckOnqLIm4Q1/+ +Uss62sGT1B5PrecksyLLWmTPgBQvFzQg0XALmvMNAkRlcY+fjIAZ/XEPvufpbUCofV5Jt 7vhCndBUyM8mQ5Zpq9dth3O49DMzMGU= 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=70ENJ+e43W+JEfZAYbhdnR1EAncIpy4QJD8Z04bKBDo=; b=Op18IUhAzFaxGRMhbBPMPn0Ozo W6le7n2ERB4vtEPBO1rvvfEG1IFs0QTJlx26h72wO7nlwhLP15jF7q7UYAXVMSgcoqBjYpDj5cJOZ o9jsaBtjrmh3cyj1qU7UX+JIxu8cNG5yn8dU2KKVgSBNNHOEnpzjzIBROHrfeqmyItz7x7RDGOXpy TgjZQr+GgNK5oIXS675v7QRr6ScsJNbcbfGL8g06/PirwoPAcVoRHgTNoD8cE4sWXrw4hBd77OzX+ ib408JPLpUZEYSnl26s1bOEQE/RslPw4viwkVkS9uo6RWLkTSdAq7IAkWSOlSsWe89v7zQk+Y/W74 NC61e9tw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qZB5U-00BLac-OO; Thu, 24 Aug 2023 14:13:28 +0000 From: "Matthew Wilcox (Oracle)" To: Mike Kravetz Cc: "Matthew Wilcox (Oracle)" , Muchun Song , linux-mm@kvack.org, Muchun Song , Sidhartha Kumar Subject: [PATCH v2 2/3] hugetlb: Remove a few calls to page_folio() Date: Thu, 24 Aug 2023 15:13:24 +0100 Message-Id: <20230824141325.2704553-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230824141325.2704553-1-willy@infradead.org> References: <20230824141325.2704553-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: eja6q4n3yw97wtt8sq3ruxtjcos77wdm X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D27B3100017 X-HE-Tag: 1692886420-523606 X-HE-Meta: U2FsdGVkX1/AyF3PWhgb54vr/3xhyD74s7Z1xqQ2kzWPsXzSB8w1cUKcHpogNzgQotHvul4HiJ6xiUFvDJanTkA3jnaiFGondAJ0wg3IHCmZbpeNbQj1y2ZBAts6u3Ryh/1SjTSnKMhMxDpOYrkhMOTCO1QCZ9hheteUDhF1VeJxkCq836DMoctrDvWPsBsdZNgZ9Z7Dcp00Yr8e90Etzimt84SlJfJGgtOWOZDFGApGaq2R3INQpFlWl0uN7kEJhe+g8K5UiJrHn4yc/XuYEI64VYNDhH49JEFkf621bIgsqOrilU0hw/MRaFcCWuf3fCrtS70x0JLVT9vVMNdFZuBJkmy13F1JaIuxD0/diIBleTctdhEmOylYehR2ynCyF5uvclSjP+mxGkdwybERUky/ZvaSRFrUGKlh3rLL7q6Jh55n2uJ3r3Y+HCCHiLy5dOvv/g1ul2pLMaw2OFVzsHP0MPbx6KFTiEfJj4z8ayMK4ThUMNNkIv/r+A97SyR7E5dpsYwSWSyuEVswMm93QQ4fIuXU5xLiicnP2czWXvC5TQENDpa6ZA84lxR3oEbySZG1R9HNHmGqBgXrwXOE3qI1dXtjBLURQSJ4tpZ2Z+xMxxtavKVWaoOWRbKT8kfltSXALe3HKmXDjB5OsaMdE/SH+N8O/RZiBk8v17hphlYDC4roqYSWC5GsBDw08vPuVNTZpmR7yIz5xL1sxmvxoj5k3IHYETMDo4VgKata5a/4iAJEZ6sHQLcCJ2Nfwez1DXlBaSgMSR7nToRvWGk/DSkbZRlvhZc4CcMJ3NPpDOSgeHQcnfZA+idOjr3BQV7YzwAGevjXQRz4Ly9wBdhNR4BjcVbynl1k8ek2YZ1H0T4m3BOolXBj5CEeum6fnrsP/+7msptqJ48fKuZzax61F1dHw8pH9A2NePFYnr4y2RBYixw3DbrU+FZ4dpN2lHNKuvKSNr+XXPvUL8O8++5 Zu+bfRl4 PpIDFAGv4+DqgbYjdB/un7HTJNEVstsc51/yFsZQ8ZBazMQZZbFlYse0rvmG2Nik9/CASSS4dEc+S2hjRVUosrTwgAvZn6y25uHPCnaYtWG4tDBMPqKtFZD3DbZvuXRP2VAimSZNOQxpcDH4RjneKrz+QApOKKlcgkl0TutE5ufCzm1q9lDd79VOD7VhjaYyQ8LiHqDFAZ5HQkEX62cEc/Zs+SeuJdfUP0M9D+ic1o7W0rOaCWHpKodDicMtW+xG6fetkjTQhwJcV0TcZ/D+RihV2YU9ABo19ELm/DQ568jdLZYiZFvJYvze+Cw== 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: Anything found on a linked list threaded through ->lru is guaranteed to be a folio as the compound_head found in a tail page overlaps the ->lru member of struct page. So we can pull folios directly off these lists no matter whether pages or folios were added to the list. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Mike Kravetz Reviewed-by: Muchun Song Cc: Sidhartha Kumar --- mm/hugetlb.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index d1c856628bac..8f548a274e3c 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1835,11 +1835,9 @@ static void update_and_free_hugetlb_folio(struct hstate *h, struct folio *folio, static void update_and_free_pages_bulk(struct hstate *h, struct list_head *list) { - struct page *page, *t_page; - struct folio *folio; + struct folio *folio, *t_folio; - list_for_each_entry_safe(page, t_page, list, lru) { - folio = page_folio(page); + list_for_each_entry_safe(folio, t_folio, list, lru) { update_and_free_hugetlb_folio(h, folio, false); cond_resched(); } @@ -2228,8 +2226,7 @@ static struct page *remove_pool_huge_page(struct hstate *h, bool acct_surplus) { int nr_nodes, node; - struct page *page = NULL; - struct folio *folio; + struct folio *folio = NULL; lockdep_assert_held(&hugetlb_lock); for_each_node_mask_to_free(h, nr_nodes, node, nodes_allowed) { @@ -2239,15 +2236,14 @@ static struct page *remove_pool_huge_page(struct hstate *h, */ if ((!acct_surplus || h->surplus_huge_pages_node[node]) && !list_empty(&h->hugepage_freelists[node])) { - page = list_entry(h->hugepage_freelists[node].next, - struct page, lru); - folio = page_folio(page); + folio = list_entry(h->hugepage_freelists[node].next, + struct folio, lru); remove_hugetlb_folio(h, folio, acct_surplus); break; } } - return page; + return &folio->page; } /* @@ -3363,15 +3359,15 @@ static void try_to_free_low(struct hstate *h, unsigned long count, * Collect pages to be freed on a list, and free after dropping lock */ for_each_node_mask(i, *nodes_allowed) { - struct page *page, *next; + struct folio *folio, *next; struct list_head *freel = &h->hugepage_freelists[i]; - list_for_each_entry_safe(page, next, freel, lru) { + list_for_each_entry_safe(folio, next, freel, lru) { if (count >= h->nr_huge_pages) goto out; - if (PageHighMem(page)) + if (folio_test_highmem(folio)) continue; - remove_hugetlb_folio(h, page_folio(page), false); - list_add(&page->lru, &page_list); + remove_hugetlb_folio(h, folio, false); + list_add(&folio->lru, &page_list); } } From patchwork Thu Aug 24 14:13:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13364246 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 09677C3DA6F for ; Thu, 24 Aug 2023 14:13:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50C4E2800B0; Thu, 24 Aug 2023 10:13:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 46ED72800AB; Thu, 24 Aug 2023 10:13:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 29B202800B0; Thu, 24 Aug 2023 10:13:40 -0400 (EDT) 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 0CDDD2800AB for ; Thu, 24 Aug 2023 10:13:40 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 99096160336 for ; Thu, 24 Aug 2023 14:13:39 +0000 (UTC) X-FDA: 81159191358.22.EB8401D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 5CDFB180031 for ; Thu, 24 Aug 2023 14:13:36 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=sPa61H5v; dmarc=none; spf=none (imf24.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=1692886417; 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=SsFJQNcfE3nVkojz2bjT5SHs5TvxKlqqWYc1ctQJ8EI=; b=BGnDD4nQHe12zbmoLdH9zxZ0m6fxfi40Sm6eSSw40m9bx1JeQ3VyFKC/8TUeXWksnBOhYU I1LatexAeA1tm4D/3GRSCX6RHa5Nm09XdENFVtFRM/2TwPTcuu4s8poL9ZVnnfX2D3JXEN IO4oMYYIoKSeFvcpmNMMHFTtz+5FVNc= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=sPa61H5v; dmarc=none; spf=none (imf24.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=1692886417; a=rsa-sha256; cv=none; b=1bwxUV1ypiabDZBJ1eCXdCt4tH5jSodW4n6R+2AapTSV2SytQQHVW+BSFBgv3M2a7+7tMU ciz1Xdkq8VxhH1HctmkJv4Prwf6PzKpgvQgY7LwSCdiEndZp4lrc1AbBF3nT7SzLMkabHI tMDj6tBJijDKt85+i7kdy8LrLgEQPsM= 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=SsFJQNcfE3nVkojz2bjT5SHs5TvxKlqqWYc1ctQJ8EI=; b=sPa61H5vcZnXuxVSblnCWi+hzo 3+qOHEyuBeFd71YeHiZ4ZTubVCAsRffiUERif/27cBPENerVODQdPdVcmITk6XYQxeR73x5H8s+DO XGP+9mS83PQZPSnLPvrzDJXr0EdED++FBJ5VsBHdS/WQotLPX3LK4z2zFY3R3yKDd3ySlW2U5k08N HVzzSLm8BimsYy0xxFCP7u6Vd8KR8vuHeY8Nr6oQ6QIRhROeFpb3cm4Qfgq/tnowLReeuo+M7/8qo jaHIyZ9pBbqnY4p97p/7LhHU9ztB0S7/14cKrbzu2renA5VP8fR4gwxceIVs0+vEDaNqsl4Nw0QY6 es2Nzl1Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qZB5U-00BLae-Rv; Thu, 24 Aug 2023 14:13:28 +0000 From: "Matthew Wilcox (Oracle)" To: Mike Kravetz Cc: "Matthew Wilcox (Oracle)" , Muchun Song , linux-mm@kvack.org, Sidhartha Kumar Subject: [PATCH v2 3/3] hugetlb: Convert remove_pool_huge_page() to remove_pool_hugetlb_folio() Date: Thu, 24 Aug 2023 15:13:25 +0100 Message-Id: <20230824141325.2704553-4-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230824141325.2704553-1-willy@infradead.org> References: <20230824141325.2704553-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5CDFB180031 X-Stat-Signature: hgz4njxbwctcet9sphbt6akcarpomqpu X-HE-Tag: 1692886416-215017 X-HE-Meta: U2FsdGVkX1+8hipOgvcgexthPWSnU42/6TCjTmNRdHYFI8EWp5zumpYrwW9X+S+Y4sGmU7dRHoz8wMRQxrQfdk+6k/hOlUNTl27tSLFK4d024Jw6BwPB4eDvz2xDATuO1mAbjnQc3hVcIC6/6D2QGFLzHXeqab1QOHQpt8c7xwvHLQl5l6RH7EChe6RkykGZGUv/9u86W9ClbvHRmNdvZ6XsDc82pugbFfisTSZ5sGlU6cm5jyn0V7bLIepn/yobPomB2pdjnoVwBvODBiVNkcQiMf26E1Ux+KC300TzisnXq74u5D8W4fbCnweT1fCnXbuQFYerN/Cec4McGyD/ZOvGisjqzjfpXmQlwwbQuXk3gfwNz0qFKZSOI8xcTY0ZsLZ3fFsITDRbxPerA++Oy5j9xclwNmmdmKpcLDMLkrvYtj9g8Ft7WDnP7ErsKPRlf3VA5kvOzGvixhCXrgQgjzNsh/jMd9PUd9Yl/qG0X4sT4aP+MT2KNnlgw6A8RE9BHIXiwqYOinenKWRX4Nvx21EQiknfge70dxhsmmKnbonSA9Mj8bM706GIW0sBW9l3GUuuwtdf7M7bCK1u4hmMT13fPWBAct608aXDxa4nhaHgKtyujgDcVRHaykxRRjvkU0niLg5ZZEgy+JGy1+eV3FFBGBGImjnUxRX3DTe//vKaeZXRraoDZQ2Ef2hBFF7Ka7m7iLHoQSZEDiuBmjltMb7qbbc7I8auZhRl9tSyq/Q/537Wtg/6Xyvd2F7J3xGQyyEAtFD4/t+RbaCMyxIkin01+PeoQb9bXesH8BL+ysxNyGMCnj5LiqfEqHJKdU1jpUL2GSFkAEP/zzPvyq+WnsNZ1RtYjh3WSkrRV95MSMwPQgQBwdCKENmMPpTJbdzxld/U385+iCWbZc/KwJgmlgLaR5TcWH4na/jACLoPgZOOXILW2/0Jy46Xcn/aEhnKhy9wbFw8qqUAFq65ATZ 4PRKj01Z BoSKSvnyuXEXY99yY7Qc2pZ3C/kAE6o2r4dIEPoksvAt6IB3YXWcbfRcADBR2zirhGqS2SrVuf49JQkKlC6/H4pE08SeK9Q2/HDTOJ1nJfFD2NSClMPGOwQDodtWO4ZijcZwOjaAWdUUjWDgsZY62Zu0vfM2MF/0gsTgb1Llz0fwIRjJo1vf9PRiPFivhaCSeIJpdDurbbQ1xwMkhyLUwjts9dVZ54VHc/oDvK1NS4L/40kVItd6EUlR8Mg== 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: Convert the callers to expect a folio and remove the unnecesary conversion back to a struct page. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Mike Kravetz Cc: Sidhartha Kumar Reviewed-by: Muchun Song --- mm/hugetlb.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 8f548a274e3c..35dcc7f9b52a 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1441,7 +1441,7 @@ static int hstate_next_node_to_alloc(struct hstate *h, } /* - * helper for remove_pool_huge_page() - return the previously saved + * helper for remove_pool_hugetlb_folio() - return the previously saved * node ["this node"] from which to free a huge page. Advance the * next node id whether or not we find a free huge page to free so * that the next attempt to free addresses the next node. @@ -2221,9 +2221,8 @@ static int alloc_pool_huge_page(struct hstate *h, nodemask_t *nodes_allowed, * an additional call to free the page to low level allocators. * Called with hugetlb_lock locked. */ -static struct page *remove_pool_huge_page(struct hstate *h, - nodemask_t *nodes_allowed, - bool acct_surplus) +static struct folio *remove_pool_hugetlb_folio(struct hstate *h, + nodemask_t *nodes_allowed, bool acct_surplus) { int nr_nodes, node; struct folio *folio = NULL; @@ -2243,7 +2242,7 @@ static struct page *remove_pool_huge_page(struct hstate *h, } } - return &folio->page; + return folio; } /* @@ -2597,7 +2596,6 @@ static void return_unused_surplus_pages(struct hstate *h, unsigned long unused_resv_pages) { unsigned long nr_pages; - struct page *page; LIST_HEAD(page_list); lockdep_assert_held(&hugetlb_lock); @@ -2618,15 +2616,17 @@ static void return_unused_surplus_pages(struct hstate *h, * evenly across all nodes with memory. Iterate across these nodes * until we can no longer free unreserved surplus pages. This occurs * when the nodes with surplus pages have no free pages. - * remove_pool_huge_page() will balance the freed pages across the + * remove_pool_hugetlb_folio() will balance the freed pages across the * on-line nodes with memory and will handle the hstate accounting. */ while (nr_pages--) { - page = remove_pool_huge_page(h, &node_states[N_MEMORY], 1); - if (!page) + struct folio *folio; + + folio = remove_pool_hugetlb_folio(h, &node_states[N_MEMORY], 1); + if (!folio) goto out; - list_add(&page->lru, &page_list); + list_add(&folio->lru, &page_list); } out: @@ -3421,7 +3421,6 @@ static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid, nodemask_t *nodes_allowed) { unsigned long min_count, ret; - struct page *page; LIST_HEAD(page_list); NODEMASK_ALLOC(nodemask_t, node_alloc_noretry, GFP_KERNEL); @@ -3541,11 +3540,13 @@ static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid, * Collect pages to be removed on list without dropping lock */ while (min_count < persistent_huge_pages(h)) { - page = remove_pool_huge_page(h, nodes_allowed, 0); - if (!page) + struct folio *folio; + + folio = remove_pool_hugetlb_folio(h, nodes_allowed, 0); + if (!folio) break; - list_add(&page->lru, &page_list); + list_add(&folio->lru, &page_list); } /* free the pages after dropping lock */ spin_unlock_irq(&hugetlb_lock);