mm/memory-failure.c:1841:51: warning: passing argument 1 of 'folio_test_hugetlb_raw_hwp_unreliable' discards 'const' qualifier from pointer target type

kernel test robot <[email protected]> Wed, 05 Aug 2026 03:57:29 +0200
Newsgroups dev.linux.lists.oe-kbuild-all
Message-ID <[email protected]>
tree:   https://github.com/intel-lab-lkp/linux/commits/Matthew-Wilcox-Oracle/hugetlbfs-Set-mapping-folio-order/20260804-172347
head:   6bf87769bcecfb8455f6ece8025ec19bdf1468cb
commit: a2cb2ad150519951a14725d0213ba0b0afe13c71 mm: Handle hugetlb correctly in is_page_hwpoison()
date:   17 hours ago
config: x86_64-rhel-9.4-bpf (https://download.01.org/0day-ci/archive/20260805/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260805/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

   mm/memory-failure.c: In function 'hugetlb_page_hwpoison':
>> mm/memory-failure.c:1841:51: warning: passing argument 1 of 'folio_test_hugetlb_raw_hwp_unreliable' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
    1841 |         if (folio_test_hugetlb_raw_hwp_unreliable(folio))
         |                                                   ^~~~~
   In file included from include/linux/migrate.h:8,
                    from mm/memory-failure.c:52:
   include/linux/hugetlb.h:598:48: note: expected 'struct folio *' but argument is of type 'const struct folio *'
     598 | bool folio_test_hugetlb_##flname(struct folio *folio)           \
         |                                  ~~~~~~~~~~~~~~^~~~~
   include/linux/hugetlb.h:634:9: note: in expansion of macro 'TESTHPAGEFLAG'
     634 |         TESTHPAGEFLAG(uname, flname)                            \
         |         ^~~~~~~~~~~~~
   include/linux/hugetlb.h:646:1: note: in expansion of macro 'HPAGEFLAG'
     646 | HPAGEFLAG(RawHwpUnreliable, raw_hwp_unreliable)
         | ^~~~~~~~~
>> mm/memory-failure.c:1846:42: warning: passing argument 1 of 'raw_hwp_list_head' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
    1846 |         raw_hwp_head = raw_hwp_list_head(folio);
         |                                          ^~~~~
   mm/memory-failure.c:1820:66: note: expected 'struct folio *' but argument is of type 'const struct folio *'
    1820 | static inline struct llist_head *raw_hwp_list_head(struct folio *folio)
         |                                                    ~~~~~~~~~~~~~~^~~~~


vim +1841 mm/memory-failure.c

161df60e9e8965 Naoya Horiguchi         2022-07-14  1824  
a2cb2ad1505199 Matthew Wilcox (Oracle  2026-07-07  1825) /*
a2cb2ad1505199 Matthew Wilcox (Oracle  2026-07-07  1826)  * Check if a given @page in a hugetlb folio is HWPOISON.
a2cb2ad1505199 Matthew Wilcox (Oracle  2026-07-07  1827)  */
a2cb2ad1505199 Matthew Wilcox (Oracle  2026-07-07  1828) bool hugetlb_page_hwpoison(const struct folio *folio, const struct page *page)
b79f8eb408d046 Jiaqi Yan               2023-07-13  1829  {
b79f8eb408d046 Jiaqi Yan               2023-07-13  1830  	struct llist_head *raw_hwp_head;
b79f8eb408d046 Jiaqi Yan               2023-07-13  1831  	struct raw_hwp_page *p;
b79f8eb408d046 Jiaqi Yan               2023-07-13  1832  	bool ret = false;
b79f8eb408d046 Jiaqi Yan               2023-07-13  1833  
b79f8eb408d046 Jiaqi Yan               2023-07-13  1834  	if (!folio_test_hwpoison(folio))
b79f8eb408d046 Jiaqi Yan               2023-07-13  1835  		return false;
b79f8eb408d046 Jiaqi Yan               2023-07-13  1836  
b79f8eb408d046 Jiaqi Yan               2023-07-13  1837  	/*
b79f8eb408d046 Jiaqi Yan               2023-07-13  1838  	 * When RawHwpUnreliable is set, kernel lost track of which subpages
b79f8eb408d046 Jiaqi Yan               2023-07-13  1839  	 * are HWPOISON. So return as if ALL subpages are HWPOISONed.
b79f8eb408d046 Jiaqi Yan               2023-07-13  1840  	 */
b79f8eb408d046 Jiaqi Yan               2023-07-13 @1841  	if (folio_test_hugetlb_raw_hwp_unreliable(folio))
b79f8eb408d046 Jiaqi Yan               2023-07-13  1842  		return true;
b79f8eb408d046 Jiaqi Yan               2023-07-13  1843  
b79f8eb408d046 Jiaqi Yan               2023-07-13  1844  	mutex_lock(&mf_mutex);
b79f8eb408d046 Jiaqi Yan               2023-07-13  1845  
b79f8eb408d046 Jiaqi Yan               2023-07-13 @1846  	raw_hwp_head = raw_hwp_list_head(folio);
b79f8eb408d046 Jiaqi Yan               2023-07-13  1847  	llist_for_each_entry(p, raw_hwp_head->first, node) {
b79f8eb408d046 Jiaqi Yan               2023-07-13  1848  		if (page == p->page) {
b79f8eb408d046 Jiaqi Yan               2023-07-13  1849  			ret = true;
b79f8eb408d046 Jiaqi Yan               2023-07-13  1850  			break;
b79f8eb408d046 Jiaqi Yan               2023-07-13  1851  		}
b79f8eb408d046 Jiaqi Yan               2023-07-13  1852  	}
b79f8eb408d046 Jiaqi Yan               2023-07-13  1853  
b79f8eb408d046 Jiaqi Yan               2023-07-13  1854  	mutex_unlock(&mf_mutex);
b79f8eb408d046 Jiaqi Yan               2023-07-13  1855  
b79f8eb408d046 Jiaqi Yan               2023-07-13  1856  	return ret;
b79f8eb408d046 Jiaqi Yan               2023-07-13  1857  }
b79f8eb408d046 Jiaqi Yan               2023-07-13  1858  

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