All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mm/hugetlb: convert get_hwpoison_huge_page() to folios
@ 2023-01-18 17:40 Sidhartha Kumar
  2023-01-18 17:52 ` Matthew Wilcox
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sidhartha Kumar @ 2023-01-18 17:40 UTC (permalink / raw)
  To: linux-kernel, linux-mm
  Cc: akpm, songmuchun, mike.kravetz, willy, naoya.horiguchi,
	Sidhartha Kumar

Straightforward conversion of get_hwpoison_huge_page() to
get_hwpoison_hugetlb_folio(). Reduces two references to a head page in
memory-failure.c

Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
---
v1 -> v2
Change &folio->page == compound_head(page) to folio == page_folio(page)
in __get_hwpoison_page() per Matthew

add a-b

 include/linux/hugetlb.h |  2 +-
 mm/hugetlb.c            | 10 +++++-----
 mm/memory-failure.c     | 22 +++++++++++-----------
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index febc36f6c595..c6854fc50690 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -171,7 +171,7 @@ bool hugetlb_reserve_pages(struct inode *inode, long from, long to,
 long hugetlb_unreserve_pages(struct inode *inode, long start, long end,
 						long freed);
 int isolate_hugetlb(struct folio *folio, struct list_head *list);
-int get_hwpoison_huge_page(struct page *page, bool *hugetlb, bool unpoison);
+int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison);
 int get_huge_page_for_hwpoison(unsigned long pfn, int flags,
 				bool *migratable_cleared);
 void putback_active_hugepage(struct page *page);
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 856d2fdffbb9..c37a26c8392c 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -7272,18 +7272,18 @@ int isolate_hugetlb(struct folio *folio, struct list_head *list)
 	return ret;
 }
 
-int get_hwpoison_huge_page(struct page *page, bool *hugetlb, bool unpoison)
+int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison)
 {
 	int ret = 0;
 
 	*hugetlb = false;
 	spin_lock_irq(&hugetlb_lock);
-	if (PageHeadHuge(page)) {
+	if (folio_test_hugetlb(folio)) {
 		*hugetlb = true;
-		if (HPageFreed(page))
+		if (folio_test_hugetlb_freed(folio))
 			ret = 0;
-		else if (HPageMigratable(page) || unpoison)
-			ret = get_page_unless_zero(page);
+		else if (folio_test_hugetlb_migratable(folio) || unpoison)
+			ret = folio_try_get(folio);
 		else
 			ret = -EBUSY;
 	}
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 0b0a36afd79d..eb8c3cf2ca36 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1328,28 +1328,28 @@ static inline bool HWPoisonHandlable(struct page *page, unsigned long flags)
 
 static int __get_hwpoison_page(struct page *page, unsigned long flags)
 {
-	struct page *head = compound_head(page);
+	struct folio *folio = page_folio(page);
 	int ret = 0;
 	bool hugetlb = false;
 
-	ret = get_hwpoison_huge_page(head, &hugetlb, false);
+	ret = get_hwpoison_hugetlb_folio(folio, &hugetlb, false);
 	if (hugetlb)
 		return ret;
 
 	/*
-	 * This check prevents from calling get_page_unless_zero() for any
-	 * unsupported type of page in order to reduce the risk of unexpected
-	 * races caused by taking a page refcount.
+	 * This check prevents from calling folio_try_get() for any
+	 * unsupported type of folio in order to reduce the risk of unexpected
+	 * races caused by taking a folio refcount.
 	 */
-	if (!HWPoisonHandlable(head, flags))
+	if (!HWPoisonHandlable(&folio->page, flags))
 		return -EBUSY;
 
-	if (get_page_unless_zero(head)) {
-		if (head == compound_head(page))
+	if (folio_try_get(folio)) {
+		if (folio == page_folio(page))
 			return 1;
 
 		pr_info("%#lx cannot catch tail\n", page_to_pfn(page));
-		put_page(head);
+		folio_put(folio);
 	}
 
 	return 0;
@@ -1418,11 +1418,11 @@ static int get_any_page(struct page *p, unsigned long flags)
 
 static int __get_unpoison_page(struct page *page)
 {
-	struct page *head = compound_head(page);
+	struct folio *folio = page_folio(page);
 	int ret = 0;
 	bool hugetlb = false;
 
-	ret = get_hwpoison_huge_page(head, &hugetlb, true);
+	ret = get_hwpoison_hugetlb_folio(folio, &hugetlb, true);
 	if (hugetlb)
 		return ret;
 
-- 
2.39.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm/hugetlb: convert get_hwpoison_huge_page() to folios
  2023-01-18 17:40 [PATCH v2] mm/hugetlb: convert get_hwpoison_huge_page() to folios Sidhartha Kumar
@ 2023-01-18 17:52 ` Matthew Wilcox
  2023-01-19  0:34 ` kernel test robot
  2023-01-19  0:55 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2023-01-18 17:52 UTC (permalink / raw)
  To: Sidhartha Kumar
  Cc: linux-kernel, linux-mm, akpm, songmuchun, mike.kravetz,
	naoya.horiguchi

On Wed, Jan 18, 2023 at 09:40:39AM -0800, Sidhartha Kumar wrote:
> Straightforward conversion of get_hwpoison_huge_page() to
> get_hwpoison_hugetlb_folio(). Reduces two references to a head page in
> memory-failure.c
> 
> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>

Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm/hugetlb: convert get_hwpoison_huge_page() to folios
  2023-01-18 17:40 [PATCH v2] mm/hugetlb: convert get_hwpoison_huge_page() to folios Sidhartha Kumar
  2023-01-18 17:52 ` Matthew Wilcox
@ 2023-01-19  0:34 ` kernel test robot
  2023-01-19  0:55 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2023-01-19  0:34 UTC (permalink / raw)
  To: Sidhartha Kumar; +Cc: llvm, oe-kbuild-all

Hi Sidhartha,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Sidhartha-Kumar/mm-hugetlb-convert-get_hwpoison_huge_page-to-folios/20230119-014337
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20230118174039.14247-1-sidhartha.kumar%40oracle.com
patch subject: [PATCH v2] mm/hugetlb: convert get_hwpoison_huge_page() to folios
config: arm64-buildonly-randconfig-r006-20230118 (https://download.01.org/0day-ci/archive/20230119/202301190837.bTrbAr7a-lkp@intel.com/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 4196ca3278f78c6e19246e54ab0ecb364e37d66a)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/6704f4eff6775ce3ccc4156b41b9d1c4d091eb14
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Sidhartha-Kumar/mm-hugetlb-convert-get_hwpoison_huge_page-to-folios/20230119-014337
        git checkout 6704f4eff6775ce3ccc4156b41b9d1c4d091eb14
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> mm/memory-failure.c:1335:8: error: call to undeclared function 'get_hwpoison_hugetlb_folio'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
           ret = get_hwpoison_hugetlb_folio(folio, &hugetlb, false);
                 ^
   mm/memory-failure.c:1335:8: note: did you mean 'get_hwpoison_huge_page'?
   include/linux/hugetlb.h:420:19: note: 'get_hwpoison_huge_page' declared here
   static inline int get_hwpoison_huge_page(struct page *page, bool *hugetlb, bool unpoison)
                     ^
   mm/memory-failure.c:1425:8: error: call to undeclared function 'get_hwpoison_hugetlb_folio'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
           ret = get_hwpoison_hugetlb_folio(folio, &hugetlb, true);
                 ^
   2 errors generated.


vim +/get_hwpoison_hugetlb_folio +1335 mm/memory-failure.c

  1328	
  1329	static int __get_hwpoison_page(struct page *page, unsigned long flags)
  1330	{
  1331		struct folio *folio = page_folio(page);
  1332		int ret = 0;
  1333		bool hugetlb = false;
  1334	
> 1335		ret = get_hwpoison_hugetlb_folio(folio, &hugetlb, false);
  1336		if (hugetlb)
  1337			return ret;
  1338	
  1339		/*
  1340		 * This check prevents from calling folio_try_get() for any
  1341		 * unsupported type of folio in order to reduce the risk of unexpected
  1342		 * races caused by taking a folio refcount.
  1343		 */
  1344		if (!HWPoisonHandlable(&folio->page, flags))
  1345			return -EBUSY;
  1346	
  1347		if (folio_try_get(folio)) {
  1348			if (folio == page_folio(page))
  1349				return 1;
  1350	
  1351			pr_info("%#lx cannot catch tail\n", page_to_pfn(page));
  1352			folio_put(folio);
  1353		}
  1354	
  1355		return 0;
  1356	}
  1357	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm/hugetlb: convert get_hwpoison_huge_page() to folios
  2023-01-18 17:40 [PATCH v2] mm/hugetlb: convert get_hwpoison_huge_page() to folios Sidhartha Kumar
  2023-01-18 17:52 ` Matthew Wilcox
  2023-01-19  0:34 ` kernel test robot
@ 2023-01-19  0:55 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2023-01-19  0:55 UTC (permalink / raw)
  To: Sidhartha Kumar; +Cc: llvm, oe-kbuild-all

Hi Sidhartha,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Sidhartha-Kumar/mm-hugetlb-convert-get_hwpoison_huge_page-to-folios/20230119-014337
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20230118174039.14247-1-sidhartha.kumar%40oracle.com
patch subject: [PATCH v2] mm/hugetlb: convert get_hwpoison_huge_page() to folios
config: x86_64-randconfig-a012 (https://download.01.org/0day-ci/archive/20230119/202301190833.olO4HOkZ-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/6704f4eff6775ce3ccc4156b41b9d1c4d091eb14
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Sidhartha-Kumar/mm-hugetlb-convert-get_hwpoison_huge_page-to-folios/20230119-014337
        git checkout 6704f4eff6775ce3ccc4156b41b9d1c4d091eb14
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> mm/memory-failure.c:1335:8: error: implicit declaration of function 'get_hwpoison_hugetlb_folio' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           ret = get_hwpoison_hugetlb_folio(folio, &hugetlb, false);
                 ^
   mm/memory-failure.c:1335:8: note: did you mean 'get_hwpoison_huge_page'?
   include/linux/hugetlb.h:420:19: note: 'get_hwpoison_huge_page' declared here
   static inline int get_hwpoison_huge_page(struct page *page, bool *hugetlb, bool unpoison)
                     ^
   mm/memory-failure.c:1425:8: error: implicit declaration of function 'get_hwpoison_hugetlb_folio' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           ret = get_hwpoison_hugetlb_folio(folio, &hugetlb, true);
                 ^
   2 errors generated.


vim +/get_hwpoison_hugetlb_folio +1335 mm/memory-failure.c

  1328	
  1329	static int __get_hwpoison_page(struct page *page, unsigned long flags)
  1330	{
  1331		struct folio *folio = page_folio(page);
  1332		int ret = 0;
  1333		bool hugetlb = false;
  1334	
> 1335		ret = get_hwpoison_hugetlb_folio(folio, &hugetlb, false);
  1336		if (hugetlb)
  1337			return ret;
  1338	
  1339		/*
  1340		 * This check prevents from calling folio_try_get() for any
  1341		 * unsupported type of folio in order to reduce the risk of unexpected
  1342		 * races caused by taking a folio refcount.
  1343		 */
  1344		if (!HWPoisonHandlable(&folio->page, flags))
  1345			return -EBUSY;
  1346	
  1347		if (folio_try_get(folio)) {
  1348			if (folio == page_folio(page))
  1349				return 1;
  1350	
  1351			pr_info("%#lx cannot catch tail\n", page_to_pfn(page));
  1352			folio_put(folio);
  1353		}
  1354	
  1355		return 0;
  1356	}
  1357	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-19  0:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-18 17:40 [PATCH v2] mm/hugetlb: convert get_hwpoison_huge_page() to folios Sidhartha Kumar
2023-01-18 17:52 ` Matthew Wilcox
2023-01-19  0:34 ` kernel test robot
2023-01-19  0:55 ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.