diff mbox series

[v2,6/6] mm/hugetlb add folio_hstate()

Message ID 20220906165445.146913-7-sidhartha.kumar@oracle.com (mailing list archive)
State New
Headers show
Series begin converting hugetlb code to folios | expand

Commit Message

Sidhartha Kumar Sept. 6, 2022, 4:54 p.m. UTC
Helper function to retrieve hstate information from a hugetlb folio.

Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
 include/linux/hugetlb.h | 9 +++++++--
 mm/migrate.c            | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

Comments

kernel test robot Sept. 7, 2022, 4:01 a.m. UTC | #1
Hi Sidhartha,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on next-20220906]
[cannot apply to soc/for-next linus/master v6.0-rc4]
[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/Sidhartha-Kumar/begin-converting-hugetlb-code-to-folios/20220907-005803
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
config: openrisc-randconfig-r033-20220906 (https://download.01.org/0day-ci/archive/20220907/202209071158.3gw6CkuN-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 12.1.0
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/4f02eaa12cd159c40269d80d357809de3be5518a
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Sidhartha-Kumar/begin-converting-hugetlb-code-to-folios/20220907-005803
        git checkout 4f02eaa12cd159c40269d80d357809de3be5518a
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=openrisc SHELL=/bin/bash

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

All error/warnings (new ones prefixed by >>):

   mm/migrate.c: In function 'alloc_migration_target':
>> mm/migrate.c:1610:36: error: implicit declaration of function 'folio_hstate'; did you mean 'folio_activate'? [-Werror=implicit-function-declaration]
    1610 |                 struct hstate *h = folio_hstate(folio);
         |                                    ^~~~~~~~~~~~
         |                                    folio_activate
>> mm/migrate.c:1610:36: warning: initialization of 'struct hstate *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
   cc1: some warnings being treated as errors


vim +1610 mm/migrate.c

  1592	
  1593	struct page *alloc_migration_target(struct page *page, unsigned long private)
  1594	{
  1595		struct folio *folio = page_folio(page);
  1596		struct migration_target_control *mtc;
  1597		gfp_t gfp_mask;
  1598		unsigned int order = 0;
  1599		struct folio *new_folio = NULL;
  1600		int nid;
  1601		int zidx;
  1602	
  1603		mtc = (struct migration_target_control *)private;
  1604		gfp_mask = mtc->gfp_mask;
  1605		nid = mtc->nid;
  1606		if (nid == NUMA_NO_NODE)
  1607			nid = folio_nid(folio);
  1608	
  1609		if (folio_test_hugetlb(folio)) {
> 1610			struct hstate *h = folio_hstate(folio);
  1611	
  1612			gfp_mask = htlb_modify_alloc_mask(h, gfp_mask);
  1613			return alloc_huge_page_nodemask(h, nid, mtc->nmask, gfp_mask);
  1614		}
  1615	
  1616		if (folio_test_large(folio)) {
  1617			/*
  1618			 * clear __GFP_RECLAIM to make the migration callback
  1619			 * consistent with regular THP allocations.
  1620			 */
  1621			gfp_mask &= ~__GFP_RECLAIM;
  1622			gfp_mask |= GFP_TRANSHUGE;
  1623			order = folio_order(folio);
  1624		}
  1625		zidx = zone_idx(folio_zone(folio));
  1626		if (is_highmem_idx(zidx) || zidx == ZONE_MOVABLE)
  1627			gfp_mask |= __GFP_HIGHMEM;
  1628	
  1629		new_folio = __folio_alloc(gfp_mask, order, nid, mtc->nmask);
  1630	
  1631		return &new_folio->page;
  1632	}
  1633
kernel test robot Sept. 7, 2022, 5:23 a.m. UTC | #2
Hi Sidhartha,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on next-20220906]
[cannot apply to soc/for-next linus/master v6.0-rc4]
[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/Sidhartha-Kumar/begin-converting-hugetlb-code-to-folios/20220907-005803
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
config: arm64-randconfig-r031-20220906
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project c55b41d5199d2394dd6cdb8f52180d8b81d809d4)
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/4f02eaa12cd159c40269d80d357809de3be5518a
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Sidhartha-Kumar/begin-converting-hugetlb-code-to-folios/20220907-005803
        git checkout 4f02eaa12cd159c40269d80d357809de3be5518a
        # 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 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/migrate.c:1610:22: error: call to undeclared function 'folio_hstate'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
                   struct hstate *h = folio_hstate(folio);
                                      ^
>> mm/migrate.c:1610:18: error: incompatible integer to pointer conversion initializing 'struct hstate *' with an expression of type 'int' [-Wint-conversion]
                   struct hstate *h = folio_hstate(folio);
                                  ^   ~~~~~~~~~~~~~~~~~~~
   2 errors generated.


vim +/folio_hstate +1610 mm/migrate.c

  1592	
  1593	struct page *alloc_migration_target(struct page *page, unsigned long private)
  1594	{
  1595		struct folio *folio = page_folio(page);
  1596		struct migration_target_control *mtc;
  1597		gfp_t gfp_mask;
  1598		unsigned int order = 0;
  1599		struct folio *new_folio = NULL;
  1600		int nid;
  1601		int zidx;
  1602	
  1603		mtc = (struct migration_target_control *)private;
  1604		gfp_mask = mtc->gfp_mask;
  1605		nid = mtc->nid;
  1606		if (nid == NUMA_NO_NODE)
  1607			nid = folio_nid(folio);
  1608	
  1609		if (folio_test_hugetlb(folio)) {
> 1610			struct hstate *h = folio_hstate(folio);
  1611	
  1612			gfp_mask = htlb_modify_alloc_mask(h, gfp_mask);
  1613			return alloc_huge_page_nodemask(h, nid, mtc->nmask, gfp_mask);
  1614		}
  1615	
  1616		if (folio_test_large(folio)) {
  1617			/*
  1618			 * clear __GFP_RECLAIM to make the migration callback
  1619			 * consistent with regular THP allocations.
  1620			 */
  1621			gfp_mask &= ~__GFP_RECLAIM;
  1622			gfp_mask |= GFP_TRANSHUGE;
  1623			order = folio_order(folio);
  1624		}
  1625		zidx = zone_idx(folio_zone(folio));
  1626		if (is_highmem_idx(zidx) || zidx == ZONE_MOVABLE)
  1627			gfp_mask |= __GFP_HIGHMEM;
  1628	
  1629		new_folio = __folio_alloc(gfp_mask, order, nid, mtc->nmask);
  1630	
  1631		return &new_folio->page;
  1632	}
  1633
diff mbox series

Patch

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 68177725a897..a218d33e518c 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -850,10 +850,15 @@  static inline pte_t arch_make_huge_pte(pte_t entry, unsigned int shift,
 }
 #endif
 
+static inline struct hstate *folio_hstate(struct folio *folio)
+{
+	VM_BUG_ON_FOLIO(!folio_test_hugetlb(folio), folio);
+	return size_to_hstate(folio_size(folio));
+}
+
 static inline struct hstate *page_hstate(struct page *page)
 {
-	VM_BUG_ON_PAGE(!PageHuge(page), page);
-	return size_to_hstate(page_size(page));
+	return folio_hstate(page_folio(page));
 }
 
 static inline unsigned hstate_index_to_shift(unsigned index)
diff --git a/mm/migrate.c b/mm/migrate.c
index 6a1597c92261..55392a706493 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1589,7 +1589,7 @@  struct page *alloc_migration_target(struct page *page, unsigned long private)
 		nid = folio_nid(folio);
 
 	if (folio_test_hugetlb(folio)) {
-		struct hstate *h = page_hstate(&folio->page);
+		struct hstate *h = folio_hstate(folio);
 
 		gfp_mask = htlb_modify_alloc_mask(h, gfp_mask);
 		return alloc_huge_page_nodemask(h, nid, mtc->nmask, gfp_mask);