linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: fix insert_pfn() return value
@ 2018-11-27 14:43 Mans Rullgard
  2018-11-27 15:08 ` Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: Mans Rullgard @ 2018-11-27 14:43 UTC (permalink / raw)
  To: linux-mm; +Cc: linux-kernel

Commit 9b5a8e00d479 ("mm: convert insert_pfn() to vm_fault_t") accidentally
made insert_pfn() always return an error.  Fix this.

Fixes: 9b5a8e00d479 ("mm: convert insert_pfn() to vm_fault_t")
Signed-off-by: Mans Rullgard <mans@mansr.com>
---
 mm/memory.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/memory.c b/mm/memory.c
index 4ad2d293ddc2..15baf50e3908 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1524,12 +1524,14 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
 			pfn_t pfn, pgprot_t prot, bool mkwrite)
 {
 	struct mm_struct *mm = vma->vm_mm;
+	int retval;
 	pte_t *pte, entry;
 	spinlock_t *ptl;
 
 	pte = get_locked_pte(mm, addr, &ptl);
 	if (!pte)
 		return VM_FAULT_OOM;
+	retval = VM_FAULT_NOPAGE;
 	if (!pte_none(*pte)) {
 		if (mkwrite) {
 			/*
@@ -1567,9 +1569,10 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
 	set_pte_at(mm, addr, pte, entry);
 	update_mmu_cache(vma, addr, pte); /* XXX: why not for insert_page? */
 
+	retval = 0;
 out_unlock:
 	pte_unmap_unlock(pte, ptl);
-	return VM_FAULT_NOPAGE;
+	return retval;
 }
 
 /**
-- 
2.19.2


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

* Re: [PATCH] mm: fix insert_pfn() return value
  2018-11-27 14:43 [PATCH] mm: fix insert_pfn() return value Mans Rullgard
@ 2018-11-27 15:08 ` Matthew Wilcox
  2018-11-27 15:20   ` Måns Rullgård
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2018-11-27 15:08 UTC (permalink / raw)
  To: Mans Rullgard; +Cc: linux-mm, linux-kernel

On Tue, Nov 27, 2018 at 02:43:51PM +0000, Mans Rullgard wrote:
> Commit 9b5a8e00d479 ("mm: convert insert_pfn() to vm_fault_t") accidentally
> made insert_pfn() always return an error.  Fix this.

Umm.  VM_FAULT_NOPAGE is not an error.  It's saying "I inserted the PFN,
there's no struct page for the core VM to do anything with".  Which is
the correct response from a device driver which has called insert_pfn().

Could you explain a bit more what led you to think there's a problem here?

Also, rather rude of you not to cc the patch author when you claim to
be fixing a bug in their patch.

> Fixes: 9b5a8e00d479 ("mm: convert insert_pfn() to vm_fault_t")
> Signed-off-by: Mans Rullgard <mans@mansr.com>
> ---
>  mm/memory.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/memory.c b/mm/memory.c
> index 4ad2d293ddc2..15baf50e3908 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -1524,12 +1524,14 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
>  			pfn_t pfn, pgprot_t prot, bool mkwrite)
>  {
>  	struct mm_struct *mm = vma->vm_mm;
> +	int retval;
>  	pte_t *pte, entry;
>  	spinlock_t *ptl;
>  
>  	pte = get_locked_pte(mm, addr, &ptl);
>  	if (!pte)
>  		return VM_FAULT_OOM;
> +	retval = VM_FAULT_NOPAGE;
>  	if (!pte_none(*pte)) {
>  		if (mkwrite) {
>  			/*
> @@ -1567,9 +1569,10 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
>  	set_pte_at(mm, addr, pte, entry);
>  	update_mmu_cache(vma, addr, pte); /* XXX: why not for insert_page? */
>  
> +	retval = 0;
>  out_unlock:
>  	pte_unmap_unlock(pte, ptl);
> -	return VM_FAULT_NOPAGE;
> +	return retval;
>  }
>  
>  /**
> -- 
> 2.19.2
> 

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

* Re: [PATCH] mm: fix insert_pfn() return value
  2018-11-27 15:08 ` Matthew Wilcox
@ 2018-11-27 15:20   ` Måns Rullgård
  0 siblings, 0 replies; 3+ messages in thread
From: Måns Rullgård @ 2018-11-27 15:20 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-mm, linux-kernel

Matthew Wilcox <willy@infradead.org> writes:

> On Tue, Nov 27, 2018 at 02:43:51PM +0000, Mans Rullgard wrote:
>> Commit 9b5a8e00d479 ("mm: convert insert_pfn() to vm_fault_t") accidentally
>> made insert_pfn() always return an error.  Fix this.
>
> Umm.  VM_FAULT_NOPAGE is not an error.  It's saying "I inserted the PFN,
> there's no struct page for the core VM to do anything with".  Which is
> the correct response from a device driver which has called insert_pfn().
>
> Could you explain a bit more what led you to think there's a problem here?

Apparently some (not in mainline) driver code had been hastily converted
to the vm_fault_t codes, and that is where the error is.  Sorry for the
noise.  Please disregard this.

(The quickest way to get the correct answer is still to send a bad
patch.)

> Also, rather rude of you not to cc the patch author when you claim to
> be fixing a bug in their patch.

Sorry about that.  Blame the get-maintainers script.

-- 
Måns Rullgård

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

end of thread, other threads:[~2018-11-27 15:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-27 14:43 [PATCH] mm: fix insert_pfn() return value Mans Rullgard
2018-11-27 15:08 ` Matthew Wilcox
2018-11-27 15:20   ` Måns Rullgård

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).