cpu_buffer.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #include <linux/sched.h>
  16. struct task_struct;
  17. int alloc_cpu_buffers(void);
  18. void free_cpu_buffers(void);
  19. void start_cpu_work(void);
  20. void end_cpu_work(void);
  21. /* CPU buffer is composed of such entries (which are
  22. * also used for context switch notes)
  23. */
  24. struct op_sample {
  25. unsigned long eip;
  26. unsigned long event;
  27. };
  28. struct oprofile_cpu_buffer {
  29. volatile unsigned long head_pos;
  30. volatile unsigned long tail_pos;
  31. unsigned long buffer_size;
  32. struct task_struct * last_task;
  33. int last_is_kernel;
  34. int tracing;
  35. struct op_sample * buffer;
  36. unsigned long sample_received;
  37. unsigned long sample_lost_overflow;
  38. unsigned long backtrace_aborted;
  39. unsigned long sample_invalid_eip;
  40. int cpu;
  41. struct delayed_work work;
  42. };
  43. DECLARE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer);
  44. void cpu_buffer_reset(struct oprofile_cpu_buffer * cpu_buf);
  45. /* transient events for the CPU buffer -> event buffer */
  46. #define CPU_IS_KERNEL 1
  47. #define CPU_TRACE_BEGIN 2
  48. #endif /* OPROFILE_CPU_BUFFER_H */