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