Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1647394
| From | Jerome Glisse <jglisse@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [HMM 08/15] mm/ZONE_DEVICE: special case put_page() for device private pages |
| Date | 2017-05-22 23:20 +0200 |
| Message-ID | <tK2U9-2m2-1@gated-at.bofh.it> (permalink) |
| References | <tJYQx-8az-5@gated-at.bofh.it> <tJYQx-8az-3@gated-at.bofh.it> <tK1ln-1kI-1@gated-at.bofh.it> <tK1Y5-1N3-3@gated-at.bofh.it> <tK27M-1Q5-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, May 22, 2017 at 01:22:22PM -0700, Hugh Dickins wrote:
> On Mon, 22 May 2017, Jerome Glisse wrote:
> > On Mon, May 22, 2017 at 12:29:53PM -0700, Dan Williams wrote:
> > > On Mon, May 22, 2017 at 9:51 AM, Jerome Glisse <jglisse@redhat.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: Jerome Glisse <jglisse@redhat.com>
> > > > Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> > > > Cc: Dan Williams <dan.j.williams@intel.com>
> > > > Cc: Ross Zwisler <ross.zwisler@linux.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);
> > > > +}
>
> Is there something else in this patchset that guarantees
> that get_page_unless_zero() is never used on thse pages?
> We have plenty of code that knows that refcount 0 is special:
> having to know that refcount 1 may be special is worrying.
>
> Hugh
ZONE_DEVICE pages always had this extra refcount since their
inception. All the place that use get_page_unless_zero() should
be unreachable by a ZONE_DEVICE pages (hwpoison, lru, isolate,
ksm, ...). So if that happens it is a bug.
Jérôme
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[HMM 08/15] mm/ZONE_DEVICE: special case put_page() for device private pages Jérôme Glisse <jglisse@redhat.com> - 2017-05-22 19:00 +0200
Re: [HMM 08/15] mm/ZONE_DEVICE: special case put_page() for device private pages Dan Williams <dan.j.williams@intel.com> - 2017-05-22 21:40 +0200
Re: [HMM 08/15] mm/ZONE_DEVICE: special case put_page() for device private pages Jerome Glisse <jglisse@redhat.com> - 2017-05-22 22:20 +0200
Re: [HMM 08/15] mm/ZONE_DEVICE: special case put_page() for device private pages Dan Williams <dan.j.williams@intel.com> - 2017-05-22 22:20 +0200
Re: [HMM 08/15] mm/ZONE_DEVICE: special case put_page() for device private pages Jerome Glisse <jglisse@redhat.com> - 2017-05-22 23:20 +0200
Re: [HMM 08/15] mm/ZONE_DEVICE: special case put_page() for device private pages Hugh Dickins <hughd@google.com> - 2017-05-22 22:30 +0200
Re: [HMM 08/15] mm/ZONE_DEVICE: special case put_page() for device private pages Jerome Glisse <jglisse@redhat.com> - 2017-05-22 23:20 +0200
Re: [HMM 08/15] mm/ZONE_DEVICE: special case put_page() for device private pages "Kirill A. Shutemov" <kirill@shutemov.name> - 2017-05-23 15:30 +0200
[HMM 08/18] mm/ZONE_DEVICE: special case put_page() for device private pages v2 Jérôme Glisse <jglisse@redhat.com> - 2017-05-23 23:40 +0200
csiph-web