lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANe_+Ugjtu2zw8i3CyCU3mu71L7Gh_etuj_5t64Bx7y7+fj2jA@mail.gmail.com>
Date:   Sun, 6 Feb 2022 14:52:46 +0000
From:   Mark Hemment <markhemm@...glemail.com>
To:     "Matthew Wilcox (Oracle)" <willy@...radead.org>
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        Christoph Hellwig <hch@....de>,
        John Hubbard <jhubbard@...dia.com>,
        Jason Gunthorpe <jgg@...dia.com>,
        William Kucharski <william.kucharski@...cle.com>
Subject: Re: [PATCH 20/75] mm/gup: Convert gup_pte_range() to use a folio

On Fri, 4 Feb 2022 at 20:21, Matthew Wilcox (Oracle)
<willy@...radead.org> wrote:
>
> We still call try_grab_folio() once per PTE; a future patch could
> optimise to just adjust the reference count for each page within
> the folio.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
> Reviewed-by: Christoph Hellwig <hch@....de>
> Reviewed-by: John Hubbard <jhubbard@...dia.com>
> Reviewed-by: Jason Gunthorpe <jgg@...dia.com>
> Reviewed-by: William Kucharski <william.kucharski@...cle.com>
> ---
>  mm/gup.c | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/mm/gup.c b/mm/gup.c
> index 00227b2cb1cf..44281350db1a 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -2252,7 +2252,8 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end,
>         ptem = ptep = pte_offset_map(&pmd, addr);
>         do {
>                 pte_t pte = ptep_get_lockless(ptep);
> -               struct page *head, *page;
> +               struct page *page;
> +               struct folio *folio;
>
>                 /*
>                  * Similar to the PMD case below, NUMA hinting must take slow
> @@ -2279,22 +2280,20 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end,
>                 VM_BUG_ON(!pfn_valid(pte_pfn(pte)));
>                 page = pte_page(pte);
>
> -               head = try_grab_compound_head(page, 1, flags);
> -               if (!head)
> +               folio = try_grab_folio(page, 1, flags);
> +               if (!folio)
>                         goto pte_unmap;
>
>                 if (unlikely(page_is_secretmem(page))) {
> -                       put_compound_head(head, 1, flags);
> +                       gup_put_folio(folio, 1, flags);
>                         goto pte_unmap;
>                 }
>
>                 if (unlikely(pte_val(pte) != pte_val(*ptep))) {
> -                       put_compound_head(head, 1, flags);
> +                       gup_put_folio(folio, 1, flags);
>                         goto pte_unmap;
>                 }
>
> -               VM_BUG_ON_PAGE(compound_head(page) != head, page);
> -
>                 /*
>                  * We need to make the page accessible if and only if we are
>                  * going to access its content (the FOLL_PIN case).  Please
> @@ -2308,10 +2307,9 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end,
>                                 goto pte_unmap;
>                         }

V. Minor/nit: Above the "goto pte_unmap;" is the code block;
           if (flags & FOLL_PIN) {
                        ret = arch_make_page_accessible(page);
                        if (ret) {
                                unpin_user_page(page);
                                goto pte_unmap;
                        }
                }
Other conditions which goto pte_unmap, after successful
try_grab_folio(), call gup_put_folio() (rather than
unpin_user_page()).
No change in functionality, but suggest calling gup_put_folio() here
too for consistency.

Cheers,
Mark

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ