ebpf_hardirq.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_CONFIG_FILE "hardirq.conf"
  41. typedef struct hardirq_val {
  42. // must be at top for simplified AVL tree usage.
  43. // if it's not at the top, we need to use `containerof` for almost all ops.
  44. avl_t avl;
  45. int irq;
  46. bool dim_exists; // keep this after `int irq` for alignment byte savings.
  47. uint64_t latency;
  48. char name[NETDATA_HARDIRQ_NAME_LEN];
  49. } hardirq_val_t;
  50. typedef struct hardirq_static_val {
  51. enum hardirq_ebpf_static idx;
  52. char *name;
  53. uint64_t latency;
  54. } hardirq_static_val_t;
  55. extern struct config hardirq_config;
  56. void *ebpf_hardirq_thread(void *ptr);
  57. #endif /* NETDATA_EBPF_HARDIRQ_H */