All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/hmm: bypass devmap pte when all pfn requested flags are fulfilled
@ 2021-08-27 14:45 Li Zhijian
  2021-08-27 16:28 ` Jason Gunthorpe
  0 siblings, 1 reply; 3+ messages in thread
From: Li Zhijian @ 2021-08-27 14:45 UTC (permalink / raw)
  To: linux-mm, linux-rdma, akpm, jglisse, jgg
  Cc: yishaih, linux-kernel, Li Zhijian, stable

Previously, we noticed the one rpma example was failed[1] since 36f30e486d,
where it will use ODP feature to do RDMA WRITE between fsdax files.

After digging into the code, we found hmm_vma_handle_pte() will still
return EFAULT even though all the its requesting flags has been
fulfilled. That's because a DAX page will be marked as
(_PAGE_SPECIAL | PAGE_DEVMAP) by pte_mkdevmap().

[1]: https://github.com/pmem/rpma/issues/1142

CC: stable@vger.kernel.org
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
---
 mm/hmm.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mm/hmm.c b/mm/hmm.c
index fad6be2bf072..4766bdefb6c3 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -294,6 +294,12 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr,
 	if (required_fault)
 		goto fault;
 
+	/*
+	 * just bypass devmap pte such as DAX page when all pfn requested
+	 * flags(pfn_req_flags) are fulfilled.
+	 */
+	if (pte_devmap(pte))
+		goto out;
 	/*
 	 * Since each architecture defines a struct page for the zero page, just
 	 * fall through and treat it like a normal page.
@@ -307,6 +313,7 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr,
 		return 0;
 	}
 
+out:
 	*hmm_pfn = pte_pfn(pte) | cpu_flags;
 	return 0;
 
-- 
2.31.1




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/hmm: bypass devmap pte when all pfn requested flags are fulfilled
  2021-08-27 14:45 [PATCH] mm/hmm: bypass devmap pte when all pfn requested flags are fulfilled Li Zhijian
@ 2021-08-27 16:28 ` Jason Gunthorpe
  2021-08-27 17:45   ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Gunthorpe @ 2021-08-27 16:28 UTC (permalink / raw)
  To: Li Zhijian
  Cc: linux-mm, linux-rdma, akpm, jglisse, yishaih, linux-kernel, stable

On Fri, Aug 27, 2021 at 10:45:00PM +0800, Li Zhijian wrote:
> Previously, we noticed the one rpma example was failed[1] since 36f30e486d,
> where it will use ODP feature to do RDMA WRITE between fsdax files.
> 
> After digging into the code, we found hmm_vma_handle_pte() will still
> return EFAULT even though all the its requesting flags has been
> fulfilled. That's because a DAX page will be marked as
> (_PAGE_SPECIAL | PAGE_DEVMAP) by pte_mkdevmap().
> 
> [1]: https://github.com/pmem/rpma/issues/1142
> 
> CC: stable@vger.kernel.org
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>

You need to add a 

Fixes: 405506274922 ("mm/hmm: add missing call to hmm_pte_need_fault in HMM_PFN_SPECIAL handling")

> diff --git a/mm/hmm.c b/mm/hmm.c
> index fad6be2bf072..4766bdefb6c3 100644
> +++ b/mm/hmm.c
> @@ -294,6 +294,12 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr,
>  	if (required_fault)
>  		goto fault;
>  
> +	/*
> +	 * just bypass devmap pte such as DAX page when all pfn requested
> +	 * flags(pfn_req_flags) are fulfilled.
> +	 */
> +	if (pte_devmap(pte))
> +		goto out;

I liked your ealier version better where this was added to the
pte_special test - logically this is about disambiguating the
pte_special and the devmap case as they are different things.

Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/hmm: bypass devmap pte when all pfn requested flags are fulfilled
  2021-08-27 16:28 ` Jason Gunthorpe
@ 2021-08-27 17:45   ` Christoph Hellwig
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2021-08-27 17:45 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Li Zhijian, linux-mm, linux-rdma, akpm, jglisse, yishaih,
	linux-kernel, stable

On Fri, Aug 27, 2021 at 01:28:52PM -0300, Jason Gunthorpe wrote:
> > +	/*
> > +	 * just bypass devmap pte such as DAX page when all pfn requested
> > +	 * flags(pfn_req_flags) are fulfilled.
> > +	 */
> > +	if (pte_devmap(pte))
> > +		goto out;
> 
> I liked your ealier version better where this was added to the
> pte_special test - logically this is about disambiguating the
> pte_special and the devmap case as they are different things.

Yes, I think that is much more logical.  Also please capitalize the
first word in multi-line comments.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-27 17:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27 14:45 [PATCH] mm/hmm: bypass devmap pte when all pfn requested flags are fulfilled Li Zhijian
2021-08-27 16:28 ` Jason Gunthorpe
2021-08-27 17:45   ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.