On Fri, Jan 20, 2023 at 12:45:38PM -0800, Sidhartha Kumar wrote:I see now, I agree that page cannot be NULL at the return from alloc_huge_page, I will make that change in v2.
@@ -6176,6 +6186,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
spinlock_t *ptl;
int ret = -ENOMEM;
struct page *page;
+ struct folio *folio = NULL;
int writable;
bool page_in_pagecache = false;
@@ -6251,12 +6262,15 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
*pagep = NULL;
}
+ if (page)
+ folio = page_folio(page);
+
/*
- * The memory barrier inside __SetPageUptodate makes sure that
+ * The memory barrier inside __folio_mark_uptodate makes sure that
* preceding stores to the page contents become visible before
* the set_pte_at() write.
*/
- __SetPageUptodate(page);
+ __folio_mark_uptodate(folio);
Hi Matthew,
In the snippet:
page = alloc_huge_page(dst_vma, dst_addr, 0);
if (IS_ERR(page)) {
put_page(*pagep);
ret = -ENOMEM;
*pagep = NULL;
goto out;
}
copy_user_huge_page(page, *pagep, dst_addr, dst_vma,
pages_per_huge_page(h));
I thought the IS_ERR() call does not handle the NULL case and is a check for
high memory addresses, and copy_user_huge_page() path does not seem to
handle the NULL case as well but alloc_huge_page() can possibly return NULL
so I was unsure about how to handle the folio conversion.
I'm not sure how alloc_huge_page() can return NULL. It seems like it
returns ERR_PTR(-ENOSPC) or ERR_PTR(-ENOMEM) if it cannot allocate memory?