This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to understand the pid() and new_pid are same value in executing forktracker.stp?


Hi Josh,

Firstly,  thanks very much for your answer!

Executing your script from
SO(http://stackoverflow.com/questions/33274128/how-to-understand-the-pid-and-new-pid-are-same-value-in-executing-forktracker):

probe kprocess.create {
  printf("%-25s: %s (%d:%d) created %d:%d\n",
         ctime(gettimeofday_s()), execname(), pid(), tid(), new_pid, new_tid)
}

probe kprocess.exec {
  printf("%-25s: %s (%d) is exec'ing %s\n",
         ctime(gettimeofday_s()), execname(), pid(), filename)
}

The output is:

......
Fri Oct 23 01:18:27 2015 : virt-manager (14030) is exec'ing
"/usr/share/virt-manager/virt-manager"
Fri Oct 23 01:18:30 2015 : virt-manager (14030:14030) created 14032:14032
Fri Oct 23 01:18:31 2015 : virt-manager (14032:14032) created 14032:14038
Fri Oct 23 01:18:31 2015 : virt-manager (14032:14032) created 14032:14039
Fri Oct 23 01:18:32 2015 : virt-manager (14032:14032) created 14032:14040
Fri Oct 23 01:18:34 2015 : virt-manager (14032:14032) created 14032:14041
Fri Oct 23 01:18:35 2015 : virt-manager (14032:14032) created 14032:14042
......

I remember in Linux, the process is actually a thread, or LWP, right?
If it is true, I think the pid() is also
tid().

Hope you can give some explanations, thanks in advance!

Best Regards
Nan Xiao


On Fri, Oct 23, 2015 at 8:43 AM, Josh Stone <jistone@redhat.com> wrote:
> On 10/22/2015 05:15 PM, Nan Xiao wrote:
>> Hi guys,
>>
>> Greetings from me!
>>
>> I am using forktracker.stp(https://sourceware.org/systemtap/examples/process/forktracker.stp)
>> script to track fork process, but the output likes this:
>>
>> ......
>> Thu Oct 22 05:09:42 2015 : virt-manager (8713) created 8713
>> Thu Oct 22 05:09:42 2015 : virt-manager (8713) created 8713
>> Thu Oct 22 05:09:42 2015 : virt-manager (8713) created 8713
>> Thu Oct 22 05:09:43 2015 : virt-manager (8713) created 8713
>> ......
>>
>>
>> I can't understand why pid() and new_pid are same. I also submit a
>> issue on SO (http://stackoverflow.com/questions/33274128/how-to-understand-the-pid-and-new-pid-are-same-value-in-executing-forktracker),
>> but until now, no one answer this issue.
>>
>> Could anyone help on this issue? Thanks very much in advance!
>
> Most likely these are new threads in the same process, so the pids will
> match while the tids are different.  We probably should add tids to that
> example script.
>
> Note that we use the POSIX terminology with pid=process and tid=thread,
> versus the kernel with pid=task-id and tgid=thread-group-id.  Every user
> thread has a task, and a thread group is roughly a user process.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]