Debian Codegraph @

irqbalance.h

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #ifndef __INCLUDE_GUARD_IRQBALANCE_H_
2 #define __INCLUDE_GUARD_IRQBALANCE_H_
3
4
5 #include "constants.h"
6
7 #include "cpumask.h"
8
9 #include <stdint.h>
10 #include <glib.h>
11 #include <glib-unix.h>
12 #include <syslog.h>
13 #include <limits.h>
14
15 #include "types.h"
16 #include "config.h"
17
18 #ifdef __aarch64__
19 #define AARCH64
20 #endif
21
22 #ifdef HAVE_NUMA_H
23 #include <numa.h>
24 #else
25 #define numa_available() -1
26 #endif
27
28 #ifdef HAVE_LIBSYSTEMD
29 #include <systemd/sd-journal.h>
30 #endif
31
32 #define NUMA_NO_NODE (-1)
33
34 extern char *classes[];
35
36 extern void parse_cpu_tree(void);
37 extern void clear_work_stats(void);
38 extern void parse_proc_interrupts(void);
39 extern GList* collect_full_irq_list();
40 extern void parse_proc_stat(void);
41 extern void set_interrupt_count(int number, uint64_t count);
42 extern void set_msi_interrupt_numa(int number);
43 extern void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq);
44 extern int proc_irq_hotplug(char *line, int irq, struct irq_info **pinfo);
45 extern void clear_no_existing_irqs(void);
46
47 extern GList *rebalance_irq_list;
48 extern void force_rebalance_irq(struct irq_info *info, void *data __attribute__((unused)));
49
50 void update_migration_status(void);
51 void dump_workloads(void);
52 void sort_irq_list(GList **list);
53 void calculate_placement(void);
54 void dump_tree(void);
55
56 void activate_mappings(void);
57 void clear_cpu_tree(void);
58 void free_cpu_topo(gpointer data);
59 /*===================NEW BALANCER FUNCTIONS============================*/
60
61 /*
62 * Master topo_obj type lists
63 */
64 extern GList *numa_nodes;
65 extern GList *packages;
66 extern GList *cache_domains;
67 extern GList *cpus;
68 extern int numa_avail;
69 extern GList *cl_banned_irqs;
70
71 extern int debug_mode;
72 extern int journal_logging;
73 extern int one_shot_mode;
74 extern int need_rescan;
75 extern int need_rebuild;
76 extern unsigned long long cycle_count;
77 extern unsigned long power_thresh;
78 extern unsigned long deepest_cache;
79 extern char *polscript;
80 extern cpumask_t banned_cpus;
81 extern cpumask_t unbanned_cpus;
82 extern long HZ;
83 extern unsigned long migrate_ratio;
84
85 /*
86 * Numa node access routines
87 */
88 extern void build_numa_node_list(void);
89 extern void free_numa_node_list(void);
90 extern void dump_numa_node_info(struct topo_obj *node, void *data);
91 extern void connect_cpu_mem_topo(struct topo_obj *p, void *data);
92 extern struct topo_obj *get_numa_node(int nodeid);
93
94 /*
95 * cpu core functions
96 */
97 #define cpu_numa_node(cpu) ((cpu)->parent->numa_nodes)
98 extern struct topo_obj *find_cpu_core(int cpunr);
99 extern int get_cpu_count(void);
100
101 /*
102 * irq db functions
103 */
104 extern void rebuild_irq_db(void);
105 extern void free_irq_db(void);
106 extern void add_cl_banned_irq(int irq);
107 extern void for_each_irq(GList *list, void (*cb)(struct irq_info *info, void *data), void *data);
108 extern struct irq_info *get_irq_info(int irq);
109 extern void migrate_irq(GList **from, GList **to, struct irq_info *info);
110 extern void free_cl_opts(void);
111 extern void add_cl_banned_module(char *modname);
112 #define irq_numa_node(irq) ((irq)->numa_node)
113
114
115 /*
116 * Generic object functions
117 */
118 static inline void for_each_object(GList *list, void (*cb)(struct topo_obj *obj, void *data), void *data)
119 {
120 GList *entry, *next;
121 entry = g_list_first(list);
122 while (entry) {
123 next = g_list_next(entry);
124 cb(entry->data, data);
125 entry = next;
126 }
127 }
128
129 /*
130 * Logging functions
131 */
132 #define TO_SYSLOG (1 << 0)
133 #define TO_CONSOLE (1 << 1)
134 #define TO_ALL (TO_SYSLOG | TO_CONSOLE)
135
136 extern const char * log_indent;
137 extern unsigned int log_mask;
138 #ifdef HAVE_LIBSYSTEMD
139 #define log(mask, lvl, fmt, args...) do { \
140 if (journal_logging) { \
141 if (log_mask & mask & TO_SYSLOG) \
142 sd_journal_print(lvl, fmt, ##args); \
143 if (log_mask & mask & TO_CONSOLE) \
144 printf(fmt, ##args); \
145 } else { \
146 if (log_mask & mask & TO_SYSLOG) \
147 syslog(lvl, fmt, ##args); \
148 if (log_mask & mask & TO_CONSOLE) \
149 printf(fmt, ##args); \
150 } \
151 }while(0)
152 #else /* ! HAVE_LIBSYSTEMD */
153 #define log(mask, lvl, fmt, args...) do { \
154 if (journal_logging) { \
155 printf("<%d>", lvl); \
156 printf(fmt, ##args); \
157 } else { \
158 if (log_mask & mask & TO_SYSLOG) \
159 syslog(lvl, fmt, ##args); \
160 if (log_mask & mask & TO_CONSOLE) \
161 printf(fmt, ##args); \
162 } \
163 }while(0)
164 #endif /* HAVE_LIBSYSTEMD */
165
166 #define SOCKET_PATH "irqbalance"
167 #define SOCKET_TMPFS "/run/irqbalance"
168
169 extern int process_one_line(char *path, void (*cb)(char *line, void *data), void *data);
170 extern void get_mask_from_bitmap(char *line, void *mask);
171 extern void get_int(char *line, void *data);
172 extern void get_hex(char *line, void *data);
173
174 #endif /* __INCLUDE_GUARD_IRQBALANCE_H_ */
175