diff mbox

[v6,06/13] mm, dev_pagemap: Do not clear ->mapping on final put

Message ID 153154380137.34503.3754023882460956800.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Williams July 14, 2018, 4:50 a.m. UTC
MEMORY_DEVICE_FS_DAX relies on typical page semantics whereby ->mapping
is only ever cleared by truncation, not final put.

Without this fix dax pages may forget their mapping association at the
end of every page pin event.

Move this atypical behavior that HMM wants into the HMM ->page_free()
callback.

Cc: <stable@vger.kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Fixes: d2c997c0f145 ("fs, dax: use page->mapping...")
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 kernel/memremap.c |    1 -
 mm/hmm.c          |    2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

Comments

Dave Jiang July 23, 2018, 4:12 p.m. UTC | #1
Jerome,
Is it possible to get an ack for this? Thanks!

On 07/13/2018 09:50 PM, Dan Williams wrote:
> MEMORY_DEVICE_FS_DAX relies on typical page semantics whereby ->mapping
> is only ever cleared by truncation, not final put.
> 
> Without this fix dax pages may forget their mapping association at the
> end of every page pin event.
> 
> Move this atypical behavior that HMM wants into the HMM ->page_free()
> callback.
> 
> Cc: <stable@vger.kernel.org>
> Cc: Jan Kara <jack@suse.cz>
> Cc: Jérôme Glisse <jglisse@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
> Fixes: d2c997c0f145 ("fs, dax: use page->mapping...")
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  kernel/memremap.c |    1 -
>  mm/hmm.c          |    2 ++
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/memremap.c b/kernel/memremap.c
> index 5857267a4af5..62603634a1d2 100644
> --- a/kernel/memremap.c
> +++ b/kernel/memremap.c
> @@ -339,7 +339,6 @@ void __put_devmap_managed_page(struct page *page)
>  		__ClearPageActive(page);
>  		__ClearPageWaiters(page);
>  
> -		page->mapping = NULL;
>  		mem_cgroup_uncharge(page);
>  
>  		page->pgmap->page_free(page, page->pgmap->data);
> diff --git a/mm/hmm.c b/mm/hmm.c
> index de7b6bf77201..f9d1d89dec4d 100644
> --- a/mm/hmm.c
> +++ b/mm/hmm.c
> @@ -963,6 +963,8 @@ static void hmm_devmem_free(struct page *page, void *data)
>  {
>  	struct hmm_devmem *devmem = data;
>  
> +	page->mapping = NULL;
> +
>  	devmem->ops->free(devmem, page);
>  }
>  
> 
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm
>
Jerome Glisse July 23, 2018, 4:23 p.m. UTC | #2
On Mon, Jul 23, 2018 at 09:12:06AM -0700, Dave Jiang wrote:
> Jerome,
> Is it possible to get an ack for this? Thanks!
> 
> On 07/13/2018 09:50 PM, Dan Williams wrote:
> > MEMORY_DEVICE_FS_DAX relies on typical page semantics whereby ->mapping
> > is only ever cleared by truncation, not final put.
> > 
> > Without this fix dax pages may forget their mapping association at the
> > end of every page pin event.
> > 
> > Move this atypical behavior that HMM wants into the HMM ->page_free()
> > callback.
> > 
> > Cc: <stable@vger.kernel.org>
> > Cc: Jan Kara <jack@suse.cz>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
> > Fixes: d2c997c0f145 ("fs, dax: use page->mapping...")
> > Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Acked-by: Jérôme Glisse <jglisse@redhat.com>

> > ---
> >  kernel/memremap.c |    1 -
> >  mm/hmm.c          |    2 ++
> >  2 files changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/kernel/memremap.c b/kernel/memremap.c
> > index 5857267a4af5..62603634a1d2 100644
> > --- a/kernel/memremap.c
> > +++ b/kernel/memremap.c
> > @@ -339,7 +339,6 @@ void __put_devmap_managed_page(struct page *page)
> >  		__ClearPageActive(page);
> >  		__ClearPageWaiters(page);
> >  
> > -		page->mapping = NULL;
> >  		mem_cgroup_uncharge(page);
> >  
> >  		page->pgmap->page_free(page, page->pgmap->data);
> > diff --git a/mm/hmm.c b/mm/hmm.c
> > index de7b6bf77201..f9d1d89dec4d 100644
> > --- a/mm/hmm.c
> > +++ b/mm/hmm.c
> > @@ -963,6 +963,8 @@ static void hmm_devmem_free(struct page *page, void *data)
> >  {
> >  	struct hmm_devmem *devmem = data;
> >  
> > +	page->mapping = NULL;
> > +
> >  	devmem->ops->free(devmem, page);
> >  }
> >  
> > 
> > _______________________________________________
> > Linux-nvdimm mailing list
> > Linux-nvdimm@lists.01.org
> > https://lists.01.org/mailman/listinfo/linux-nvdimm
> >
diff mbox

Patch

diff --git a/kernel/memremap.c b/kernel/memremap.c
index 5857267a4af5..62603634a1d2 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -339,7 +339,6 @@  void __put_devmap_managed_page(struct page *page)
 		__ClearPageActive(page);
 		__ClearPageWaiters(page);
 
-		page->mapping = NULL;
 		mem_cgroup_uncharge(page);
 
 		page->pgmap->page_free(page, page->pgmap->data);
diff --git a/mm/hmm.c b/mm/hmm.c
index de7b6bf77201..f9d1d89dec4d 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -963,6 +963,8 @@  static void hmm_devmem_free(struct page *page, void *data)
 {
 	struct hmm_devmem *devmem = data;
 
+	page->mapping = NULL;
+
 	devmem->ops->free(devmem, page);
 }