ebpf_hardirq.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. enum hardirq_maps {
  30. HARDIRQ_MAP_LATENCY,
  31. HARDIRQ_MAP_LATENCY_STATIC
  32. };
  33. typedef struct hardirq_ebpf_static_val {
  34. uint64_t latency;
  35. uint64_t ts;
  36. } hardirq_ebpf_static_val_t;
  37. /*****************************************************************
  38. * below this is eBPF plugin-specific code.
  39. *****************************************************************/
  40. // ARAL Name
  41. #define NETDATA_EBPF_HARDIRQ_ARAL_NAME "ebpf_harddirq"
  42. #define NETDATA_EBPF_MODULE_NAME_HARDIRQ "hardirq"
  43. #define NETDATA_HARDIRQ_CONFIG_FILE "hardirq.conf"
  44. typedef struct hardirq_val {
  45. // must be at top for simplified AVL tree usage.
  46. // if it's not at the top, we need to use `containerof` for almost all ops.
  47. avl_t avl;
  48. int irq;
  49. bool dim_exists; // keep this after `int irq` for alignment byte savings.
  50. uint64_t latency;
  51. char name[NETDATA_HARDIRQ_NAME_LEN];
  52. } hardirq_val_t;
  53. typedef struct hardirq_static_val {
  54. enum hardirq_ebpf_static idx;
  55. char *name;
  56. uint64_t latency;
  57. } hardirq_static_val_t;
  58. extern struct config hardirq_config;
  59. void *ebpf_hardirq_thread(void *ptr);
  60. #endif /* NETDATA_EBPF_HARDIRQ_H */