lkml.org 
[lkml]   [2022]   [Jun]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC PATCH 03/26] hugetlb: add make_huge_pte_with_shift
From

On 24/06/22 11:06 pm, James Houghton wrote:
> This allows us to make huge PTEs at shifts other than the hstate shift,
> which will be necessary for high-granularity mappings.
>
> Signed-off-by: James Houghton <jthoughton@google.com>
> ---
> mm/hugetlb.c | 33 ++++++++++++++++++++-------------
> 1 file changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 5df838d86f32..0eec34edf3b2 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -4686,23 +4686,30 @@ const struct vm_operations_struct hugetlb_vm_ops = {
> .pagesize = hugetlb_vm_op_pagesize,
> };
reviewed-by: manish.mishra@nutanix.com
>
> +static pte_t make_huge_pte_with_shift(struct vm_area_struct *vma,
> + struct page *page, int writable,
> + int shift)
> +{
> + bool huge = shift > PAGE_SHIFT;
> + pte_t entry = huge ? mk_huge_pte(page, vma->vm_page_prot)
> + : mk_pte(page, vma->vm_page_prot);
> +
> + if (writable)
> + entry = huge ? huge_pte_mkwrite(entry) : pte_mkwrite(entry);
> + else
> + entry = huge ? huge_pte_wrprotect(entry) : pte_wrprotect(entry);
> + pte_mkyoung(entry);
> + if (huge)
> + entry = arch_make_huge_pte(entry, shift, vma->vm_flags);
> + return entry;
> +}
> +
> static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page,
> - int writable)
> + int writable)
> {
> - pte_t entry;
> unsigned int shift = huge_page_shift(hstate_vma(vma));
>
> - if (writable) {
> - entry = huge_pte_mkwrite(huge_pte_mkdirty(mk_huge_pte(page,
> - vma->vm_page_prot)));
> - } else {
> - entry = huge_pte_wrprotect(mk_huge_pte(page,
> - vma->vm_page_prot));
> - }
> - entry = pte_mkyoung(entry);
> - entry = arch_make_huge_pte(entry, shift, vma->vm_flags);
> -
> - return entry;
> + return make_huge_pte_with_shift(vma, page, writable, shift);
> }
>
> static void set_huge_ptep_writable(struct vm_area_struct *vma,

\
 
 \ /
  Last update: 2022-06-27 14:15    [W:0.387 / U:0.776 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site