Tracing thread name (was: ltt comm tracking)
Quoted 8 lines · * Matthieu CASTET ([email protected]) wrote:
Hi,
I use ltt on a 2.6.27 on an arm architecture.
It works quite well, but I have a minor problem :my application sets thread name with prctl
PR_SET_NAME. But ltt viewer doesn't seem to saw it.
Hrm, I guess we might want to instrument set_task_comm as you propose to get the correct process name, but if this gets us the thread name, I think it's only an implementation side-effect:
If I look at the man page:
PRCTL(2)
PR_SET_NAME (since Linux 2.6.9)
Set the process name for the calling process, using the value in the location pointed to by (char *) arg2. The name can be up to 16 bytes long, and should be null terminated if it contains fewer bytes.
It seems to officially set the process name, not thread name.
The way LTTng handles thread names is by adding a userspace "thread branding" event. It should be executed at thread startup. The downside of the current LTTng approach is that we cannot know the name of threads already executing before we started tracing.
Ideally, having something like prctl PR_SET/GET_THREAD_NAME would probably make sense.
Mathieu
Quoted 17 lines
I don't know how/where ltt extracts the comm name, but may be a tracepoint should be added in
set_task_comm?Any idea how to make ltt use name set with prctl ?
This will make more easier to read trace for application with lot's of threads.Thanks
Matthieu CASTET
_______________________________________________
ltt-dev mailing list
[email protected]
http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Quoted 18 lines · Mathieu Desnoyers
Quoted 8 lines · * Matthieu CASTET ([email protected]) wrote:
Hi,
I use ltt on a 2.6.27 on an arm architecture.
It works quite well, but I have a minor problem :my application sets thread name with prctl
PR_SET_NAME. But ltt viewer doesn't seem to saw it.Hrm, I guess we might want to instrument
set_task_commas you propose to get the correct process name, but if this gets us the thread name, I think it's only an implementation side-effect:If I look at the man page:
PRCTL(2)
Quoted 7 lines
PR_SET_NAME(since Linux 2.6.9)
Set the process name for the calling process, using the value in the location pointed to by (char *) arg2. The name can be up to 16 bytes long, and should be null terminated if it contains fewer bytes.It seems to officially set the process name, not thread name.
Then the man page is wrong, it really only sets the task (thread) name.
Quoted 7 lines
The way LTTng handles thread names is by adding a userspace "thread branding" event. It should be executed at thread startup. The downside of the current LTTng approach is that we cannot know the name of threads already executing before we started tracing.
Ideally, having something like prctl PR_SET/GET_THREAD_NAME would probably make sense.
Going by the current behaviour, you'd need to add process name.
fs/exec.c:
void set_task_comm(struct task_struct *tsk, char *buf)
{
task_lock(tsk);
strlcpy(tsk->comm, buf, sizeof(tsk->comm));
task_unlock(tsk);
perf_counter_comm(tsk);
}Re: Tracing thread name
In reply to Mathieu DesnoyersHi Mathieu,
Quoted 10 lines · Mathieu Desnoyers
Quoted 8 lines · * Matthieu CASTET ([email protected]) wrote:
Hi,
I use ltt on a 2.6.27 on an arm architecture.
It works quite well, but I have a minor problem :my application sets thread name with prctl
PR_SET_NAME. But ltt viewer doesn't seem to saw it.
Quoted 9 lines
Hrm, I guess we might want to instrument
set_task_commas you propose to get the correct process name, but if this gets us the thread name, I think it's only an implementation side-effect:The way LTTng handles thread names is by adding a userspace "thread branding" event. It should be executed at thread startup. The downside of the current LTTng approach is that we cannot know the name of threads already executing before we started tracing.
Do you know if it is possible to patch my version to add such feature ?
I saw that the name already change in the trace before/after an exec. How lltv get the new name ?
With "fs.exec" tracepoint ?
In that case I could fake a "fs.exec" tracepoint in set_task_comm.
Thanks
Matthieu
Re: Tracing thread name
Quoted 23 lines · * Matthieu CASTET ([email protected]) wrote:
Hi Mathieu,
Quoted 10 lines · Mathieu Desnoyers
Quoted 8 lines · * Matthieu CASTET ([email protected]) wrote:
Hi,
I use ltt on a 2.6.27 on an arm architecture.
It works quite well, but I have a minor problem :my application sets thread name with prctl
PR_SET_NAME. But ltt viewer doesn't seem to saw it.Quoted 9 lines
Hrm, I guess we might want to instrument
set_task_commas you propose to get the correct process name, but if this gets us the thread name, I think it's only an implementation side-effect:The way LTTng handles thread names is by adding a userspace "thread branding" event. It should be executed at thread startup. The downside of the current LTTng approach is that we cannot know the name of threads already executing before we started tracing.
Quoted 6 lines
Do you know if it is possible to patch my version to add such feature ?
I saw that the name already change in the trace before/after an exec. How lltv get the new name ?
With "fs.exec" tracepoint ?
In that case I could fake a "fs.exec" tracepoint inset_task_comm.
A better solution : you add a new event in both lttng and lttv, and modify state.c to support your new event. The current event to brand thread is named "userspace.thread_brand". Look for this in LTTV to see all the sites that need to support the new event (there are very few).
Mathieu
Quoted 5 lines
Thanks
Matthieu
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Re: Tracing thread name
Hi,
Quoted 11 lines · Mathieu Desnoyers
Quoted 9 lines · * Matthieu CASTET ([email protected]) wrote:
Hi Mathieu,
Mathieu Desnoyers a écrit :
Do you know if it is possible to patch my version to add such feature ?I saw that the name already change in the trace before/after an exec. How lltv get the new name ?
With "fs.exec" tracepoint ?
In that case I could fake a "fs.exec" tracepoint inset_task_comm.
Quoted 5 lines
A better solution : you add a new event in both lttng and lttv, and modify
state.cto support your new event. The current event to brand thread is named "userspace.thread_brand". Look for this in LTTV to see all the sites that need to support the new event (there are very few).
Thanks, but I want to avoid to modify too much ltt (I use an old version for 2.6.27 and my modifications may be useless for upstream).
I added "trace_fs_exec(tsk->comm);" at the end of set_task_comm and now the thread got the correct name :)
Matthieu
Re: [ltt-dev] Tracing thread name
Quoted 18 lines · Matthieu CASTET
Hi,
Quoted 6 lines · Mathieu Desnoyers
Quoted 5 lines · * Matthieu CASTET ([email protected]) wrote:
Hi Mathieu,
Mathieu Desnoyers a écrit :
Do you know if it is possible to patch my version to add such feature ?Quoted 9 lines
Quoted 4 lines
I saw that the name already change in the trace before/after an exec. How lltv get the new name ?
With "fs.exec" tracepoint ?
In that case I could fake a "fs.exec" tracepoint inset_task_comm.A better solution : you add a new event in both lttng and lttv, and modify
state.cto support your new event. The current event to brand thread is named "userspace.thread_brand". Look for this in LTTV to see all the sites that need to support the new event (there are very few).
Quoted 6 lines
Thanks, but I want to avoid to modify too much ltt (I use an old version for 2.6.27 and my modifications may be useless for upstream).
I added "
trace_fs_exec(tsk->comm);" at the end ofset_task_command now the thread got the correct name :)
BTW it is also interesting to get the name of the kernel threads (created by kthread_create).
The current version of ltt show "kthreadd" for these threads.
The same solution than set_task_comm should solve the problem (comm is set at the end of kthread_create).
Matthieu
PS: khelper thread are also annoying because they all got the same name. May be it could be interesting to add extra info in the name.