Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1// SPDX-License-Identifier: GPL-2.0
2
3#include <stdint.h>
4#include <time.h>
5#include <sched.h>
6
7/*
8 * '18446744073709551615\0'
9 */
10#define BUFF_U64_STR_SIZE 24
11#define MAX_PATH 1024
12
13#define container_of(ptr, type, member)({ \
14 const typeof(((type *)0)->member) *__mptr = (ptr); \
15 (type *)((char *)__mptr - offsetof(type, member)) ; })
16
17extern int config_debug;
18void debug_msg(const char *fmt, ...);
19void err_msg(const char *fmt, ...);
20
21long parse_seconds_duration(char *val);
22void get_duration(time_t start_time, char *output, int output_size);
23
24int parse_cpu_list(char *cpu_list, char **monitored_cpus);
25long long get_llong_from_str(char *start);
26
27static inline void
28update_min(unsigned long long *a, unsigned long long *b)
29{
30 if (*a > *b)
31 *a = *b;
32}
33
34static inline void
35update_max(unsigned long long *a, unsigned long long *b)
36{
37 if (*a < *b)
38 *a = *b;
39}
40
41static inline void
42update_sum(unsigned long long *a, unsigned long long *b)
43{
44 *a += *b;
45}
46
47struct sched_attr {
48 uint32_t size;
49 uint32_t sched_policy;
50 uint64_t sched_flags;
51 int32_t sched_nice;
52 uint32_t sched_priority;
53 uint64_t sched_runtime;
54 uint64_t sched_deadline;
55 uint64_t sched_period;
56};
57
58int parse_prio(char *arg, struct sched_attr *sched_param);
59int parse_cpu_set(char *cpu_list, cpu_set_t *set);
60int __set_sched_attr(int pid, struct sched_attr *attr);
61int set_comm_sched_attr(const char *comm_prefix, struct sched_attr *attr);
62int set_comm_cgroup(const char *comm_prefix, const char *cgroup);
63int set_pid_cgroup(pid_t pid, const char *cgroup);
64int set_cpu_dma_latency(int32_t latency);
65int auto_house_keeping(cpu_set_t *monitored_cpus);
66
67#define ns_to_usf(x) (((double)x/1000))
68#define ns_to_per(total, part) ((part * 100) / (double)total)