Skip to contentSkip to conversation

Accessing CPU performance counters from user space

DISCUSSION sandeep lahane 2 participants 3 messages Jun 25, 2009 – Jun 26, 2009

lore
Share & tools
lore
#0 lore raw

Hi All,

Is it possible to access cpu performance counters from user space? AFAIK, it is not possible.
I am aware of various attempts like perfmon and perfctr patch set. Looks like a kernel module is
mandatory to access these registers. My objective is to measure various parameters like number
instructions retired, number of cache misses, number of brach mis predictions etc.

I know of an alternative way to count the number of instructions by using ptrace but I think this approach
is very slow.

Regards,
Sandeep.
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#1 lore raw
Quoted 11 lines · sandeep lahane

Hi All,

Is it possible to access cpu performance counters from user space? AFAIK, it is not possible.
I am aware of various attempts like perfmon and perfctr patch set. Looks like a kernel module is
mandatory to access these registers. My objective is to measure various parameters like number
instructions retired, number of cache misses, number of brach mis predictions etc.

Quoted 7 lines

I know of an alternative way to count the number of instructions by using ptrace but I think this approach
is very slow.

Regards,
Sandeep.

I meant Perfsuite and perfctr, not perfmon.
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#2 lore raw
In reply to sandeep lahane
Quoted 4 lines · sandeep lahane

Hi All,

Is it possible to access cpu performance counters from user space? AFAIK, it is not possible.

yes, impossible...because u need ring 0 to access these counter.

For some more info:

http://www.scl.ameslab.gov/Projects/Rabbit/menu.html#download

and this one (irrelevant to linux kernel, but it shows how other kernel are doing it.....all have to be ring0):

http://www.opensolaris.org/os/project/intel-platform/CPC/

Quoted 19 lines

I am aware of various attempts like perfmon and perfctr patch set. Looks like a kernel module is
mandatory to access these registers. My objective is to measure various parameters like number
instructions retired, number of cache misses, number of brach mis predictions etc.

I know of an alternative way to count the number of instructions by using ptrace but I think this approach
is very slow.

Regards,
Sandeep.
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Signature · 7 lines
Regards,
Peter Teoh
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs