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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPcyv4hodnCFEy8iyb3jQPJ=TNj-L2uZQKJqb7JTqSv=YE0BDg@mail.gmail.com>
Date:   Mon, 22 May 2017 12:29:53 -0700
From:   Dan Williams <dan.j.williams@...el.com>
To:     Jérôme Glisse <jglisse@...hat.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Linux MM <linux-mm@...ck.org>,
        John Hubbard <jhubbard@...dia.com>,
        David Nellans <dnellans@...dia.com>,
        "Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
        Ross Zwisler <ross.zwisler@...ux.intel.com>
Subject: Re: [HMM 08/15] mm/ZONE_DEVICE: special case put_page() for device
 private pages

On Mon, May 22, 2017 at 9:51 AM, Jérôme Glisse <jglisse@...hat.com> wrote:
> A ZONE_DEVICE page that reach a refcount of 1 is free ie no longer
> have any user. For device private pages this is important to catch
> and thus we need to special case put_page() for this.
>
> Signed-off-by: Jérôme Glisse <jglisse@...hat.com>
> Cc: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
> Cc: Dan Williams <dan.j.williams@...el.com>
> Cc: Ross Zwisler <ross.zwisler@...ux.intel.com>
> ---
>  include/linux/mm.h | 30 ++++++++++++++++++++++++++++++
>  kernel/memremap.c  |  1 -
>  2 files changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index a825dab..11f7bac 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -23,6 +23,7 @@
>  #include <linux/page_ext.h>
>  #include <linux/err.h>
>  #include <linux/page_ref.h>
> +#include <linux/memremap.h>
>
>  struct mempolicy;
>  struct anon_vma;
> @@ -795,6 +796,20 @@ static inline bool is_device_private_page(const struct page *page)
>         return ((page_zonenum(page) == ZONE_DEVICE) &&
>                 (page->pgmap->type == MEMORY_DEVICE_PRIVATE));
>  }
> +
> +static inline void put_zone_device_private_page(struct page *page)
> +{
> +       int count = page_ref_dec_return(page);
> +
> +       /*
> +        * If refcount is 1 then page is freed and refcount is stable as nobody
> +        * holds a reference on the page.
> +        */
> +       if (count == 1)
> +               page->pgmap->page_free(page, page->pgmap->data);
> +       else if (!count)
> +               __put_page(page);
> +}
>  #else
>  static inline bool is_zone_device_page(const struct page *page)
>  {
> @@ -805,6 +820,10 @@ static inline bool is_device_private_page(const struct page *page)
>  {
>         return false;
>  }
> +
> +static inline void put_zone_device_private_page(struct page *page)
> +{
> +}
>  #endif
>
>  static inline void get_page(struct page *page)
> @@ -822,6 +841,17 @@ static inline void put_page(struct page *page)
>  {
>         page = compound_head(page);
>
> +       /*
> +        * For private device pages we need to catch refcount transition from
> +        * 2 to 1, when refcount reach one it means the private device page is
> +        * free and we need to inform the device driver through callback. See
> +        * include/linux/memremap.h and HMM for details.
> +        */
> +       if (unlikely(is_device_private_page(page))) {

Since I presume HMM is a niche use case can we make this a
"static_branch_unlikely(&hmm_key) && is_device_private_page(page))"?
That way non-hmm platforms see minimal overhead.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ