Re: [PATCH v2 3/9] mm/huge_page: cleanup clear_/copy_subpage()

From: Matthew Wilcox
Date: Fri Sep 08 2023 - 09:10:03 EST


On Wed, Aug 30, 2023 at 11:49:52AM -0700, Ankur Arora wrote:
> @@ -5945,9 +5935,7 @@ static int __clear_huge_page(
> /* Process subpages at the end of huge page */
> for (i = pages_per_huge_page - 1; i >= 2 * n; i--) {
> cond_resched();
> - ret = process_subpage(addr + i * PAGE_SIZE, i, arg);
> - if (ret)
> - return ret;
> + clear_user_highpage(page + i, addr + i * PAGE_SIZE);

It's possible for a 1GB page to cross a memmap discontiguity. This
needs to be:

clear_user_highpage(nth_page(page, i),
addr + i * PAGE_SIZE);

(similarly in other places)