linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] MIPS/c-r4k: do no use mmap_sem for gup_fast()
       [not found] <20190207053740.26915-1-dave@stgolabs.net>
@ 2019-02-07  5:37 ` Davidlohr Bueso
  2019-02-07 19:00   ` Paul Burton
  0 siblings, 1 reply; 3+ messages in thread
From: Davidlohr Bueso @ 2019-02-07  5:37 UTC (permalink / raw)
  To: akpm
  Cc: linux-mm, dave, linux-kernel, Ralf Baechle, Paul Burton,
	James Hogan, linux-mips, Davidlohr Bueso

It is well known that because the mm can internally
call the regular gup_unlocked if the lockless approach
fails and take the sem there, the caller must not hold
the mmap_sem already.

Fixes: e523f289fe4d (MIPS: c-r4k: Fix sigtramp SMP call to use kmap)
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paul.burton@mips.com>
Cc: James Hogan <jhogan@kernel.org>
Cc: linux-mips@vger.kernel.org
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
 arch/mips/mm/c-r4k.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index cc4e17caeb26..38fe86928837 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -1034,11 +1034,9 @@ static void r4k_flush_cache_sigtramp(unsigned long addr)
 	struct flush_cache_sigtramp_args args;
 	int npages;
 
-	down_read(&current->mm->mmap_sem);
-
 	npages = get_user_pages_fast(addr, 1, 0, &args.page);
 	if (npages < 1)
-		goto out;
+		return;
 
 	args.mm = current->mm;
 	args.addr = addr;
@@ -1046,8 +1044,6 @@ static void r4k_flush_cache_sigtramp(unsigned long addr)
 	r4k_on_each_cpu(R4K_HIT, local_r4k_flush_cache_sigtramp, &args);
 
 	put_page(args.page);
-out:
-	up_read(&current->mm->mmap_sem);
 }
 
 static void r4k_flush_icache_all(void)
-- 
2.16.4


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

* Re: [PATCH 2/2] MIPS/c-r4k: do no use mmap_sem for gup_fast()
  2019-02-07  5:37 ` [PATCH 2/2] MIPS/c-r4k: do no use mmap_sem for gup_fast() Davidlohr Bueso
@ 2019-02-07 19:00   ` Paul Burton
  2019-02-07 19:25     ` Davidlohr Bueso
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Burton @ 2019-02-07 19:00 UTC (permalink / raw)
  To: Davidlohr Bueso
  Cc: akpm, linux-mm, linux-kernel, Ralf Baechle, James Hogan,
	linux-mips, Davidlohr Bueso

Hi Davidlohr,

On Wed, Feb 06, 2019 at 09:37:40PM -0800, Davidlohr Bueso wrote:
> It is well known that because the mm can internally
> call the regular gup_unlocked if the lockless approach
> fails and take the sem there, the caller must not hold
> the mmap_sem already.
> 
> Fixes: e523f289fe4d (MIPS: c-r4k: Fix sigtramp SMP call to use kmap)
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Paul Burton <paul.burton@mips.com>
> Cc: James Hogan <jhogan@kernel.org>
> Cc: linux-mips@vger.kernel.org
> Signed-off-by: Davidlohr Bueso <dbueso@suse.de>

Thanks - this looks good, but:

 1) The problem it fixes was introduced in v4.8.

 2) Commit adcc81f148d7 ("MIPS: math-emu: Write-protect delay slot
    emulation pages") actually left flush_cache_sigtramp unused, and has
    been backported to stable kernels also as far as v4.8.

Therefore this will just fix code that never gets called, and I'll go
delete the whole thing instead.

Thanks,
    Paul

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

* Re: [PATCH 2/2] MIPS/c-r4k: do no use mmap_sem for gup_fast()
  2019-02-07 19:00   ` Paul Burton
@ 2019-02-07 19:25     ` Davidlohr Bueso
  0 siblings, 0 replies; 3+ messages in thread
From: Davidlohr Bueso @ 2019-02-07 19:25 UTC (permalink / raw)
  To: Paul Burton
  Cc: akpm, linux-mm, linux-kernel, Ralf Baechle, James Hogan,
	linux-mips, Davidlohr Bueso

On Thu, 07 Feb 2019, Paul Burton wrote:

>Hi Davidlohr,
>
>On Wed, Feb 06, 2019 at 09:37:40PM -0800, Davidlohr Bueso wrote:
>> It is well known that because the mm can internally
>> call the regular gup_unlocked if the lockless approach
>> fails and take the sem there, the caller must not hold
>> the mmap_sem already.
>>
>> Fixes: e523f289fe4d (MIPS: c-r4k: Fix sigtramp SMP call to use kmap)
>> Cc: Ralf Baechle <ralf@linux-mips.org>
>> Cc: Paul Burton <paul.burton@mips.com>
>> Cc: James Hogan <jhogan@kernel.org>
>> Cc: linux-mips@vger.kernel.org
>> Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
>
>Thanks - this looks good, but:
>
> 1) The problem it fixes was introduced in v4.8.
>
> 2) Commit adcc81f148d7 ("MIPS: math-emu: Write-protect delay slot
>    emulation pages") actually left flush_cache_sigtramp unused, and has
>    been backported to stable kernels also as far as v4.8.
>
>Therefore this will just fix code that never gets called, and I'll go
>delete the whole thing instead.

Even better.

Thanks,
Davidlohr

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

end of thread, other threads:[~2019-02-07 19:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20190207053740.26915-1-dave@stgolabs.net>
2019-02-07  5:37 ` [PATCH 2/2] MIPS/c-r4k: do no use mmap_sem for gup_fast() Davidlohr Bueso
2019-02-07 19:00   ` Paul Burton
2019-02-07 19:25     ` Davidlohr Bueso

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).