* [PATCH] powerpc: Fix deadlock in icswx code
[not found] <20110915052313.7127520d@kryten>
@ 2011-09-14 19:43 ` Anton Blanchard
2011-09-15 13:09 ` Jimi Xenidis
0 siblings, 1 reply; 3+ messages in thread
From: Anton Blanchard @ 2011-09-14 19:43 UTC (permalink / raw)
To: benh, paulus; +Cc: linuxppc-dev
The icswx code introduced an A-B B-A deadlock:
CPU0 CPU1
---- ----
lock(&anon_vma->mutex);
lock(&mm->mmap_sem);
lock(&anon_vma->mutex);
lock(&mm->mmap_sem);
Instead of using the mmap_sem to keep mm_users constant, take the
page table spinlock.
Signed-off-by: Anton Blanchard <anton@samba.org>
Cc: <stable@kernel.org>
---
diff --git a/arch/powerpc/mm/mmu_context_hash64.c b/arch/powerpc/mm/mmu_context_hash64.c
index 3bafc3d..4ff587e 100644
--- a/arch/powerpc/mm/mmu_context_hash64.c
+++ b/arch/powerpc/mm/mmu_context_hash64.c
@@ -136,8 +136,8 @@ int use_cop(unsigned long acop, struct mm_struct *mm)
if (!mm || !acop)
return -EINVAL;
- /* We need to make sure mm_users doesn't change */
- down_read(&mm->mmap_sem);
+ /* The page_table_lock ensures mm_users won't change under us */
+ spin_lock(&mm->page_table_lock);
spin_lock(mm->context.cop_lockp);
if (mm->context.cop_pid == COP_PID_NONE) {
@@ -164,7 +164,7 @@ int use_cop(unsigned long acop, struct mm_struct *mm)
out:
spin_unlock(mm->context.cop_lockp);
- up_read(&mm->mmap_sem);
+ spin_unlock(&mm->page_table_lock);
return ret;
}
@@ -185,8 +185,8 @@ void drop_cop(unsigned long acop, struct mm_struct *mm)
if (WARN_ON_ONCE(!mm))
return;
- /* We need to make sure mm_users doesn't change */
- down_read(&mm->mmap_sem);
+ /* The page_table_lock ensures mm_users won't change under us */
+ spin_lock(&mm->page_table_lock);
spin_lock(mm->context.cop_lockp);
mm->context.acop &= ~acop;
@@ -213,7 +213,7 @@ void drop_cop(unsigned long acop, struct mm_struct *mm)
}
spin_unlock(mm->context.cop_lockp);
- up_read(&mm->mmap_sem);
+ spin_unlock(&mm->page_table_lock);
}
EXPORT_SYMBOL_GPL(drop_cop);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc: Fix deadlock in icswx code
2011-09-14 19:43 ` [PATCH] powerpc: Fix deadlock in icswx code Anton Blanchard
@ 2011-09-15 13:09 ` Jimi Xenidis
2011-09-27 10:04 ` Anton Blanchard
0 siblings, 1 reply; 3+ messages in thread
From: Jimi Xenidis @ 2011-09-15 13:09 UTC (permalink / raw)
To: Anton Blanchard; +Cc: paulus, linuxppc-dev
On Sep 14, 2011, at 2:43 PM, Anton Blanchard wrote:
Hi Anton,
It would really help me a lot if you could review and maybe merge this =
with my earlier patch that splits this file.
<http://patchwork.ozlabs.org/patch/109103/>
All it does is split.. I promise.
You don't have to take the other stuff.. yet :)
-JX
>=20
> The icswx code introduced an A-B B-A deadlock:
>=20
> CPU0 CPU1
> ---- ----
> lock(&anon_vma->mutex);
> lock(&mm->mmap_sem);
> lock(&anon_vma->mutex);
> lock(&mm->mmap_sem);
>=20
> Instead of using the mmap_sem to keep mm_users constant, take the
> page table spinlock.
>=20
> Signed-off-by: Anton Blanchard <anton@samba.org>
> Cc: <stable@kernel.org>
> ---
>=20
> diff --git a/arch/powerpc/mm/mmu_context_hash64.c =
b/arch/powerpc/mm/mmu_context_hash64.c
> index 3bafc3d..4ff587e 100644
> --- a/arch/powerpc/mm/mmu_context_hash64.c
> +++ b/arch/powerpc/mm/mmu_context_hash64.c
> @@ -136,8 +136,8 @@ int use_cop(unsigned long acop, struct mm_struct =
*mm)
> if (!mm || !acop)
> return -EINVAL;
>=20
> - /* We need to make sure mm_users doesn't change */
> - down_read(&mm->mmap_sem);
> + /* The page_table_lock ensures mm_users won't change under us */
> + spin_lock(&mm->page_table_lock);
> spin_lock(mm->context.cop_lockp);
>=20
> if (mm->context.cop_pid =3D=3D COP_PID_NONE) {
> @@ -164,7 +164,7 @@ int use_cop(unsigned long acop, struct mm_struct =
*mm)
>=20
> out:
> spin_unlock(mm->context.cop_lockp);
> - up_read(&mm->mmap_sem);
> + spin_unlock(&mm->page_table_lock);
>=20
> return ret;
> }
> @@ -185,8 +185,8 @@ void drop_cop(unsigned long acop, struct mm_struct =
*mm)
> if (WARN_ON_ONCE(!mm))
> return;
>=20
> - /* We need to make sure mm_users doesn't change */
> - down_read(&mm->mmap_sem);
> + /* The page_table_lock ensures mm_users won't change under us */
> + spin_lock(&mm->page_table_lock);
> spin_lock(mm->context.cop_lockp);
>=20
> mm->context.acop &=3D ~acop;
> @@ -213,7 +213,7 @@ void drop_cop(unsigned long acop, struct mm_struct =
*mm)
> }
>=20
> spin_unlock(mm->context.cop_lockp);
> - up_read(&mm->mmap_sem);
> + spin_unlock(&mm->page_table_lock);
> }
> EXPORT_SYMBOL_GPL(drop_cop);
>=20
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc: Fix deadlock in icswx code
2011-09-15 13:09 ` Jimi Xenidis
@ 2011-09-27 10:04 ` Anton Blanchard
0 siblings, 0 replies; 3+ messages in thread
From: Anton Blanchard @ 2011-09-27 10:04 UTC (permalink / raw)
To: Jimi Xenidis; +Cc: paulus, linuxppc-dev
Hi Jimi,
> It would really help me a lot if you could review and maybe merge
> this with my earlier patch that splits this file.
> <http://patchwork.ozlabs.org/patch/109103/> All it does is split.. I
> promise. You don't have to take the other stuff.. yet :)
Sorry it took so long to get to this. Looking at it now.
Anton
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-09-27 10:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20110915052313.7127520d@kryten>
2011-09-14 19:43 ` [PATCH] powerpc: Fix deadlock in icswx code Anton Blanchard
2011-09-15 13:09 ` Jimi Xenidis
2011-09-27 10:04 ` Anton Blanchard
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).