[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9c5ccb75-c06a-e638-a83b-07c318a0d074@oracle.com>
Date: Fri, 20 Jan 2023 14:05:57 -0800
From: Sidhartha Kumar <sidhartha.kumar@...cle.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
akpm@...ux-foundation.org, songmuchun@...edance.com,
mike.kravetz@...cle.com, jhubbard@...dia.com
Subject: Re: [PATCH 4/9] mm/rmap: change hugepage_add_new_anon_rmap to take in
a folio
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
Powered by blists - more mailing lists