0

How can I get page faults statistics from kernel for my application while it is running? What about other events, like inter-cpu migrations count in SMP nodes, or number of context switches?

I want to count such events for various small parts of the program.

Thanks.

osgx
  • 90,338
  • 53
  • 357
  • 513

2 Answers2

4

The procfs records some of that information, but (I believe) not all of it, and definitely not "for various small parts", but only for the process as a whole. I doubt the kernel records e.g. context switches or page faults "for various small parts" anywhere. Maybe you can take snapshots of the applicable /proc pseudofiles at the start and end of each "small part" and take the difference -- for some applications (that don't branch every which way all of the time) that might be an acceptable substitute.

Alex Martelli
  • 854,459
  • 170
  • 1,222
  • 1,395
  • which records from procfs can i use? is there statistics of cpu migrations and cntx switches? – osgx Apr 04 '10 at 01:31
  • Yes, I can do smth (like reading a file) between measured parts. – osgx Apr 04 '10 at 01:31
  • there is a counter for cntx switch: http://lxr.linux.no/linux+v2.6.33/kernel/sched.c#L2962 `long long nr_context_switches()` – osgx Apr 04 '10 at 01:34
3

You'll be wanting to use the "perf" tools packaged with the kernel. See here.

stsquad
  • 5,712
  • 3
  • 36
  • 54
  • I'm pretty sure you'll find interesting stuff looking at PAPI, Likwid or even Oprofile. – claf Oct 06 '11 at 09:01