• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 #include <stdint.h>
3 #include <time.h>
4 
5 /*
6  * '18446744073709551615\0'
7  */
8 #define BUFF_U64_STR_SIZE	24
9 #define MAX_PATH		1024
10 #define MAX_NICE		20
11 #define MIN_NICE		-19
12 
13 #define container_of(ptr, type, member)({			\
14 	const typeof(((type *)0)->member) *__mptr = (ptr);	\
15 	(type *)((char *)__mptr - offsetof(type, member)) ; })
16 
17 extern int config_debug;
18 void debug_msg(const char *fmt, ...);
19 void err_msg(const char *fmt, ...);
20 
21 long parse_seconds_duration(char *val);
22 void get_duration(time_t start_time, char *output, int output_size);
23 
24 int parse_cpu_list(char *cpu_list, char **monitored_cpus);
25 long long get_llong_from_str(char *start);
26 
27 static inline void
update_min(unsigned long long * a,unsigned long long * b)28 update_min(unsigned long long *a, unsigned long long *b)
29 {
30 	if (*a > *b)
31 		*a = *b;
32 }
33 
34 static inline void
update_max(unsigned long long * a,unsigned long long * b)35 update_max(unsigned long long *a, unsigned long long *b)
36 {
37 	if (*a < *b)
38 		*a = *b;
39 }
40 
41 static inline void
update_sum(unsigned long long * a,unsigned long long * b)42 update_sum(unsigned long long *a, unsigned long long *b)
43 {
44 	*a += *b;
45 }
46 
47 struct 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 
58 int parse_prio(char *arg, struct sched_attr *sched_param);
59 int set_comm_sched_attr(const char *comm_prefix, struct sched_attr *attr);
60 int set_cpu_dma_latency(int32_t latency);
61