* [PATCH 2/3] hugetlb: Remove a few calls to page_folio()
2023-08-22 16:28 [PATCH 1/3] hugetlb: Use a folio in free_hpage_workfn() Matthew Wilcox (Oracle)
@ 2023-08-22 16:28 ` Matthew Wilcox (Oracle)
2023-08-23 22:41 ` Mike Kravetz
` (3 more replies)
2023-08-22 16:28 ` [PATCH 3/3] hugetlb: Convert remove_pool_huge_page() to return a folio Matthew Wilcox (Oracle)
` (2 subsequent siblings)
3 siblings, 4 replies; 12+ messages in thread
From: Matthew Wilcox (Oracle) @ 2023-08-22 16:28 UTC (permalink / raw)
To: Mike Kravetz
Cc: Matthew Wilcox (Oracle), Muchun Song, linux-mm, Sidhartha Kumar
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) <willy@infradead.org>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
mm/hugetlb.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index d1c856628bac..d6309edb59e5 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,7 +2226,6 @@ static struct page *remove_pool_huge_page(struct hstate *h,
bool acct_surplus)
{
int nr_nodes, node;
- struct page *page = NULL;
struct folio *folio;
lockdep_assert_held(&hugetlb_lock);
@@ -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);
}
}
--
2.40.1
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 2/3] hugetlb: Remove a few calls to page_folio()
2023-08-22 16:28 ` [PATCH 2/3] hugetlb: Remove a few calls to page_folio() Matthew Wilcox (Oracle)
@ 2023-08-23 22:41 ` Mike Kravetz
2023-08-24 2:59 ` Muchun Song
` (2 subsequent siblings)
3 siblings, 0 replies; 12+ messages in thread
From: Mike Kravetz @ 2023-08-23 22:41 UTC (permalink / raw)
To: Matthew Wilcox (Oracle); +Cc: Muchun Song, linux-mm, Sidhartha Kumar
On 08/22/23 17:28, Matthew Wilcox (Oracle) wrote:
> 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) <willy@infradead.org>
> Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> ---
> mm/hugetlb.c | 24 ++++++++++--------------
> 1 file changed, 10 insertions(+), 14 deletions(-)
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
--
Mike Kravetz
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 2/3] hugetlb: Remove a few calls to page_folio()
2023-08-22 16:28 ` [PATCH 2/3] hugetlb: Remove a few calls to page_folio() Matthew Wilcox (Oracle)
2023-08-23 22:41 ` Mike Kravetz
@ 2023-08-24 2:59 ` Muchun Song
2023-08-24 13:59 ` kernel test robot
2023-10-13 9:06 ` Dan Carpenter
3 siblings, 0 replies; 12+ messages in thread
From: Muchun Song @ 2023-08-24 2:59 UTC (permalink / raw)
To: Matthew Wilcox (Oracle); +Cc: Mike Kravetz, linux-mm, Sidhartha Kumar
> On Aug 23, 2023, at 00:28, Matthew Wilcox (Oracle) <willy@infradead.org> wrote:
>
> 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) <willy@infradead.org>
> Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] hugetlb: Remove a few calls to page_folio()
2023-08-22 16:28 ` [PATCH 2/3] hugetlb: Remove a few calls to page_folio() Matthew Wilcox (Oracle)
2023-08-23 22:41 ` Mike Kravetz
2023-08-24 2:59 ` Muchun Song
@ 2023-08-24 13:59 ` kernel test robot
2023-10-13 9:06 ` Dan Carpenter
3 siblings, 0 replies; 12+ messages in thread
From: kernel test robot @ 2023-08-24 13:59 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Mike Kravetz
Cc: llvm, oe-kbuild-all, Matthew Wilcox (Oracle),
Muchun Song, linux-mm, Sidhartha Kumar
Hi Matthew,
kernel test robot noticed the following build warnings:
[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on linus/master v6.5-rc7 next-20230824]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Matthew-Wilcox-Oracle/hugetlb-Remove-a-few-calls-to-page_folio/20230823-002932
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20230822162808.4131399-2-willy%40infradead.org
patch subject: [PATCH 2/3] hugetlb: Remove a few calls to page_folio()
config: s390-randconfig-001-20230824 (https://download.01.org/0day-ci/archive/20230824/202308242115.E2LcVeIB-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce: (https://download.01.org/0day-ci/archive/20230824/202308242115.E2LcVeIB-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308242115.E2LcVeIB-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from mm/hugetlb.c:19:
In file included from include/linux/memblock.h:13:
In file included from arch/s390/include/asm/dma.h:5:
In file included from include/linux/io.h:13:
In file included from arch/s390/include/asm/io.h:78:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
547 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
560 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
| ^
include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
| ^
In file included from mm/hugetlb.c:19:
In file included from include/linux/memblock.h:13:
In file included from arch/s390/include/asm/dma.h:5:
In file included from include/linux/io.h:13:
In file included from arch/s390/include/asm/io.h:78:
include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
573 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
| ^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
| ^
In file included from mm/hugetlb.c:19:
In file included from include/linux/memblock.h:13:
In file included from arch/s390/include/asm/dma.h:5:
In file included from include/linux/io.h:13:
In file included from arch/s390/include/asm/io.h:78:
include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
584 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
594 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
604 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
692 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
700 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
708 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
717 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
726 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
735 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
>> mm/hugetlb.c:2232:32: warning: variable 'folio' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
2232 | for_each_node_mask_to_free(h, nr_nodes, node, nodes_allowed) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mm/hugetlb.c:1469:3: note: expanded from macro 'for_each_node_mask_to_free'
1469 | nr_nodes > 0 && \
| ^~~~~~~~~~~~
mm/hugetlb.c:2246:10: note: uninitialized use occurs here
2246 | return &folio->page;
| ^~~~~
mm/hugetlb.c:2232:32: note: remove the '&&' if its condition is always true
2232 | for_each_node_mask_to_free(h, nr_nodes, node, nodes_allowed) {
| ^
mm/hugetlb.c:2229:21: note: initialize the variable 'folio' to silence this warning
2229 | struct folio *folio;
| ^
| = NULL
13 warnings generated.
vim +2232 mm/hugetlb.c
b2261026825ed3 Joonsoo Kim 2013-09-11 2216
e8c5c8249878fb Lee Schermerhorn 2009-09-21 2217 /*
10c6ec49802b17 Mike Kravetz 2021-05-04 2218 * Remove huge page from pool from next node to free. Attempt to keep
10c6ec49802b17 Mike Kravetz 2021-05-04 2219 * persistent huge pages more or less balanced over allowed nodes.
10c6ec49802b17 Mike Kravetz 2021-05-04 2220 * This routine only 'removes' the hugetlb page. The caller must make
10c6ec49802b17 Mike Kravetz 2021-05-04 2221 * an additional call to free the page to low level allocators.
e8c5c8249878fb Lee Schermerhorn 2009-09-21 2222 * Called with hugetlb_lock locked.
e8c5c8249878fb Lee Schermerhorn 2009-09-21 2223 */
10c6ec49802b17 Mike Kravetz 2021-05-04 2224 static struct page *remove_pool_huge_page(struct hstate *h,
10c6ec49802b17 Mike Kravetz 2021-05-04 2225 nodemask_t *nodes_allowed,
6ae11b278bca1c Lee Schermerhorn 2009-12-14 2226 bool acct_surplus)
e8c5c8249878fb Lee Schermerhorn 2009-09-21 2227 {
b2261026825ed3 Joonsoo Kim 2013-09-11 2228 int nr_nodes, node;
cfd5082b514765 Sidhartha Kumar 2022-11-29 2229 struct folio *folio;
e8c5c8249878fb Lee Schermerhorn 2009-09-21 2230
9487ca60fd7fa2 Mike Kravetz 2021-05-04 2231 lockdep_assert_held(&hugetlb_lock);
b2261026825ed3 Joonsoo Kim 2013-09-11 @2232 for_each_node_mask_to_free(h, nr_nodes, node, nodes_allowed) {
685f345708096e Lee Schermerhorn 2009-09-21 2233 /*
685f345708096e Lee Schermerhorn 2009-09-21 2234 * If we're returning unused surplus pages, only examine
685f345708096e Lee Schermerhorn 2009-09-21 2235 * nodes with surplus pages.
685f345708096e Lee Schermerhorn 2009-09-21 2236 */
b2261026825ed3 Joonsoo Kim 2013-09-11 2237 if ((!acct_surplus || h->surplus_huge_pages_node[node]) &&
b2261026825ed3 Joonsoo Kim 2013-09-11 2238 !list_empty(&h->hugepage_freelists[node])) {
e601ce76a2aabd Matthew Wilcox (Oracle 2023-08-22 2239) folio = list_entry(h->hugepage_freelists[node].next,
e601ce76a2aabd Matthew Wilcox (Oracle 2023-08-22 2240) struct folio, lru);
cfd5082b514765 Sidhartha Kumar 2022-11-29 2241 remove_hugetlb_folio(h, folio, acct_surplus);
9a76db09970938 Lee Schermerhorn 2009-12-14 2242 break;
e8c5c8249878fb Lee Schermerhorn 2009-09-21 2243 }
b2261026825ed3 Joonsoo Kim 2013-09-11 2244 }
e8c5c8249878fb Lee Schermerhorn 2009-09-21 2245
e601ce76a2aabd Matthew Wilcox (Oracle 2023-08-22 2246) return &folio->page;
e8c5c8249878fb Lee Schermerhorn 2009-09-21 2247 }
e8c5c8249878fb Lee Schermerhorn 2009-09-21 2248
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 2/3] hugetlb: Remove a few calls to page_folio()
2023-08-22 16:28 ` [PATCH 2/3] hugetlb: Remove a few calls to page_folio() Matthew Wilcox (Oracle)
` (2 preceding siblings ...)
2023-08-24 13:59 ` kernel test robot
@ 2023-10-13 9:06 ` Dan Carpenter
3 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2023-10-13 9:06 UTC (permalink / raw)
To: oe-kbuild, Matthew Wilcox (Oracle), Mike Kravetz
Cc: lkp, oe-kbuild-all, Matthew Wilcox (Oracle),
Muchun Song, linux-mm, Sidhartha Kumar
Hi Matthew,
kernel test robot noticed the following build warnings:
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Matthew-Wilcox-Oracle/hugetlb-Remove-a-few-calls-to-page_folio/20230823-002932
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20230822162808.4131399-2-willy%40infradead.org
patch subject: [PATCH 2/3] hugetlb: Remove a few calls to page_folio()
config: x86_64-randconfig-161-20230827 (https://download.01.org/0day-ci/archive/20231013/202310131039.ZgssYfIB-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231013/202310131039.ZgssYfIB-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202310131039.ZgssYfIB-lkp@intel.com/
smatch warnings:
mm/hugetlb.c:2246 remove_pool_huge_page() error: uninitialized symbol 'folio'.
vim +/folio +2246 mm/hugetlb.c
10c6ec49802b17 Mike Kravetz 2021-05-04 2224 static struct page *remove_pool_huge_page(struct hstate *h,
10c6ec49802b17 Mike Kravetz 2021-05-04 2225 nodemask_t *nodes_allowed,
6ae11b278bca1c Lee Schermerhorn 2009-12-14 2226 bool acct_surplus)
e8c5c8249878fb Lee Schermerhorn 2009-09-21 2227 {
b2261026825ed3 Joonsoo Kim 2013-09-11 2228 int nr_nodes, node;
cfd5082b514765 Sidhartha Kumar 2022-11-29 2229 struct folio *folio;
e8c5c8249878fb Lee Schermerhorn 2009-09-21 2230
9487ca60fd7fa2 Mike Kravetz 2021-05-04 2231 lockdep_assert_held(&hugetlb_lock);
b2261026825ed3 Joonsoo Kim 2013-09-11 2232 for_each_node_mask_to_free(h, nr_nodes, node, nodes_allowed) {
685f345708096e Lee Schermerhorn 2009-09-21 2233 /*
685f345708096e Lee Schermerhorn 2009-09-21 2234 * If we're returning unused surplus pages, only examine
685f345708096e Lee Schermerhorn 2009-09-21 2235 * nodes with surplus pages.
685f345708096e Lee Schermerhorn 2009-09-21 2236 */
b2261026825ed3 Joonsoo Kim 2013-09-11 2237 if ((!acct_surplus || h->surplus_huge_pages_node[node]) &&
b2261026825ed3 Joonsoo Kim 2013-09-11 2238 !list_empty(&h->hugepage_freelists[node])) {
e601ce76a2aabd Matthew Wilcox (Oracle 2023-08-22 2239) folio = list_entry(h->hugepage_freelists[node].next,
e601ce76a2aabd Matthew Wilcox (Oracle 2023-08-22 2240) struct folio, lru);
cfd5082b514765 Sidhartha Kumar 2022-11-29 2241 remove_hugetlb_folio(h, folio, acct_surplus);
9a76db09970938 Lee Schermerhorn 2009-12-14 2242 break;
So we're always guaranteed to hit this break statement?
e8c5c8249878fb Lee Schermerhorn 2009-09-21 2243 }
b2261026825ed3 Joonsoo Kim 2013-09-11 2244 }
e8c5c8249878fb Lee Schermerhorn 2009-09-21 2245
e601ce76a2aabd Matthew Wilcox (Oracle 2023-08-22 @2246) return &folio->page;
e8c5c8249878fb Lee Schermerhorn 2009-09-21 2247 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] hugetlb: Convert remove_pool_huge_page() to return a folio
2023-08-22 16:28 [PATCH 1/3] hugetlb: Use a folio in free_hpage_workfn() Matthew Wilcox (Oracle)
2023-08-22 16:28 ` [PATCH 2/3] hugetlb: Remove a few calls to page_folio() Matthew Wilcox (Oracle)
@ 2023-08-22 16:28 ` Matthew Wilcox (Oracle)
2023-08-23 22:48 ` Mike Kravetz
2023-08-23 22:37 ` [PATCH 1/3] hugetlb: Use a folio in free_hpage_workfn() Mike Kravetz
2023-08-24 2:58 ` Muchun Song
3 siblings, 1 reply; 12+ messages in thread
From: Matthew Wilcox (Oracle) @ 2023-08-22 16:28 UTC (permalink / raw)
To: Mike Kravetz
Cc: Matthew Wilcox (Oracle), Muchun Song, linux-mm, Sidhartha Kumar
Convert the callers to expect a folio and remove the unnecesary conversion
back to a struct page.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
mm/hugetlb.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index d6309edb59e5..283cd5290515 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -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_huge_page(struct hstate *h,
+ nodemask_t *nodes_allowed, bool acct_surplus)
{
int nr_nodes, node;
struct folio *folio;
@@ -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);
@@ -2622,11 +2620,13 @@ static void return_unused_surplus_pages(struct hstate *h,
* 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_huge_page(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_huge_page(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);
--
2.40.1
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 3/3] hugetlb: Convert remove_pool_huge_page() to return a folio
2023-08-22 16:28 ` [PATCH 3/3] hugetlb: Convert remove_pool_huge_page() to return a folio Matthew Wilcox (Oracle)
@ 2023-08-23 22:48 ` Mike Kravetz
2023-08-24 1:10 ` Matthew Wilcox
0 siblings, 1 reply; 12+ messages in thread
From: Mike Kravetz @ 2023-08-23 22:48 UTC (permalink / raw)
To: Matthew Wilcox (Oracle); +Cc: Muchun Song, linux-mm, Sidhartha Kumar
On 08/22/23 17:28, Matthew Wilcox (Oracle) wrote:
> Convert the callers to expect a folio and remove the unnecesary conversion
> back to a struct page.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> ---
> mm/hugetlb.c | 25 +++++++++++++------------
> 1 file changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index d6309edb59e5..283cd5290515 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -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_huge_page(struct hstate *h,
> + nodemask_t *nodes_allowed, bool acct_surplus)
might have been good to make a simple name change to remove_pool_huge_folio,
but not insisting.
Code looks fine,
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
--
Mike Kravetz
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] hugetlb: Convert remove_pool_huge_page() to return a folio
2023-08-23 22:48 ` Mike Kravetz
@ 2023-08-24 1:10 ` Matthew Wilcox
2023-08-24 2:38 ` Muchun Song
0 siblings, 1 reply; 12+ messages in thread
From: Matthew Wilcox @ 2023-08-24 1:10 UTC (permalink / raw)
To: Mike Kravetz; +Cc: Muchun Song, linux-mm, Sidhartha Kumar
On Wed, Aug 23, 2023 at 03:48:13PM -0700, Mike Kravetz wrote:
> > -static struct page *remove_pool_huge_page(struct hstate *h,
> > - nodemask_t *nodes_allowed,
> > - bool acct_surplus)
> > +static struct folio *remove_pool_huge_page(struct hstate *h,
> > + nodemask_t *nodes_allowed, bool acct_surplus)
>
> might have been good to make a simple name change to remove_pool_huge_folio,
> but not insisting.
I wasn't sure what we were calling it now. I can go for huge_folio.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] hugetlb: Convert remove_pool_huge_page() to return a folio
2023-08-24 1:10 ` Matthew Wilcox
@ 2023-08-24 2:38 ` Muchun Song
0 siblings, 0 replies; 12+ messages in thread
From: Muchun Song @ 2023-08-24 2:38 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: Mike Kravetz, Linux-MM, Sidhartha Kumar
> On Aug 24, 2023, at 09:10, Matthew Wilcox <willy@infradead.org> wrote:
>
> On Wed, Aug 23, 2023 at 03:48:13PM -0700, Mike Kravetz wrote:
>>> -static struct page *remove_pool_huge_page(struct hstate *h,
>>> - nodemask_t *nodes_allowed,
>>> - bool acct_surplus)
>>> +static struct folio *remove_pool_huge_page(struct hstate *h,
>>> + nodemask_t *nodes_allowed, bool acct_surplus)
>>
>> might have been good to make a simple name change to remove_pool_huge_folio,
>> but not insisting.
>
> I wasn't sure what we were calling it now. I can go for huge_folio.
>
However, there are so many places where it is hugetlb_folio, so I'd suggest
hugetlb_folio.
Thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] hugetlb: Use a folio in free_hpage_workfn()
2023-08-22 16:28 [PATCH 1/3] hugetlb: Use a folio in free_hpage_workfn() Matthew Wilcox (Oracle)
2023-08-22 16:28 ` [PATCH 2/3] hugetlb: Remove a few calls to page_folio() Matthew Wilcox (Oracle)
2023-08-22 16:28 ` [PATCH 3/3] hugetlb: Convert remove_pool_huge_page() to return a folio Matthew Wilcox (Oracle)
@ 2023-08-23 22:37 ` Mike Kravetz
2023-08-24 2:58 ` Muchun Song
3 siblings, 0 replies; 12+ messages in thread
From: Mike Kravetz @ 2023-08-23 22:37 UTC (permalink / raw)
To: Matthew Wilcox (Oracle); +Cc: Muchun Song, linux-mm, Sidhartha Kumar
On 08/22/23 17:28, Matthew Wilcox (Oracle) wrote:
> 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) <willy@infradead.org>
> Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> ---
> mm/hugetlb.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
Thanks!
I was about to do this for another reason. All 3 patches testing fine with
another series under development.
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
--
Mike Kravetz
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] hugetlb: Use a folio in free_hpage_workfn()
2023-08-22 16:28 [PATCH 1/3] hugetlb: Use a folio in free_hpage_workfn() Matthew Wilcox (Oracle)
` (2 preceding siblings ...)
2023-08-23 22:37 ` [PATCH 1/3] hugetlb: Use a folio in free_hpage_workfn() Mike Kravetz
@ 2023-08-24 2:58 ` Muchun Song
3 siblings, 0 replies; 12+ messages in thread
From: Muchun Song @ 2023-08-24 2:58 UTC (permalink / raw)
To: Matthew Wilcox (Oracle); +Cc: Mike Kravetz, linux-mm, Sidhartha Kumar
> On Aug 23, 2023, at 00:28, Matthew Wilcox (Oracle) <willy@infradead.org> wrote:
>
> 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) <willy@infradead.org>
> Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread