LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-20-2011, 02:37 AM   #1
ternis
LQ Newbie
 
Registered: Jul 2011
Posts: 1

Rep: Reputation: Disabled
[kernel] performance counter


Hello,

I want read the performance counters for an external module. For this i found 2 function in ./include/linux/perf_event.h :
extern struct perf_event *perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu, struct task_struct *task, perf_overflow_handler_t callback);
extern u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running);
The problem : the values recovered with perf_event_read_value are (a priori) erroneous.

I have recovered a program that reads the register in user space and the values are not same that for the module...

Code:
static void perf_counter(unsigned int cpu){
	struct perf_event_attr attr = {
		.type = PERF_TYPE_SOFTWARE
		.config = PERF_COUNT_SW_CPU_CLOCK
	};
	u64 total=0, enabled=0, running=0;
	
	struct perf_event *evt = perf_event_create_kernel_counter(&attr, cpu, NULL, f_overflow);
	total = perf_event_read_value(evt, &enabled, &running);
	
	printk(KERN_INFO "cpufreq(%u): governor Govtest perf : %llu %llu %llu", cpu, total, 
		   enabled, running);
}

For example the displayed values by the module are between 300 and 700. total is always lower that enabled and running. More enabled=running at each test...
Normally I should have a value neighbor 1 000 000 000...


thanks for your help !
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP - POST variables named with counter: $_POST[${"variable$counter"} winairmvs Programming 1 08-06-2010 04:56 PM
Reading the Performance Counter in RT-Linux? overberg Programming 0 07-24-2009 04:08 AM
LXer: IBM Hardware Performance Counter for Linux on Power LXer Syndicated Linux News 0 08-25-2006 10:21 PM
counter part of "rpm -ivh --force kernel....rpm in slackware b0nd Slackware 2 01-28-2006 07:46 PM
2.6 kernel performance Jerre Cope Linux - General 2 07-12-2005 09:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration