oprofile_stats.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * @file oprofile_stats.c
  3. *
  4. * @remark Copyright 2002 OProfile authors
  5. * @remark Read the file COPYING
  6. *
  7. * @author John Levon
  8. */
  9. #include <linux/oprofile.h>
  10. #include <linux/smp.h>
  11. #include <linux/cpumask.h>
  12. #include <linux/threads.h>
  13. #include "oprofile_stats.h"
  14. #include "cpu_buffer.h"
  15. struct oprofile_stat_struct oprofile_stats;
  16. void oprofile_reset_stats(void)
  17. {
  18. struct oprofile_cpu_buffer * cpu_buf;
  19. int i;
  20. for_each_possible_cpu(i) {
  21. cpu_buf = &cpu_buffer[i];
  22. cpu_buf->sample_received = 0;
  23. cpu_buf->sample_lost_overflow = 0;
  24. }
  25. atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
  26. atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
  27. atomic_set(&oprofile_stats.event_lost_overflow, 0);
  28. }
  29. void oprofile_create_stats_files(struct super_block * sb, struct dentry * root)
  30. {
  31. struct oprofile_cpu_buffer * cpu_buf;
  32. struct dentry * cpudir;
  33. struct dentry * dir;
  34. char buf[10];
  35. int i;
  36. dir = oprofilefs_mkdir(sb, root, "stats");
  37. if (!dir)
  38. return;
  39. for_each_possible_cpu(i) {
  40. cpu_buf = &cpu_buffer[i];
  41. snprintf(buf, 10, "cpu%d", i);
  42. cpudir = oprofilefs_mkdir(sb, dir, buf);
  43. /* Strictly speaking access to these ulongs is racy,
  44. * but we can't simply lock them, and they are
  45. * informational only.
  46. */
  47. oprofilefs_create_ro_ulong(sb, cpudir, "sample_received",
  48. &cpu_buf->sample_received);
  49. oprofilefs_create_ro_ulong(sb, cpudir, "sample_lost_overflow",
  50. &cpu_buf->sample_lost_overflow);
  51. oprofilefs_create_ro_ulong(sb, cpudir, "backtrace_aborted",
  52. &cpu_buf->backtrace_aborted);
  53. }
  54. oprofilefs_create_ro_atomic(sb, dir, "sample_lost_no_mm",
  55. &oprofile_stats.sample_lost_no_mm);
  56. oprofilefs_create_ro_atomic(sb, dir, "sample_lost_no_mapping",
  57. &oprofile_stats.sample_lost_no_mapping);
  58. oprofilefs_create_ro_atomic(sb, dir, "event_lost_overflow",
  59. &oprofile_stats.event_lost_overflow);
  60. oprofilefs_create_ro_atomic(sb, dir, "bt_lost_no_mapping",
  61. &oprofile_stats.bt_lost_no_mapping);
  62. }