ebpf_hardirq.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_EBPF_HARDIRQ_H
  3. #define NETDATA_EBPF_HARDIRQ_H 1
  4. /*****************************************************************
  5. * copied from kernel-collectors repo, with modifications needed
  6. * for inclusion here.
  7. *****************************************************************/
  8. #define NETDATA_HARDIRQ_NAME_LEN 32
  9. #define NETDATA_HARDIRQ_MAX_IRQS 1024L
  10. typedef struct hardirq_ebpf_key {
  11. int irq;
  12. } hardirq_ebpf_key_t;
  13. typedef struct hardirq_ebpf_val {
  14. uint64_t latency;
  15. uint64_t ts;
  16. char name[NETDATA_HARDIRQ_NAME_LEN];
  17. } hardirq_ebpf_val_t;
  18. enum hardirq_ebpf_static {
  19. HARDIRQ_EBPF_STATIC_APIC_THERMAL,
  20. HARDIRQ_EBPF_STATIC_APIC_THRESHOLD,
  21. HARDIRQ_EBPF_STATIC_APIC_ERROR,
  22. HARDIRQ_EBPF_STATIC_APIC_DEFERRED_ERROR,
  23. HARDIRQ_EBPF_STATIC_APIC_SPURIOUS,
  24. HARDIRQ_EBPF_STATIC_FUNC_CALL,
  25. HARDIRQ_EBPF_STATIC_FUNC_CALL_SINGLE,
  26. HARDIRQ_EBPF_STATIC_RESCHEDULE,
  27. HARDIRQ_EBPF_STATIC_LOCAL_TIMER,
  28. HARDIRQ_EBPF_STATIC_IRQ_WORK,
  29. HARDIRQ_EBPF_STATIC_X86_PLATFORM_IPI,
  30. HARDIRQ_EBPF_STATIC_END
  31. };
  32. typedef struct hardirq_ebpf_static_val {
  33. uint64_t latency;
  34. uint64_t ts;
  35. } hardirq_ebpf_static_val_t;
  36. /*****************************************************************
  37. * below this is eBPF plugin-specific code.
  38. *****************************************************************/
  39. #define NETDATA_EBPF_MODULE_NAME_HARDIRQ "hardirq"
  40. #define NETDATA_HARDIRQ_SLEEP_MS 650000ULL
  41. #define NETDATA_HARDIRQ_CONFIG_FILE "hardirq.conf"
  42. typedef struct hardirq_val {
  43. // must be at top for simplified AVL tree usage.
  44. // if it's not at the top, we need to use `containerof` for almost all ops.
  45. avl_t avl;
  46. int irq;
  47. bool dim_exists; // keep this after `int irq` for alignment byte savings.
  48. uint64_t latency;
  49. char name[NETDATA_HARDIRQ_NAME_LEN];
  50. } hardirq_val_t;
  51. typedef struct hardirq_static_val {
  52. enum hardirq_ebpf_static idx;
  53. char *name;
  54. uint64_t latency;
  55. } hardirq_static_val_t;
  56. extern struct config hardirq_config;
  57. extern void *ebpf_hardirq_thread(void *ptr);
  58. #endif /* NETDATA_EBPF_HARDIRQ_H */