2005-04-17 05:20:36 +07:00
|
|
|
/**
|
|
|
|
* @file oprofile_stats.c
|
|
|
|
*
|
|
|
|
* @remark Copyright 2002 OProfile authors
|
|
|
|
* @remark Read the file COPYING
|
|
|
|
*
|
|
|
|
* @author John Levon
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/oprofile.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/cpumask.h>
|
|
|
|
#include <linux/threads.h>
|
2008-10-16 20:01:40 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#include "oprofile_stats.h"
|
|
|
|
#include "cpu_buffer.h"
|
2008-10-16 20:01:40 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
struct oprofile_stat_struct oprofile_stats;
|
2008-10-16 20:01:40 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
void oprofile_reset_stats(void)
|
|
|
|
{
|
2008-09-05 22:12:36 +07:00
|
|
|
struct oprofile_cpu_buffer *cpu_buf;
|
2005-04-17 05:20:36 +07:00
|
|
|
int i;
|
2008-10-16 20:01:40 +07:00
|
|
|
|
2006-03-28 16:56:38 +07:00
|
|
|
for_each_possible_cpu(i) {
|
2009-10-29 20:34:13 +07:00
|
|
|
cpu_buf = &per_cpu(op_cpu_buffer, i);
|
2005-04-17 05:20:36 +07:00
|
|
|
cpu_buf->sample_received = 0;
|
|
|
|
cpu_buf->sample_lost_overflow = 0;
|
2007-11-15 07:58:48 +07:00
|
|
|
cpu_buf->backtrace_aborted = 0;
|
|
|
|
cpu_buf->sample_invalid_eip = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2008-10-16 20:01:40 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
|
|
|
|
atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
|
|
|
|
atomic_set(&oprofile_stats.event_lost_overflow, 0);
|
2009-05-27 22:15:08 +07:00
|
|
|
atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
|
2009-07-09 19:56:25 +07:00
|
|
|
atomic_set(&oprofile_stats.multiplex_counter, 0);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-19 18:54:56 +07:00
|
|
|
void oprofile_create_stats_files(struct dentry *root)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2008-09-05 22:12:36 +07:00
|
|
|
struct oprofile_cpu_buffer *cpu_buf;
|
|
|
|
struct dentry *cpudir;
|
|
|
|
struct dentry *dir;
|
2005-04-17 05:20:36 +07:00
|
|
|
char buf[10];
|
|
|
|
int i;
|
|
|
|
|
2013-07-19 18:58:27 +07:00
|
|
|
dir = oprofilefs_mkdir(root, "stats");
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!dir)
|
|
|
|
return;
|
|
|
|
|
2006-03-28 16:56:38 +07:00
|
|
|
for_each_possible_cpu(i) {
|
2009-10-29 20:34:13 +07:00
|
|
|
cpu_buf = &per_cpu(op_cpu_buffer, i);
|
2005-04-17 05:20:36 +07:00
|
|
|
snprintf(buf, 10, "cpu%d", i);
|
2013-07-19 18:58:27 +07:00
|
|
|
cpudir = oprofilefs_mkdir(dir, buf);
|
2008-10-16 20:01:40 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* Strictly speaking access to these ulongs is racy,
|
|
|
|
* but we can't simply lock them, and they are
|
|
|
|
* informational only.
|
|
|
|
*/
|
2013-07-19 19:10:36 +07:00
|
|
|
oprofilefs_create_ro_ulong(cpudir, "sample_received",
|
2005-04-17 05:20:36 +07:00
|
|
|
&cpu_buf->sample_received);
|
2013-07-19 19:10:36 +07:00
|
|
|
oprofilefs_create_ro_ulong(cpudir, "sample_lost_overflow",
|
2005-04-17 05:20:36 +07:00
|
|
|
&cpu_buf->sample_lost_overflow);
|
2013-07-19 19:10:36 +07:00
|
|
|
oprofilefs_create_ro_ulong(cpudir, "backtrace_aborted",
|
2005-04-17 05:20:36 +07:00
|
|
|
&cpu_buf->backtrace_aborted);
|
2013-07-19 19:10:36 +07:00
|
|
|
oprofilefs_create_ro_ulong(cpudir, "sample_invalid_eip",
|
2007-11-15 07:58:48 +07:00
|
|
|
&cpu_buf->sample_invalid_eip);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2008-10-16 20:01:40 +07:00
|
|
|
|
2013-07-19 19:10:36 +07:00
|
|
|
oprofilefs_create_ro_atomic(dir, "sample_lost_no_mm",
|
2005-04-17 05:20:36 +07:00
|
|
|
&oprofile_stats.sample_lost_no_mm);
|
2013-07-19 19:10:36 +07:00
|
|
|
oprofilefs_create_ro_atomic(dir, "sample_lost_no_mapping",
|
2005-04-17 05:20:36 +07:00
|
|
|
&oprofile_stats.sample_lost_no_mapping);
|
2013-07-19 19:10:36 +07:00
|
|
|
oprofilefs_create_ro_atomic(dir, "event_lost_overflow",
|
2005-04-17 05:20:36 +07:00
|
|
|
&oprofile_stats.event_lost_overflow);
|
2013-07-19 19:10:36 +07:00
|
|
|
oprofilefs_create_ro_atomic(dir, "bt_lost_no_mapping",
|
2005-04-17 05:20:36 +07:00
|
|
|
&oprofile_stats.bt_lost_no_mapping);
|
2009-07-08 18:49:38 +07:00
|
|
|
#ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
|
2013-07-19 19:10:36 +07:00
|
|
|
oprofilefs_create_ro_atomic(dir, "multiplex_counter",
|
2009-07-09 19:56:25 +07:00
|
|
|
&oprofile_stats.multiplex_counter);
|
2009-07-08 18:49:38 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|