lkml.org 
[lkml]   [2023]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 13/46] hugetlb: add hugetlb_hgm_walk and hugetlb_walk_step
On Thu, Jan 05, 2023 at 10:18:11AM +0000, James Houghton wrote:

[...]

> +static int hugetlb_hgm_walk_uninit(struct hugetlb_pte *hpte,

Nitpick on the name: the "uninit" can be misread into pairing with some
other "init()" calls..

How about just call it hugetlb_hgm_walk (since it's the higher level API
comparing to the existing one)? Then the existing hugetlb_hgm_walk can be
called hugetlb_hgm_do_walk/__hugetlb_hgm_walk since it's one level down.

> + pte_t *ptep,
> + struct vm_area_struct *vma,
> + unsigned long addr,
> + unsigned long target_sz,
> + bool alloc)
> +{
> + struct hstate *h = hstate_vma(vma);
> +
> + hugetlb_pte_populate(vma->vm_mm, hpte, ptep, huge_page_shift(h),
> + hpage_size_to_level(huge_page_size(h)));

Another nitpick on name: I remembered we used to reach a consensus of using
hugetlb_pte_init before? Can we still avoid the word "populate" (if "init"
is not suitable since it can be updated during stepping, how about "setup")?

[...]

> +int hugetlb_walk_step(struct mm_struct *mm, struct hugetlb_pte *hpte,
> + unsigned long addr, unsigned long sz)
> +{
> + pte_t *ptep;
> + spinlock_t *ptl;
> +
> + switch (hpte->level) {
> + case HUGETLB_LEVEL_PUD:
> + ptep = (pte_t *)hugetlb_alloc_pmd(mm, hpte, addr);
> + if (IS_ERR(ptep))
> + return PTR_ERR(ptep);
> + hugetlb_pte_populate(mm, hpte, ptep, PMD_SHIFT,
> + HUGETLB_LEVEL_PMD);
> + break;
> + case HUGETLB_LEVEL_PMD:
> + ptep = hugetlb_alloc_pte(mm, hpte, addr);
> + if (IS_ERR(ptep))
> + return PTR_ERR(ptep);
> + ptl = pte_lockptr(mm, (pmd_t *)hpte->ptep);
> + __hugetlb_pte_populate(hpte, ptep, PAGE_SHIFT,
> + HUGETLB_LEVEL_PTE, ptl);
> + hpte->ptl = ptl;

This line seems to be superfluous (even if benign).

> + break;
> + default:
> + WARN_ONCE(1, "%s: got invalid level: %d (shift: %d)\n",
> + __func__, hpte->level, hpte->shift);
> + return -EINVAL;
> + }
> + return 0;
> +}
> +
> /*
> * Return a mask that can be used to update an address to the last huge
> * page in a page table page mapping size. Used to skip non-present
> --
> 2.39.0.314.g84b9a713c41-goog
>

--
Peter Xu

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