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