DESCRIPTION

LttngKernelStateProvider: Record TGID of threads

The TGID (thread group ID) will be useful for tracking resources shared
by threads in a process, such as file descriptors.

Change-Id: I20f6f2a3fd12289f031fd03977d52951603b3677
Signed-off-by: Kason Bridges xxx@xxx.xxx


COMMENTS

author: Kason Bridges
date: 2014-08-25 17:55:14.000000000

Uploaded patch set 1.

-------------------------------------
author: Ivy Mitchell
date: 2014-08-26 02:01:25.000000000

Patch Set 1: Code-Review+1

-------------------------------------
author: Braxton Mccarthy
date: 2014-08-26 02:33:39.000000000

Patch Set 1: Code-Review-1

(2 comments)

child_pid was added in LTTng 2.2 or 2.3 IIRC. It may not be present in all LTTng traces.

We should first check if the field is present before dereferencing it (this stands true for this whole file.... but especially for fields that may or may not be there).

Line:284, lttng/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/stateprovider/LttngKernelStateProvider.java -> Only these were part of LTTng 2.0

Line:293, lttng/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/stateprovider/LttngKernelStateProvider.java -> getValue() will throw an NPE if this field is not present in the trace.

-------------------------------------
author: Kason Bridges
date: 2014-08-26 14:18:53.000000000

Patch Set 1:

Without this information, the whole file descriptor bookkeeping is not really possible. I see two options:

1. As you said, check for the field child_pid., no cool analysis for you.
2. When a sched_process_fork happens, the parent thread will always be in a sys_clone. In the flags given to sys_clone, we can check if the CLONE_THREAD bit is set. From there, we can set TGID accordingly (to child_tid if it's a new process, to parent_tid if it's a new thread). This should work for all LTTng 2.x versions.


FYI, the CLONE_THREAD bit position has not changed since the clone system call appeared in the Linux kernel 2.4, so I think it is safe to say it won't change in a near future.

-------------------------------------
author: Kason Bridges
date: 2014-08-26 14:20:01.000000000

Patch Set 1:

The formatting sucked in my last comment. Let me try again.

1. As you said, check for the field child_pid. If it is not there, no cool analysis for you.


2. When a sched_process_fork happens, the parent thread will always be in a sys_clone. In the flags given to sys_clone, we can check if the CLONE_THREAD bit is set. From there, we can set TGID accordingly (to child_tid if it's a new process, to parent_tid if it's a new thread). This should work for all LTTng 2.x versions.

-------------------------------------
