All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] arm64: traps: disable irq in die()
@ 2017-07-07  9:29 ` Qiao Zhou
  0 siblings, 0 replies; 8+ messages in thread
From: Qiao Zhou @ 2017-07-07  9:29 UTC (permalink / raw)
  To: catalin.marinas, will.deacon, mark.rutland, suzuki.poulose,
	mingo, marc.zyngier, andre.przywara, linux-arm-kernel,
	linux-kernel
  Cc: Qiao Zhou

In current die(), the irq is disabled for __die() handle, not
including the possible panic() handling. Since the log in __die()
can take several hundreds ms, new irq might come and interrupt
current die().

If the process calling die() holds some critical resource, and some
other process scheduled later also needs it, then it would deadlock.
The first panic will not be executed.

So here disable irq for the whole flow of die().

Signed-off-by: Qiao Zhou <qiaozhou@asrmicro.com>
---
 arch/arm64/kernel/traps.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index 0805b44..2e2ff88 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -274,10 +274,12 @@ static DEFINE_RAW_SPINLOCK(die_lock);
 void die(const char *str, struct pt_regs *regs, int err)
 {
 	int ret;
+	unsigned long flags;
+
+	raw_spin_lock_irqsave(&die_lock, flags);
 
 	oops_enter();
 
-	raw_spin_lock_irq(&die_lock);
 	console_verbose();
 	bust_spinlocks(1);
 	ret = __die(str, err, regs);
@@ -287,13 +289,15 @@ void die(const char *str, struct pt_regs *regs, int err)
 
 	bust_spinlocks(0);
 	add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
-	raw_spin_unlock_irq(&die_lock);
 	oops_exit();
 
 	if (in_interrupt())
 		panic("Fatal exception in interrupt");
 	if (panic_on_oops)
 		panic("Fatal exception");
+
+	raw_spin_unlock_irqrestore(&die_lock, flags);
+
 	if (ret != NOTIFY_STOP)
 		do_exit(SIGSEGV);
 }
-- 
2.7.4

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

* [PATCH V2] arm64: traps: disable irq in die()
@ 2017-07-07  9:29 ` Qiao Zhou
  0 siblings, 0 replies; 8+ messages in thread
From: Qiao Zhou @ 2017-07-07  9:29 UTC (permalink / raw)
  To: linux-arm-kernel

In current die(), the irq is disabled for __die() handle, not
including the possible panic() handling. Since the log in __die()
can take several hundreds ms, new irq might come and interrupt
current die().

If the process calling die() holds some critical resource, and some
other process scheduled later also needs it, then it would deadlock.
The first panic will not be executed.

So here disable irq for the whole flow of die().

Signed-off-by: Qiao Zhou <qiaozhou@asrmicro.com>
---
 arch/arm64/kernel/traps.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index 0805b44..2e2ff88 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -274,10 +274,12 @@ static DEFINE_RAW_SPINLOCK(die_lock);
 void die(const char *str, struct pt_regs *regs, int err)
 {
 	int ret;
+	unsigned long flags;
+
+	raw_spin_lock_irqsave(&die_lock, flags);
 
 	oops_enter();
 
-	raw_spin_lock_irq(&die_lock);
 	console_verbose();
 	bust_spinlocks(1);
 	ret = __die(str, err, regs);
@@ -287,13 +289,15 @@ void die(const char *str, struct pt_regs *regs, int err)
 
 	bust_spinlocks(0);
 	add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
-	raw_spin_unlock_irq(&die_lock);
 	oops_exit();
 
 	if (in_interrupt())
 		panic("Fatal exception in interrupt");
 	if (panic_on_oops)
 		panic("Fatal exception");
+
+	raw_spin_unlock_irqrestore(&die_lock, flags);
+
 	if (ret != NOTIFY_STOP)
 		do_exit(SIGSEGV);
 }
-- 
2.7.4

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

* RE: [PATCH V2] arm64: traps: disable irq in die()
  2017-07-07  9:29 ` Qiao Zhou
@ 2017-07-21  7:38   ` Zhou Qiao(周侨)
  -1 siblings, 0 replies; 8+ messages in thread
From: Zhou Qiao(周侨) @ 2017-07-21  7:38 UTC (permalink / raw)
  To: catalin.marinas, will.deacon, mark.rutland, suzuki.poulose,
	mingo, marc.zyngier, andre.przywara, linux-arm-kernel,
	linux-kernel

Hi Maintainers,

Could you please help to take a look and give some comments? Thanks in advance.

Best Regards
Qiao

-----Original Message-----
From: Zhou Qiao
Sent: Friday, July 07, 2017 5:30 PM
To: catalin.marinas@arm.com; will.deacon@arm.com; mark.rutland@arm.com; suzuki.poulose@arm.com; mingo@kernel.org; marc.zyngier@arm.com; andre.przywara@arm.com; linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org
Cc: Zhou Qiao
Subject: [PATCH V2] arm64: traps: disable irq in die()

In current die(), the irq is disabled for __die() handle, not including the possible panic() handling. Since the log in __die() can take several hundreds ms, new irq might come and interrupt current die().

If the process calling die() holds some critical resource, and some other process scheduled later also needs it, then it would deadlock.
The first panic will not be executed.

So here disable irq for the whole flow of die().

Signed-off-by: Qiao Zhou <qiaozhou@asrmicro.com>
---
 arch/arm64/kernel/traps.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 0805b44..2e2ff88 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -274,10 +274,12 @@ static DEFINE_RAW_SPINLOCK(die_lock);  void die(const char *str, struct pt_regs *regs, int err)  {
 	int ret;
+	unsigned long flags;
+
+	raw_spin_lock_irqsave(&die_lock, flags);
 
 	oops_enter();
 
-	raw_spin_lock_irq(&die_lock);
 	console_verbose();
 	bust_spinlocks(1);
 	ret = __die(str, err, regs);
@@ -287,13 +289,15 @@ void die(const char *str, struct pt_regs *regs, int err)
 
 	bust_spinlocks(0);
 	add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
-	raw_spin_unlock_irq(&die_lock);
 	oops_exit();
 
 	if (in_interrupt())
 		panic("Fatal exception in interrupt");
 	if (panic_on_oops)
 		panic("Fatal exception");
+
+	raw_spin_unlock_irqrestore(&die_lock, flags);
+
 	if (ret != NOTIFY_STOP)
 		do_exit(SIGSEGV);
 }
--
2.7.4

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

* [PATCH V2] arm64: traps: disable irq in die()
@ 2017-07-21  7:38   ` Zhou Qiao(周侨)
  0 siblings, 0 replies; 8+ messages in thread
From: Zhou Qiao(周侨) @ 2017-07-21  7:38 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Maintainers,

Could you please help to take a look and give some comments? Thanks in advance.

Best Regards
Qiao

-----Original Message-----
From: Zhou Qiao
Sent: Friday, July 07, 2017 5:30 PM
To: catalin.marinas at arm.com; will.deacon at arm.com; mark.rutland at arm.com; suzuki.poulose at arm.com; mingo at kernel.org; marc.zyngier at arm.com; andre.przywara at arm.com; linux-arm-kernel at lists.infradead.org; linux-kernel at vger.kernel.org
Cc: Zhou Qiao
Subject: [PATCH V2] arm64: traps: disable irq in die()

In current die(), the irq is disabled for __die() handle, not including the possible panic() handling. Since the log in __die() can take several hundreds ms, new irq might come and interrupt current die().

If the process calling die() holds some critical resource, and some other process scheduled later also needs it, then it would deadlock.
The first panic will not be executed.

So here disable irq for the whole flow of die().

Signed-off-by: Qiao Zhou <qiaozhou@asrmicro.com>
---
 arch/arm64/kernel/traps.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 0805b44..2e2ff88 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -274,10 +274,12 @@ static DEFINE_RAW_SPINLOCK(die_lock);  void die(const char *str, struct pt_regs *regs, int err)  {
 	int ret;
+	unsigned long flags;
+
+	raw_spin_lock_irqsave(&die_lock, flags);
 
 	oops_enter();
 
-	raw_spin_lock_irq(&die_lock);
 	console_verbose();
 	bust_spinlocks(1);
 	ret = __die(str, err, regs);
@@ -287,13 +289,15 @@ void die(const char *str, struct pt_regs *regs, int err)
 
 	bust_spinlocks(0);
 	add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
-	raw_spin_unlock_irq(&die_lock);
 	oops_exit();
 
 	if (in_interrupt())
 		panic("Fatal exception in interrupt");
 	if (panic_on_oops)
 		panic("Fatal exception");
+
+	raw_spin_unlock_irqrestore(&die_lock, flags);
+
 	if (ret != NOTIFY_STOP)
 		do_exit(SIGSEGV);
 }
--
2.7.4

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

* Re: [PATCH V2] arm64: traps: disable irq in die()
  2017-07-21  7:38   ` Zhou Qiao(周侨)
@ 2017-07-21  8:32     ` Will Deacon
  -1 siblings, 0 replies; 8+ messages in thread
From: Will Deacon @ 2017-07-21  8:32 UTC (permalink / raw)
  To: Zhou Qiao(周侨)
  Cc: catalin.marinas, mark.rutland, suzuki.poulose, mingo,
	marc.zyngier, andre.przywara, linux-arm-kernel, linux-kernel

On Fri, Jul 21, 2017 at 07:38:42AM +0000, Zhou Qiao(周侨) wrote:
> Could you please help to take a look and give some comments? Thanks in
> advance.

I've queued this on the arm64 for-next/fixes/core branch.

Will

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

* [PATCH V2] arm64: traps: disable irq in die()
@ 2017-07-21  8:32     ` Will Deacon
  0 siblings, 0 replies; 8+ messages in thread
From: Will Deacon @ 2017-07-21  8:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jul 21, 2017 at 07:38:42AM +0000, Zhou Qiao(??) wrote:
> Could you please help to take a look and give some comments? Thanks in
> advance.

I've queued this on the arm64 for-next/fixes/core branch.

Will

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

* Re: [PATCH V2] arm64: traps: disable irq in die()
  2017-07-21  8:32     ` Will Deacon
@ 2017-07-21  9:57       ` qiaozhou
  -1 siblings, 0 replies; 8+ messages in thread
From: qiaozhou @ 2017-07-21  9:57 UTC (permalink / raw)
  To: Will Deacon
  Cc: catalin.marinas, mark.rutland, suzuki.poulose, mingo,
	marc.zyngier, andre.przywara, linux-arm-kernel, linux-kernel

On 2017年07月21日 16:32, Will Deacon wrote:
> On Fri, Jul 21, 2017 at 07:38:42AM +0000, Zhou Qiao(周侨) wrote:
>> Could you please help to take a look and give some comments? Thanks in
>> advance.
> I've queued this on the arm64 for-next/fixes/core branch.
Got it. Thanks!
>
> Will
Best Regards
Qiao

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

* [PATCH V2] arm64: traps: disable irq in die()
@ 2017-07-21  9:57       ` qiaozhou
  0 siblings, 0 replies; 8+ messages in thread
From: qiaozhou @ 2017-07-21  9:57 UTC (permalink / raw)
  To: linux-arm-kernel

On 2017?07?21? 16:32, Will Deacon wrote:
> On Fri, Jul 21, 2017 at 07:38:42AM +0000, Zhou Qiao(??) wrote:
>> Could you please help to take a look and give some comments? Thanks in
>> advance.
> I've queued this on the arm64 for-next/fixes/core branch.
Got it. Thanks!
>
> Will
Best Regards
Qiao

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

end of thread, other threads:[~2017-07-21  9:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-07  9:29 [PATCH V2] arm64: traps: disable irq in die() Qiao Zhou
2017-07-07  9:29 ` Qiao Zhou
2017-07-21  7:38 ` Zhou Qiao(周侨)
2017-07-21  7:38   ` Zhou Qiao(周侨)
2017-07-21  8:32   ` Will Deacon
2017-07-21  8:32     ` Will Deacon
2017-07-21  9:57     ` qiaozhou
2017-07-21  9:57       ` qiaozhou

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.