Skip to contentSkip to conversation

kernel api for application profiling

DISCUSSION Mikael Pettersson 3 participants 4 messages Oct 13, 2002 – Oct 14, 2002

lore
Share & tools
lore
#0 lore raw
Quoted 5 lines · John Levon
Quoted 2 lines · Mikael Pettersson

And before people ask me: perfctr is not yet in official kernels, I'm working on a cleaned up version for 2.5 submission RSN,

Quoted 7 lines

This is going to clash head-on with oprofile. However, the two systems are both useful in their own rights: oprofile isn't useful for interstitial timings as described above, whereas perfctr isn't really designed for system profiling.

So I suspect the simplest solution would be to make the config options for them exclusive. Comments ?

I've thought about this problem before, and I think there is a simple & less drastic solution to it.

The HW resources in question are the local APIC LVTPC entry and the performance counter MSRs. Agreed?

The HW is either free or owned in full by a single client (the NMI watchdog, oprofile, perfctr, etc). Splitting the HW resources gets too weird and doesn't actually work. (Consider the P6s asymmetric EVNTSEL Enable flag for instance.)

A client needs to reserve the HW before it is allowed to touch it. Normally, a client would release the HW automatically when it no longer needs it. perfctr already works that way, and I imagine oprofile could do the same.

Ignoring the NMI watchdog, the resource manager becomes trivial.

The NMI watchdog is a problem. This is a client which normally doesn't release the HW; however, it should release it if some other specialised client (like oprofile or perfctr) needs it. Furthermore, when that client is done, the NMI watchdog should ideally be activated again.

The NMI watchdog can either be special-cased so that the resource manager knows that it is a low-priority default owner of the HW, or we can try to encode this in the interface to the manager, using callbacks like "are you willing to release the HW?" and results like "yes, but please call this FUNC when you're done with the HW".

/Mikael

#1 lore raw
Quoted 2 lines · Mikael Pettersson

The HW resources in question are the local APIC LVTPC entry and the performance counter MSRs. Agreed?

Right.

Quoted 5 lines

The NMI watchdog can either be special-cased so that the resource manager knows that it is a low-priority default owner of the HW, or we can try to encode this in the interface to the manager, using callbacks like "are you willing to release the HW?" and results like "yes, but please call this FUNC when you're done with the HW".

I've been thinking along the exact same lines. I even started to implement something like this originally, but ended up doing a simpler save/restore thing in oprofile. It would be fairly easy to implement, the biggest difficulty being the hand-off of the power management routines and the NMI handler where appropriate.

I agree that it doesn't make sense to split up the resources (though at some point I'd like to maintain the watchdog functionality even with oprofile running). In fact, for now, I think the simple exclusive CONFIG solution is the simplest - the things don't get on together, after all.

regards
john

Signature · 2 lines
"That's just kitten-eating wrong."
	- Richard Henderson
#2 lore raw
Quoted 9 lines · John Levon

I agree that it doesn't make sense to split up the resources (though at some point I'd like to maintain the watchdog functionality even with oprofile running). In fact, for now, I think the simple exclusive CONFIG solution is the simplest - the things don't get on together, after all.

regards
john

Speaking as the potential user of these tools, having to run a different kernel (My translation of exclusive CONFIG) to swich these features on and off would be annoying. I would prefer the simple loading/unloading of a kernel module to do the job. Having looked at a fair bit of kernel module code, I at first think that the kernel module api cannot achieve this, but other people on this list might think/know otherwise. From the user point of view it is adding/removing a kernel feature so a module would seem appropriate, but from a programmers point of view, the profiling code would have to be spread about all the kernel code in order to accurately catch the profiling information.

Summary: -
Please try to create a profiling kernel runtime loadable module instead of an exclusive CONFIG item.

Cheers
James

#3 lore raw
Quoted 5 lines · James Courtier-Dutton
Quoted 3 lines

oprofile running). In fact, for now, I think the simple exclusive CONFIG

Speaking as the potential user of these tools, having to run a different kernel (My translation of exclusive CONFIG) to swich these features on

Perhaps you didn't see the "for now" part of my post.

regards
john

Signature · 2 lines
"That's just kitten-eating wrong."
	- Richard Henderson