ebpf_hardirq.h 2.2 KB

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