Message ID | 74a9fc9e018e54d7afbeae166479e2358e0a1225.1719386613.git-series.apopple@nvidia.com (mailing list archive) |
---|---|
State | Accepted, archived |
Headers | show |
Series | fs/dax: Fix FS DAX page reference counts | expand |
On 27.06.24 02:54, Alistair Popple wrote: > Longterm pinning of FS DAX pages should already be disallowed by > various pXX_devmap checks. However a future change will cause these > checks to be invalid for FS DAX pages so make > folio_is_longterm_pinnable() return false for FS DAX pages. > > Signed-off-by: Alistair Popple <apopple@nvidia.com> > --- > include/linux/memremap.h | 11 +++++++++++ > include/linux/mm.h | 4 ++++ > 2 files changed, 15 insertions(+) > > diff --git a/include/linux/memremap.h b/include/linux/memremap.h > index 6505713..19a448e 100644 > --- a/include/linux/memremap.h > +++ b/include/linux/memremap.h > @@ -193,6 +193,17 @@ static inline bool folio_is_device_coherent(const struct folio *folio) > return is_device_coherent_page(&folio->page); > } > > +static inline bool is_device_dax_page(const struct page *page) > +{ > + return is_zone_device_page(page) && > + page_dev_pagemap(page)->type == MEMORY_DEVICE_FS_DAX; > +} > + > +static inline bool folio_is_device_dax(const struct folio *folio) > +{ > + return is_device_dax_page(&folio->page); > +} > + > #ifdef CONFIG_ZONE_DEVICE > void zone_device_page_init(struct page *page); > void *memremap_pages(struct dev_pagemap *pgmap, int nid); > diff --git a/include/linux/mm.h b/include/linux/mm.h > index b84368b..4d1cdea 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -2032,6 +2032,10 @@ static inline bool folio_is_longterm_pinnable(struct folio *folio) > if (folio_is_device_coherent(folio)) > return false; > > + /* DAX must also always allow eviction. */ > + if (folio_is_device_dax(folio)) > + return false; > + > /* Otherwise, non-movable zone folios can be pinned. */ > return !folio_is_zone_movable(folio); > Why is the check in check_vma_flags() insufficient? GUP-fast maybe?
David Hildenbrand <david@redhat.com> writes: > On 27.06.24 02:54, Alistair Popple wrote: >> Longterm pinning of FS DAX pages should already be disallowed by >> various pXX_devmap checks. However a future change will cause these >> checks to be invalid for FS DAX pages so make >> folio_is_longterm_pinnable() return false for FS DAX pages. >> Signed-off-by: Alistair Popple <apopple@nvidia.com> >> --- >> include/linux/memremap.h | 11 +++++++++++ >> include/linux/mm.h | 4 ++++ >> 2 files changed, 15 insertions(+) >> diff --git a/include/linux/memremap.h b/include/linux/memremap.h >> index 6505713..19a448e 100644 >> --- a/include/linux/memremap.h >> +++ b/include/linux/memremap.h >> @@ -193,6 +193,17 @@ static inline bool folio_is_device_coherent(const struct folio *folio) >> return is_device_coherent_page(&folio->page); >> } >> +static inline bool is_device_dax_page(const struct page *page) >> +{ >> + return is_zone_device_page(page) && >> + page_dev_pagemap(page)->type == MEMORY_DEVICE_FS_DAX; >> +} >> + >> +static inline bool folio_is_device_dax(const struct folio *folio) >> +{ >> + return is_device_dax_page(&folio->page); >> +} >> + >> #ifdef CONFIG_ZONE_DEVICE >> void zone_device_page_init(struct page *page); >> void *memremap_pages(struct dev_pagemap *pgmap, int nid); >> diff --git a/include/linux/mm.h b/include/linux/mm.h >> index b84368b..4d1cdea 100644 >> --- a/include/linux/mm.h >> +++ b/include/linux/mm.h >> @@ -2032,6 +2032,10 @@ static inline bool folio_is_longterm_pinnable(struct folio *folio) >> if (folio_is_device_coherent(folio)) >> return false; >> + /* DAX must also always allow eviction. */ >> + if (folio_is_device_dax(folio)) >> + return false; >> + >> /* Otherwise, non-movable zone folios can be pinned. */ >> return !folio_is_zone_movable(folio); >> > > Why is the check in check_vma_flags() insufficient? GUP-fast maybe? Right. This came up when I was changing the code for GUP-fast, but also they shouldn't be longterm pinnable and adding the case to folio_is_longterm_pinnable() is an excellent way of documenting that.
On 02.07.24 01:47, Alistair Popple wrote: > > David Hildenbrand <david@redhat.com> writes: > >> On 27.06.24 02:54, Alistair Popple wrote: >>> Longterm pinning of FS DAX pages should already be disallowed by >>> various pXX_devmap checks. However a future change will cause these >>> checks to be invalid for FS DAX pages so make >>> folio_is_longterm_pinnable() return false for FS DAX pages. >>> Signed-off-by: Alistair Popple <apopple@nvidia.com> >>> --- >>> include/linux/memremap.h | 11 +++++++++++ >>> include/linux/mm.h | 4 ++++ >>> 2 files changed, 15 insertions(+) >>> diff --git a/include/linux/memremap.h b/include/linux/memremap.h >>> index 6505713..19a448e 100644 >>> --- a/include/linux/memremap.h >>> +++ b/include/linux/memremap.h >>> @@ -193,6 +193,17 @@ static inline bool folio_is_device_coherent(const struct folio *folio) >>> return is_device_coherent_page(&folio->page); >>> } >>> +static inline bool is_device_dax_page(const struct page *page) >>> +{ >>> + return is_zone_device_page(page) && >>> + page_dev_pagemap(page)->type == MEMORY_DEVICE_FS_DAX; >>> +} >>> + >>> +static inline bool folio_is_device_dax(const struct folio *folio) >>> +{ >>> + return is_device_dax_page(&folio->page); >>> +} >>> + >>> #ifdef CONFIG_ZONE_DEVICE >>> void zone_device_page_init(struct page *page); >>> void *memremap_pages(struct dev_pagemap *pgmap, int nid); >>> diff --git a/include/linux/mm.h b/include/linux/mm.h >>> index b84368b..4d1cdea 100644 >>> --- a/include/linux/mm.h >>> +++ b/include/linux/mm.h >>> @@ -2032,6 +2032,10 @@ static inline bool folio_is_longterm_pinnable(struct folio *folio) >>> if (folio_is_device_coherent(folio)) >>> return false; >>> + /* DAX must also always allow eviction. */ >>> + if (folio_is_device_dax(folio)) >>> + return false; >>> + >>> /* Otherwise, non-movable zone folios can be pinned. */ >>> return !folio_is_zone_movable(folio); >>> >> >> Why is the check in check_vma_flags() insufficient? GUP-fast maybe? > > Right. This came up when I was changing the code for GUP-fast, but also > they shouldn't be longterm pinnable and adding the case to > folio_is_longterm_pinnable() is an excellent way of documenting that. Makes sense, might be worth adding that (GUP-fast and check_vma_flags() covering GUP-slow) to the patch description.
diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 6505713..19a448e 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -193,6 +193,17 @@ static inline bool folio_is_device_coherent(const struct folio *folio) return is_device_coherent_page(&folio->page); } +static inline bool is_device_dax_page(const struct page *page) +{ + return is_zone_device_page(page) && + page_dev_pagemap(page)->type == MEMORY_DEVICE_FS_DAX; +} + +static inline bool folio_is_device_dax(const struct folio *folio) +{ + return is_device_dax_page(&folio->page); +} + #ifdef CONFIG_ZONE_DEVICE void zone_device_page_init(struct page *page); void *memremap_pages(struct dev_pagemap *pgmap, int nid); diff --git a/include/linux/mm.h b/include/linux/mm.h index b84368b..4d1cdea 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2032,6 +2032,10 @@ static inline bool folio_is_longterm_pinnable(struct folio *folio) if (folio_is_device_coherent(folio)) return false; + /* DAX must also always allow eviction. */ + if (folio_is_device_dax(folio)) + return false; + /* Otherwise, non-movable zone folios can be pinned. */ return !folio_is_zone_movable(folio);
Longterm pinning of FS DAX pages should already be disallowed by various pXX_devmap checks. However a future change will cause these checks to be invalid for FS DAX pages so make folio_is_longterm_pinnable() return false for FS DAX pages. Signed-off-by: Alistair Popple <apopple@nvidia.com> --- include/linux/memremap.h | 11 +++++++++++ include/linux/mm.h | 4 ++++ 2 files changed, 15 insertions(+)