From: Sidhartha Kumar <sidhartha.kumar@oracle.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
akpm@linux-foundation.org, songmuchun@bytedance.com,
mike.kravetz@oracle.com, jhubbard@nvidia.com
Subject: Re: [PATCH 4/9] mm/rmap: change hugepage_add_new_anon_rmap to take in a folio
Date: Fri, 20 Jan 2023 12:45:38 -0800 [thread overview]
Message-ID: <9c276d01-379f-9bd7-0a7a-6a831b7b4571@oracle.com> (raw)
In-Reply-To: <Y8ot5Y01TWmB4sBj@casper.infradead.org>
On 1/19/23 10:00 PM, Matthew Wilcox wrote:
> On Thu, Jan 19, 2023 at 01:14:41PM -0800, Sidhartha Kumar wrote:
>> @@ -5599,9 +5603,9 @@ static vm_fault_t hugetlb_wp(struct mm_struct *mm, struct vm_area_struct *vma,
>> goto out_release_all;
>> }
>>
>> - copy_user_huge_page(new_page, old_page, address, vma,
>> + copy_user_huge_page(&new_folio->page, old_page, address, vma,
>> pages_per_huge_page(h));
>
> We have a folio_copy(), but it feels to me like we need a
> folio_copy_user() so that we can use copy_user_page() on machines
> with virtual caches.
>
>> @@ -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 suggest that "page" can never be NULL or __SetPageUptodate() would
> have crashed.
>
next prev parent reply other threads:[~2023-01-20 20:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-19 21:14 [PATCH 0/9] convert hugetlb fault functions to folios Sidhartha Kumar
2023-01-19 21:14 ` [PATCH 1/9] mm/hugetlb: convert hugetlb_install_page " Sidhartha Kumar
2023-01-20 23:21 ` Mike Kravetz
2023-01-19 21:14 ` [PATCH 2/9] mm/hugetlb: convert hugetlbfs_pagecache_present() " Sidhartha Kumar
2023-01-20 5:43 ` Matthew Wilcox
2023-01-20 23:40 ` Mike Kravetz
2023-01-19 21:14 ` [PATCH 3/9] mm/hugetlb: convert putback_active_hugepage to take in a folio Sidhartha Kumar
2023-01-20 5:48 ` Matthew Wilcox
2023-01-20 23:47 ` Mike Kravetz
2023-01-19 21:14 ` [PATCH 4/9] mm/rmap: change hugepage_add_new_anon_rmap " Sidhartha Kumar
2023-01-20 6:00 ` Matthew Wilcox
2023-01-20 20:45 ` Sidhartha Kumar [this message]
2023-01-20 21:17 ` Matthew Wilcox
2023-01-20 22:05 ` Sidhartha Kumar
2023-01-19 21:14 ` [PATCH 5/9] mm/hugetlb: convert alloc_huge_page to alloc_hugetlb_folio Sidhartha Kumar
2023-01-19 21:14 ` [PATCH 6/9] mm/hugetlb: convert restore_reserve_on_error to take in a folio Sidhartha Kumar
2023-01-19 21:14 ` [PATCH 7/9] mm/hugetlb: convert hugetlb_add_to_page_cache " Sidhartha Kumar
2023-01-19 21:14 ` [PATCH 8/9] mm/hugetlb: convert hugetlb_wp() " Sidhartha Kumar
2023-01-24 15:23 ` Gerald Schaefer
2023-01-24 18:38 ` Sidhartha Kumar
2023-01-19 21:14 ` [PATCH 9/9] Documentation/mm: update hugetlbfs documentation to mention alloc_hugetlb_folio Sidhartha Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9c276d01-379f-9bd7-0a7a-6a831b7b4571@oracle.com \
--to=sidhartha.kumar@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=songmuchun@bytedance.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox