H i all, You will get an error when trying to call ptrace system call on kernel threads. In code, you have the following check: static int ptrace_attach(struct task_struct *task, long request, unsigned long addr, unsigned long flags) { ... retval = -EPERM; if (unlikely(task->flags & PF_KTHREAD)) goto out; ... see: http://lxr.free-electrons.com/source/kernel/ptrace.c#L233 Question: what is the reason that kernel threads cannot be traced while userspace threads can be traced ? rgs, Kevin
On Fri, Feb 22, 2013 at 4:38 PM, Kevin Wilson <wkevils@gmail.com> wrote:
Question: what is the reason that kernel threads cannot be traced while userspace threads can be traced ?
Subjectively, I think that's because most kernel threads play important roles in kernel's works. So tracing them might either slows them or interfere them somehow. Especially since it's from user space, kernel can be interrupted badly. I think that's why ftrace introduced. Because ftrace itself is inside kernel space, so it can be trusted. -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
participants (2)
-
Kevin Wilson -
Mulyadi Santosa