Re: [PATCH mm-unstable 3/4] mm/khugepaged: delay computation of hpage boundaries until use

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 20, 2022 at 7:06 AM Zach O'Keefe <zokeefe@xxxxxxxxxx> wrote:
>
> Only compute hstart/hend once we've passed all checks that would
> cause early return in madvise_collapse().
>
> Fixes: c9d968ffd9ba ("mm/madvise: introduce MADV_COLLAPSE sync hugepage collapse")
> Signed-off-by: Zach O'Keefe <zokeefe@xxxxxxxxxx>

Reviewed-by: Yang Shi <shy828301@xxxxxxxxx>


> ---
>  mm/khugepaged.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 290422577172..70e9d9950415 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -2417,9 +2417,6 @@ int madvise_collapse(struct vm_area_struct *vma, struct vm_area_struct **prev,
>         if (!vma->anon_vma || !vma_is_anonymous(vma))
>                 return -EINVAL;
>
> -       hstart = (start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK;
> -       hend = end & HPAGE_PMD_MASK;
> -
>         if (!hugepage_vma_check(vma, vma->vm_flags, false, false, false))
>                 return -EINVAL;
>
> @@ -2432,6 +2429,9 @@ int madvise_collapse(struct vm_area_struct *vma, struct vm_area_struct **prev,
>         mmgrab(mm);
>         lru_add_drain_all();
>
> +       hstart = (start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK;
> +       hend = end & HPAGE_PMD_MASK;
> +
>         for (addr = hstart; addr < hend; addr += HPAGE_PMD_SIZE) {
>                 int result = SCAN_FAIL;
>
> --
> 2.37.0.170.g444d1eabd0-goog
>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux