oprofile_stats.c 2.4 KB

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