Re: [PATCH] arm: kprobe: replace patch_lock to raw lock

2016-12-05 Thread Shi, Yang

On 12/1/2016 6:13 AM, Sebastian Andrzej Siewior wrote:

On 2016-11-10 16:17:55 [-0800], Yang Shi wrote:


Since patch_text_stop_machine() is called in stop_machine() which disables IRQ,
sleepable lock should be not used in this atomic context, so replace patch_lock
to raw lock.

Signed-off-by: Yang Shi 


This can also go upstream.
Acked-by: Sebastian Andrzej Siewior 


Yes, thanks for acking.

Russell,

Could you please consider this patch?

Thanks,
Yang



Sebastian





Re: [PATCH] arm: kprobe: replace patch_lock to raw lock

2016-12-05 Thread Shi, Yang

On 12/1/2016 6:13 AM, Sebastian Andrzej Siewior wrote:

On 2016-11-10 16:17:55 [-0800], Yang Shi wrote:


Since patch_text_stop_machine() is called in stop_machine() which disables IRQ,
sleepable lock should be not used in this atomic context, so replace patch_lock
to raw lock.

Signed-off-by: Yang Shi 


This can also go upstream.
Acked-by: Sebastian Andrzej Siewior 


Yes, thanks for acking.

Russell,

Could you please consider this patch?

Thanks,
Yang



Sebastian





Re: [PATCH] arm: kprobe: replace patch_lock to raw lock

2016-12-01 Thread Sebastian Andrzej Siewior
On 2016-11-10 16:17:55 [-0800], Yang Shi wrote:
> 
> Since patch_text_stop_machine() is called in stop_machine() which disables 
> IRQ,
> sleepable lock should be not used in this atomic context, so replace 
> patch_lock
> to raw lock.
> 
> Signed-off-by: Yang Shi 

This can also go upstream.
Acked-by: Sebastian Andrzej Siewior 

Sebastian


Re: [PATCH] arm: kprobe: replace patch_lock to raw lock

2016-12-01 Thread Sebastian Andrzej Siewior
On 2016-11-10 16:17:55 [-0800], Yang Shi wrote:
> 
> Since patch_text_stop_machine() is called in stop_machine() which disables 
> IRQ,
> sleepable lock should be not used in this atomic context, so replace 
> patch_lock
> to raw lock.
> 
> Signed-off-by: Yang Shi 

This can also go upstream.
Acked-by: Sebastian Andrzej Siewior 

Sebastian


Re: [PATCH] arm: kprobe: replace patch_lock to raw lock

2016-12-01 Thread Sebastian Andrzej Siewior
On 2016-11-10 16:17:55 [-0800], Yang Shi wrote:
> 
> Since patch_text_stop_machine() is called in stop_machine() which disables 
> IRQ,
> sleepable lock should be not used in this atomic context, so replace 
> patch_lock
> to raw lock.

I am taking this one. Thank you.
We have jump_labels() deactivated on ARM because stop_machine() may
cause latencies at runtime. kprobe and kgdb is used by the user on
purpose (and not because he changed some sched setting) I think we are
fine. I am going to document this.

> Signed-off-by: Yang Shi 

Sebastian


Re: [PATCH] arm: kprobe: replace patch_lock to raw lock

2016-12-01 Thread Sebastian Andrzej Siewior
On 2016-11-10 16:17:55 [-0800], Yang Shi wrote:
> 
> Since patch_text_stop_machine() is called in stop_machine() which disables 
> IRQ,
> sleepable lock should be not used in this atomic context, so replace 
> patch_lock
> to raw lock.

I am taking this one. Thank you.
We have jump_labels() deactivated on ARM because stop_machine() may
cause latencies at runtime. kprobe and kgdb is used by the user on
purpose (and not because he changed some sched setting) I think we are
fine. I am going to document this.

> Signed-off-by: Yang Shi 

Sebastian


[PATCH] arm: kprobe: replace patch_lock to raw lock

2016-11-10 Thread Yang Shi
When running kprobe on -rt kernel, the below bug is caught:

BUG: sleeping function called from invalid context at 
kernel/locking/rtmutex.c:931
in_atomic(): 1, irqs_disabled(): 128, pid: 14, name: migration/0
INFO: lockdep is turned off.
irq event stamp: 238
hardirqs last enabled at (237): [<80b5aecc>] 
_raw_spin_unlock_irqrestore+0x88/0x90
hardirqs last disabled at (238): [<80b56d88>] __schedule+0xec/0x94c
softirqs last enabled at (0): [<80225584>] copy_process.part.5+0x30c/0x1994
softirqs last disabled at (0): [< (null)>] (null)
Preemption disabled at:[<802f2b98>] cpu_stopper_thread+0xc0/0x140

CPU: 0 PID: 14 Comm: migration/0 Tainted: G O 4.8.3-rt2 #1
Hardware name: Freescale LS1021A
[<80212e7c>] (unwind_backtrace) from [<8020cd2c>] (show_stack+0x20/0x24)
[<8020cd2c>] (show_stack) from [<80689e14>] (dump_stack+0xa0/0xcc)
[<80689e14>] (dump_stack) from [<8025a43c>] (___might_sleep+0x1b8/0x2a4)
[<8025a43c>] (___might_sleep) from [<80b5b324>] (rt_spin_lock+0x34/0x74)
[<80b5b324>] (rt_spin_lock) from [<80b5c31c>] (__patch_text_real+0x70/0xe8)
[<80b5c31c>] (__patch_text_real) from [<80b5c3ac>] 
(patch_text_stop_machine+0x18/0x20)
[<80b5c3ac>] (patch_text_stop_machine) from [<802f2920>] 
(multi_cpu_stop+0xfc/0x134)
[<802f2920>] (multi_cpu_stop) from [<802f2ba0>] (cpu_stopper_thread+0xc8/0x140)
[<802f2ba0>] (cpu_stopper_thread) from [<802563a4>] 
(smpboot_thread_fn+0x1a4/0x354)
[<802563a4>] (smpboot_thread_fn) from [<80251d38>] (kthread+0x104/0x11c)
[<80251d38>] (kthread) from [<80207f70>] (ret_from_fork+0x14/0x24)

Since patch_text_stop_machine() is called in stop_machine() which disables IRQ,
sleepable lock should be not used in this atomic context, so replace patch_lock
to raw lock.

Signed-off-by: Yang Shi 
---
 arch/arm/kernel/patch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
index 69bda1a..1f665ac 100644
--- a/arch/arm/kernel/patch.c
+++ b/arch/arm/kernel/patch.c
@@ -15,7 +15,7 @@ struct patch {
unsigned int insn;
 };
 
-static DEFINE_SPINLOCK(patch_lock);
+static DEFINE_RAW_SPINLOCK(patch_lock);
 
 static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags)
__acquires(_lock)
@@ -32,7 +32,7 @@ static void __kprobes *patch_map(void *addr, int fixmap, 
unsigned long *flags)
return addr;
 
if (flags)
-   spin_lock_irqsave(_lock, *flags);
+   raw_spin_lock_irqsave(_lock, *flags);
else
__acquire(_lock);
 
@@ -47,7 +47,7 @@ static void __kprobes patch_unmap(int fixmap, unsigned long 
*flags)
clear_fixmap(fixmap);
 
if (flags)
-   spin_unlock_irqrestore(_lock, *flags);
+   raw_spin_unlock_irqrestore(_lock, *flags);
else
__release(_lock);
 }
-- 
2.0.2



[PATCH] arm: kprobe: replace patch_lock to raw lock

2016-11-10 Thread Yang Shi
When running kprobe on -rt kernel, the below bug is caught:

BUG: sleeping function called from invalid context at 
kernel/locking/rtmutex.c:931
in_atomic(): 1, irqs_disabled(): 128, pid: 14, name: migration/0
INFO: lockdep is turned off.
irq event stamp: 238
hardirqs last enabled at (237): [<80b5aecc>] 
_raw_spin_unlock_irqrestore+0x88/0x90
hardirqs last disabled at (238): [<80b56d88>] __schedule+0xec/0x94c
softirqs last enabled at (0): [<80225584>] copy_process.part.5+0x30c/0x1994
softirqs last disabled at (0): [< (null)>] (null)
Preemption disabled at:[<802f2b98>] cpu_stopper_thread+0xc0/0x140

CPU: 0 PID: 14 Comm: migration/0 Tainted: G O 4.8.3-rt2 #1
Hardware name: Freescale LS1021A
[<80212e7c>] (unwind_backtrace) from [<8020cd2c>] (show_stack+0x20/0x24)
[<8020cd2c>] (show_stack) from [<80689e14>] (dump_stack+0xa0/0xcc)
[<80689e14>] (dump_stack) from [<8025a43c>] (___might_sleep+0x1b8/0x2a4)
[<8025a43c>] (___might_sleep) from [<80b5b324>] (rt_spin_lock+0x34/0x74)
[<80b5b324>] (rt_spin_lock) from [<80b5c31c>] (__patch_text_real+0x70/0xe8)
[<80b5c31c>] (__patch_text_real) from [<80b5c3ac>] 
(patch_text_stop_machine+0x18/0x20)
[<80b5c3ac>] (patch_text_stop_machine) from [<802f2920>] 
(multi_cpu_stop+0xfc/0x134)
[<802f2920>] (multi_cpu_stop) from [<802f2ba0>] (cpu_stopper_thread+0xc8/0x140)
[<802f2ba0>] (cpu_stopper_thread) from [<802563a4>] 
(smpboot_thread_fn+0x1a4/0x354)
[<802563a4>] (smpboot_thread_fn) from [<80251d38>] (kthread+0x104/0x11c)
[<80251d38>] (kthread) from [<80207f70>] (ret_from_fork+0x14/0x24)

Since patch_text_stop_machine() is called in stop_machine() which disables IRQ,
sleepable lock should be not used in this atomic context, so replace patch_lock
to raw lock.

Signed-off-by: Yang Shi 
---
 arch/arm/kernel/patch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
index 69bda1a..1f665ac 100644
--- a/arch/arm/kernel/patch.c
+++ b/arch/arm/kernel/patch.c
@@ -15,7 +15,7 @@ struct patch {
unsigned int insn;
 };
 
-static DEFINE_SPINLOCK(patch_lock);
+static DEFINE_RAW_SPINLOCK(patch_lock);
 
 static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags)
__acquires(_lock)
@@ -32,7 +32,7 @@ static void __kprobes *patch_map(void *addr, int fixmap, 
unsigned long *flags)
return addr;
 
if (flags)
-   spin_lock_irqsave(_lock, *flags);
+   raw_spin_lock_irqsave(_lock, *flags);
else
__acquire(_lock);
 
@@ -47,7 +47,7 @@ static void __kprobes patch_unmap(int fixmap, unsigned long 
*flags)
clear_fixmap(fixmap);
 
if (flags)
-   spin_unlock_irqrestore(_lock, *flags);
+   raw_spin_unlock_irqrestore(_lock, *flags);
else
__release(_lock);
 }
-- 
2.0.2