oprofile_stats.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 = &per_cpu(op_cpu_buffer, i);
  22. cpu_buf->sample_received = 0;
  23. cpu_buf->sample_lost_overflow = 0;
  24. cpu_buf->backtrace_aborted = 0;
  25. cpu_buf->sample_invalid_eip = 0;
  26. }
  27. atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
  28. atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
  29. atomic_set(&oprofile_stats.event_lost_overflow, 0);
  30. atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
  31. atomic_set(&oprofile_stats.multiplex_counter, 0);
  32. }
  33. void oprofile_create_stats_files(struct dentry *root)
  34. {
  35. struct oprofile_cpu_buffer *cpu_buf;
  36. struct dentry *cpudir;
  37. struct dentry *dir;
  38. char buf[10];
  39. int i;
  40. dir = oprofilefs_mkdir(root, "stats");
  41. if (!dir)
  42. return;
  43. for_each_possible_cpu(i) {
  44. cpu_buf = &per_cpu(op_cpu_buffer, i);
  45. snprintf(buf, 10, "cpu%d", i);
  46. cpudir = oprofilefs_mkdir(dir, buf);
  47. /* Strictly speaking access to these ulongs is racy,
  48. * but we can't simply lock them, and they are
  49. * informational only.
  50. */
  51. oprofilefs_create_ro_ulong(cpudir, "sample_received",
  52. &cpu_buf->sample_received);
  53. oprofilefs_create_ro_ulong(cpudir, "sample_lost_overflow",
  54. &cpu_buf->sample_lost_overflow);
  55. oprofilefs_create_ro_ulong(cpudir, "backtrace_aborted",
  56. &cpu_buf->backtrace_aborted);
  57. oprofilefs_create_ro_ulong(cpudir, "sample_invalid_eip",
  58. &cpu_buf->sample_invalid_eip);
  59. }
  60. oprofilefs_create_ro_atomic(dir, "sample_lost_no_mm",
  61. &oprofile_stats.sample_lost_no_mm);
  62. oprofilefs_create_ro_atomic(dir, "sample_lost_no_mapping",
  63. &oprofile_stats.sample_lost_no_mapping);
  64. oprofilefs_create_ro_atomic(dir, "event_lost_overflow",
  65. &oprofile_stats.event_lost_overflow);
  66. oprofilefs_create_ro_atomic(dir, "bt_lost_no_mapping",
  67. &oprofile_stats.bt_lost_no_mapping);
  68. #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
  69. oprofilefs_create_ro_atomic(dir, "multiplex_counter",
  70. &oprofile_stats.multiplex_counter);
  71. #endif
  72. }