DavidA
DavidA

Reputation: 2359

How to inspect scheduling of multi-threaded user application using lttng?

I am new to tracing in Linux. I have a multi-threaded C++ user application. The threads wake up periodically (by o/s timer) and sleep after doing some processing. I want to visualise:

1) When the threads start and stop running

2) Which cores the threads are running on.

I have installed lttng and Trace Compass onto an Ubuntu 14.04 LTS machine. But I don't know how to use these tools to achieve my objective.

I have read the following lttng doc section:

http://lttng.org/docs/#doc-tracing-your-own-user-application

In order to collect my trace, must I define custom lttng tracepoint definitions ( in a tracepoint provider header file ), and insert tracepoints into my user application, or is there a simpler way of achieving my goal?

Best regards

David

Upvotes: 0

Views: 618

Answers (1)

alexmonthy
alexmonthy

Reputation: 113

You can take a kernel trace, enabling at least the sched_switch event, to obtain information regarding which thread is running on which CPU. Opening such trace in Trace Compass and looking at the Control Flow View should show the status of all threads, so you can search for the ones the correspond to your application.

In addition, you could also instrument your application with userspace tracepoints, as you mentioned. This would allow you to track userspace states, going further than what is available in just the kernel trace.

You might be interested this example/tutorial, which shows how to instrument a simple application and how to write a Trace Compass configuration file to display application states graphically.

Upvotes: 0

Related Questions