Re: [PATCH 8/9] mm/hugetlb: convert hugetlb_wp() to take in a folio

From: Sidhartha Kumar
Date: Tue Jan 24 2023 - 14:11:23 EST


On 1/24/23 7:23 AM, Gerald Schaefer wrote:
On Thu, 19 Jan 2023 13:14:45 -0800
Sidhartha Kumar <sidhartha.kumar@xxxxxxxxxx> wrote:

[...]
page = pte_page(entry);
- if (page != pagecache_page)
+ if (page_folio(page) != pagecache_folio)
if (!trylock_page(page)) {
need_wait_lock = 1;
goto out_ptl;
}
- get_page(page);
+ folio_get(pagecache_folio);

We get a kernel crash on s390 in mprotect testcase from libhugetlbfs
testsuite, starting with next-20230120, bisected to this commit.

We get here with pagecache_folio == NULL, and crash in folio_get().
It doesn´t seem right to replace the get_page() with folio_get()
here, the matching put_page() at out_put_page: also wasn't changed
correspondingly. Also, pagecache_folio == NULL seems to be a valid
case here, on all architectures.

Reverting this folio_get() to get_page() fixes the crash. Not sure
though if I missed something. I think you only want to replace
pagecache_page with pagecache_folio, like in the rest of the commit,
and not page -> pagecache_folio for this get_page().
Ya that get_page(page) line should have stayed how it was before as pagecache_folio is replacing instances of pagecache_page. Thanks for catching this, I'll fix this change in a v2 of this patch series.

Thanks,
Sidhartha Kumar