public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: preempt in kprobe
       [not found] ` <566FD7EB-2F00-402D-94F0-123E35F81706@gmail.com>
@ 2015-03-01 12:18   ` Masami Hiramatsu
  0 siblings, 0 replies; 2+ messages in thread
From: Masami Hiramatsu @ 2015-03-01 12:18 UTC (permalink / raw)
  To: zhaoxiaoqiang007; +Cc: rostedt, linux-kernel, yrl.pp-manager.tt@hitachi.com

Hi,

(2015/03/01 20:27), zhaoxiaoqiang007 wrote:
> 
> Hi, masami:
>    I have read your post at https://lkml.org/lkml/2011/7/1/185 which remove the 
>   preempt disable code in kprobe.

Right, but it is only for x86 since the kprobe int3 handler runs in irq-disabled
context, which completely disables preemption. So, in this case it just redundant.
(BTW, it seems that the above patch was finally dropped (just not applied yet)...)

> Does it safe on arm(32) ? In my scenario I (have to) write some sleep code which 
> may cause reschedule in the probe handler.

No, as I've said, sleep or yield to other process in the kprobe handler doesn't
allowed.

>  Then I got schedule bug report like 
> below:
> <4>[  369.000535] [<c0110e54>] (unwind_backtrace+0x0/0x158) from [<c0ad9724>] 
> (dump_stack+0x20/0x24)
> <4>[  369.000609] [<c0ad9724>] (dump_stack+0x20/0x24) from [<c0ada664>] 
> (__schedule_bug+0x58/0x64)
> <4>[  369.000654] [<c0ada664>] (__schedule_bug+0x58/0x64) from [<c0aec4e0>] 
> (__schedule+0x764/0x8e0)
> <4>[  369.000730] [<c0aec4e0>] (__schedule+0x764/0x8e0) from [<c0aec7ac>] 
> (schedule+0x40/0x80)
> <4>[  369.000806] [<c0aec7ac>] (schedule+0x40/0x80) from [<c0ae9bac>] 
> (schedule_timeout+0x230/0x3dc)
> <4>[  369.000884] [<c0ae9bac>] (schedule_timeout+0x230/0x3dc) from [<c0aebbdc>] 
> (wait_for_common+0x100/0x184)
> <4>[  369.000929] [<c0aebbdc>] (wait_for_common+0x100/0x184) from [<c0aebc84>] 
> (wait_for_completion+0x24/0x28)
> <4>[  369.001007] [<c0aebc84>] (wait_for_completion+0x24/0x28) from [<c01c1a14>] 
> (call_usermodehelper_exec+0x150/0x168)
> <4>[  369.001083] [<c01c1a14>] (call_usermodehelper_exec+0x150/0x168) from 
> [<bf0005b4>] (log_to_user.constprop.1+0x11c/0x16
> 
> The bug was triggered by call_usermodehelper with UMH_WAIT_PROC argument , then 
> the schedule function will read the preempt_count. It should be 1, but here it 
> is 2.
> Is it legal to sleep in kprobe handler? Is there is way to walkaroud this problem?

No, please read Documentation/kprobes.txt. If you want to call some usermode
process, perhaps, using a workqueue can be a workaround. However, if you call
workqueue from workqueue-related function, that can cause unexpected result.

Thank you,

-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



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

* preempt in kprobe
       [not found]   ` <4EC4716B-53DA-4D32-8D64-F08C4CE536AA@gmail.com>
@ 2015-03-02  1:44     ` gmail
  0 siblings, 0 replies; 2+ messages in thread
From: gmail @ 2015-03-02  1:44 UTC (permalink / raw)
  To: masami; +Cc: linux-kernel@vger.kernel.org, srostedt

Hi, masami:

        I have read your post at https://lkml.org/lkml/2011/7/1/185 , which remove the  preempt disable code in kprobe.
Does it safe on arm(32) ? In my scenario I (have to) write some sleep code which may cause reschedule in the probe handler.  Then I got schedule bug report like below:

<4>[  369.000535] [<c0110e54>] (unwind_backtrace+0x0/0x158) from [<c0ad9724>] (dump_stack+0x20/0x24)
<4>[  369.000609] [<c0ad9724>] (dump_stack+0x20/0x24) from [<c0ada664>] (__schedule_bug+0x58/0x64)
<4>[  369.000654] [<c0ada664>] (__schedule_bug+0x58/0x64) from [<c0aec4e0>] (__schedule+0x764/0x8e0)
<4>[  369.000730] [<c0aec4e0>] (__schedule+0x764/0x8e0) from [<c0aec7ac>] (schedule+0x40/0x80)
<4>[  369.000806] [<c0aec7ac>] (schedule+0x40/0x80) from [<c0ae9bac>] (schedule_timeout+0x230/0x3dc)
<4>[  369.000884] [<c0ae9bac>] (schedule_timeout+0x230/0x3dc) from [<c0aebbdc>] (wait_for_common+0x100/0x184)
<4>[  369.000929] [<c0aebbdc>] (wait_for_common+0x100/0x184) from [<c0aebc84>] (wait_for_completion+0x24/0x28)
<4>[  369.001007] [<c0aebc84>] (wait_for_completion+0x24/0x28) from [<c01c1a14>] (call_usermodehelper_exec+0x150/0x168)
<4>[  369.001083] [<c01c1a14>] (call_usermodehelper_exec+0x150/0x168) from [<bf0005b4>] (log_to_user.constprop.1+0x11c/0x16

     The bug was triggered by call_usermodehelper with UMH_WAIT_PROC argument , then the schedule function will read the preempt_count. It should be 1, but here it is 2.
Is it legal to sleep in kprobe handler? Is there is way to walkaroud this problem?

        Thanks !!


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

end of thread, other threads:[~2015-03-02  1:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <813D1B5D-3D06-4EEF-AA2A-B0B9F8A81154@gmail.com>
     [not found] ` <566FD7EB-2F00-402D-94F0-123E35F81706@gmail.com>
2015-03-01 12:18   ` preempt in kprobe Masami Hiramatsu
     [not found] ` <13900FF3-780D-4AAF-BF92-3637F7FB8934@gmail.com>
     [not found]   ` <4EC4716B-53DA-4D32-8D64-F08C4CE536AA@gmail.com>
2015-03-02  1:44     ` gmail

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox