lkml.org 
[lkml]   [2023]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 4/9] mm/rmap: change hugepage_add_new_anon_rmap to take in a folio
From
On 1/20/23 1:17 PM, Matthew Wilcox wrote:
> On Fri, Jan 20, 2023 at 12:45:38PM -0800, Sidhartha Kumar wrote:
>>>> @@ -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?
>
I see now, I agree that page cannot be NULL at the return from
alloc_huge_page, I will make that change in v2.

Thanks,
Sidhartha Kumar

\
 
 \ /
  Last update: 2023-03-26 23:51    [W:0.061 / U:0.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site