cpu_buffer.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * @file cpu_buffer.h
  3. *
  4. * @remark Copyright 2002 OProfile authors
  5. * @remark Read the file COPYING
  6. *
  7. * @author John Levon <levon@movementarian.org>
  8. */
  9. #ifndef OPROFILE_CPU_BUFFER_H
  10. #define OPROFILE_CPU_BUFFER_H
  11. #include <linux/types.h>
  12. #include <linux/spinlock.h>
  13. #include <linux/workqueue.h>
  14. #include <linux/cache.h>
  15. struct task_struct;
  16. int alloc_cpu_buffers(void);
  17. void free_cpu_buffers(void);
  18. void start_cpu_work(void);
  19. void end_cpu_work(void);
  20. /* CPU buffer is composed of such entries (which are
  21. * also used for context switch notes)
  22. */
  23. struct op_sample {
  24. unsigned long eip;
  25. unsigned long event;
  26. };
  27. struct oprofile_cpu_buffer {
  28. volatile unsigned long head_pos;
  29. volatile unsigned long tail_pos;
  30. unsigned long buffer_size;
  31. struct task_struct * last_task;
  32. int last_is_kernel;
  33. int tracing;
  34. struct op_sample * buffer;
  35. unsigned long sample_received;
  36. unsigned long sample_lost_overflow;
  37. unsigned long backtrace_aborted;
  38. int cpu;
  39. struct work_struct work;
  40. } ____cacheline_aligned;
  41. extern struct oprofile_cpu_buffer cpu_buffer[];
  42. void cpu_buffer_reset(struct oprofile_cpu_buffer * cpu_buf);
  43. /* transient events for the CPU buffer -> event buffer */
  44. #define CPU_IS_KERNEL 1
  45. #define CPU_TRACE_BEGIN 2
  46. #endif /* OPROFILE_CPU_BUFFER_H */