diff mbox series

[1/2] mm/hmm: support automatic NUMA balancing

Message ID 20190510195258.9930-2-Felix.Kuehling@amd.com (mailing list archive)
State New, archived
Headers show
Series Two bug-fixes for HMM | expand

Commit Message

Felix Kuehling May 10, 2019, 7:53 p.m. UTC
From: Philip Yang <Philip.Yang@amd.com>

While the page is migrating by NUMA balancing, HMM failed to detect this
condition and still return the old page. Application will use the new
page migrated, but driver pass the old page physical address to GPU,
this crash the application later.

Use pte_protnone(pte) to return this condition and then hmm_vma_do_fault
will allocate new page.

Signed-off-by: Philip Yang <Philip.Yang@amd.com>
---
 mm/hmm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jerome Glisse May 10, 2019, 8:13 p.m. UTC | #1
On Fri, May 10, 2019 at 07:53:23PM +0000, Kuehling, Felix wrote:
> From: Philip Yang <Philip.Yang@amd.com>
> 
> While the page is migrating by NUMA balancing, HMM failed to detect this
> condition and still return the old page. Application will use the new
> page migrated, but driver pass the old page physical address to GPU,
> this crash the application later.
> 
> Use pte_protnone(pte) to return this condition and then hmm_vma_do_fault
> will allocate new page.
> 
> Signed-off-by: Philip Yang <Philip.Yang@amd.com>

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

> ---
>  mm/hmm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/hmm.c b/mm/hmm.c
> index 75d2ea906efb..b65c27d5c119 100644
> --- a/mm/hmm.c
> +++ b/mm/hmm.c
> @@ -554,7 +554,7 @@ static int hmm_vma_handle_pmd(struct mm_walk *walk,
>  
>  static inline uint64_t pte_to_hmm_pfn_flags(struct hmm_range *range, pte_t pte)
>  {
> -	if (pte_none(pte) || !pte_present(pte))
> +	if (pte_none(pte) || !pte_present(pte) || pte_protnone(pte))
>  		return 0;
>  	return pte_write(pte) ? range->flags[HMM_PFN_VALID] |
>  				range->flags[HMM_PFN_WRITE] :
> -- 
> 2.17.1
>
Andrew Morton May 13, 2019, 9:27 p.m. UTC | #2
On Fri, 10 May 2019 19:53:23 +0000 "Kuehling, Felix" <Felix.Kuehling@amd.com> wrote:

> From: Philip Yang <Philip.Yang@amd.com>
> 
> While the page is migrating by NUMA balancing, HMM failed to detect this
> condition and still return the old page. Application will use the new
> page migrated, but driver pass the old page physical address to GPU,
> this crash the application later.
> 
> Use pte_protnone(pte) to return this condition and then hmm_vma_do_fault
> will allocate new page.
> 
> Signed-off-by: Philip Yang <Philip.Yang@amd.com>

This should have included your signed-off-by:, since you were on the
patch delivery path.  I'll make that change to my copy of the patch,
OK?
Jerome Glisse May 13, 2019, 10:37 p.m. UTC | #3
On Mon, May 13, 2019 at 02:27:20PM -0700, Andrew Morton wrote:
> On Fri, 10 May 2019 19:53:23 +0000 "Kuehling, Felix" <Felix.Kuehling@amd.com> wrote:
> 
> > From: Philip Yang <Philip.Yang@amd.com>
> > 
> > While the page is migrating by NUMA balancing, HMM failed to detect this
> > condition and still return the old page. Application will use the new
> > page migrated, but driver pass the old page physical address to GPU,
> > this crash the application later.
> > 
> > Use pte_protnone(pte) to return this condition and then hmm_vma_do_fault
> > will allocate new page.
> > 
> > Signed-off-by: Philip Yang <Philip.Yang@amd.com>
> 
> This should have included your signed-off-by:, since you were on the
> patch delivery path.  I'll make that change to my copy of the patch,
> OK?

Yes it should have included that.
Felix Kuehling May 14, 2019, 9:14 p.m. UTC | #4
On 2019-05-13 5:27 p.m., Andrew Morton wrote:
> [CAUTION: External Email]
>
> On Fri, 10 May 2019 19:53:23 +0000 "Kuehling, Felix" <Felix.Kuehling@amd.com> wrote:
>
>> From: Philip Yang <Philip.Yang@amd.com>
>>
>> While the page is migrating by NUMA balancing, HMM failed to detect this
>> condition and still return the old page. Application will use the new
>> page migrated, but driver pass the old page physical address to GPU,
>> this crash the application later.
>>
>> Use pte_protnone(pte) to return this condition and then hmm_vma_do_fault
>> will allocate new page.
>>
>> Signed-off-by: Philip Yang <Philip.Yang@amd.com>
> This should have included your signed-off-by:, since you were on the
> patch delivery path.  I'll make that change to my copy of the patch,
> OK?
>
Yes. Thanks!
diff mbox series

Patch

diff --git a/mm/hmm.c b/mm/hmm.c
index 75d2ea906efb..b65c27d5c119 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -554,7 +554,7 @@  static int hmm_vma_handle_pmd(struct mm_walk *walk,
 
 static inline uint64_t pte_to_hmm_pfn_flags(struct hmm_range *range, pte_t pte)
 {
-	if (pte_none(pte) || !pte_present(pte))
+	if (pte_none(pte) || !pte_present(pte) || pte_protnone(pte))
 		return 0;
 	return pte_write(pte) ? range->flags[HMM_PFN_VALID] |
 				range->flags[HMM_PFN_WRITE] :