views:

53

answers:

1

I want to collect information about when my threads are scheduled (and descheduled), and on which CPUs, on Linux. I'm happy to collect the information and store it in a file for offline analysis later, since I'll need to merge the scheduling information with other event sources generated by my code. Ideally the information would be collected by the program itself, as I plan to be using all the cores on the machine most of the time, and using an external process to do the sampling would disturb the execution I want to measure.

So is this possible on Linux? What are the options?

+1  A: 

The Linux perf tool is a general purpose kernel-supported profiling tool. Among other things, it can record events, which includes task scheduling events.

caf
thanks, I know about perf, what I really wanted was pointers to APIs I can use to get the information from my own code.
Simon Marlow
@Simon Marlow: `perf` is that API. You don't have to worry about it affecting the thing you are attempting to measure, because the way it works is that the kernel logs events into an internal buffer as they occur, and the userspace tool is run after the fact to extract the event log.
caf
ok, thanks, I'll look into it.
Simon Marlow