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 10 #define container_of(ptr, type, member)({ \ 11 const typeof(((type *)0)->member) *__mptr = (ptr); \ 12 (type *)((char *)__mptr - offsetof(type, member)) ; }) 13 14 extern int config_debug; 15 void debug_msg(const char *fmt, ...); 16 void err_msg(const char *fmt, ...); 17 18 long parse_seconds_duration(char *val); 19 void get_duration(time_t start_time, char *output, int output_size); 20 21 int parse_cpu_list(char *cpu_list, char **monitored_cpus); 22 long long get_llong_from_str(char *start); 23 24 static inline void 25 update_min(unsigned long long *a, unsigned long long *b) 26 { 27 if (*a > *b) 28 *a = *b; 29 } 30 31 static inline void 32 update_max(unsigned long long *a, unsigned long long *b) 33 { 34 if (*a < *b) 35 *a = *b; 36 } 37 38 static inline void 39 update_sum(unsigned long long *a, unsigned long long *b) 40 { 41 *a += *b; 42 } 43 44 struct sched_attr { 45 uint32_t size; 46 uint32_t sched_policy; 47 uint64_t sched_flags; 48 int32_t sched_nice; 49 uint32_t sched_priority; 50 uint64_t sched_runtime; 51 uint64_t sched_deadline; 52 uint64_t sched_period; 53 }; 54 55 int parse_prio(char *arg, struct sched_attr *sched_param); 56 int set_comm_sched_attr(const char *comm, struct sched_attr *attr); 57