1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __SCHED_RTG_H 3 #define __SCHED_RTG_H 4 5 #ifdef CONFIG_SCHED_RTG 6 7 #define DEFAULT_RTG_GRP_ID 0 8 #define DEFAULT_CGROUP_COLOC_ID 1 9 #define MAX_NUM_CGROUP_COLOC_ID 21 10 11 struct group_cpu_time { 12 u64 window_start; 13 u64 curr_runnable_sum; 14 u64 prev_runnable_sum; 15 u64 nt_curr_runnable_sum; 16 u64 nt_prev_runnable_sum; 17 }; 18 19 struct group_ravg { 20 unsigned long curr_window_load; 21 unsigned long curr_window_exec; 22 unsigned long prev_window_load; 23 unsigned long prev_window_exec; 24 unsigned long normalized_util; 25 }; 26 27 struct rtg_class; 28 29 struct related_thread_group { 30 int id; 31 raw_spinlock_t lock; 32 struct list_head tasks; 33 struct list_head list; 34 35 unsigned int nr_running; 36 struct group_ravg ravg; 37 u64 window_start; 38 u64 mark_start; 39 u64 prev_window_time; 40 /* rtg window information for WALT */ 41 unsigned int window_size; 42 const struct rtg_class *rtg_class; 43 struct sched_cluster *preferred_cluster; 44 int max_boost; 45 unsigned long util_invalid_interval; /* in nanoseconds */ 46 unsigned long util_update_timeout; /* in nanoseconds */ 47 unsigned long freq_update_interval; /* in nanoseconds */ 48 u64 last_util_update_time; 49 u64 last_freq_update_time; 50 void *private_data; 51 }; 52 53 struct rtg_class { 54 void (*sched_update_rtg_tick)(struct related_thread_group *grp); 55 }; 56 57 enum rtg_freq_update_flags { 58 RTG_FREQ_FORCE_UPDATE = (1 << 0), 59 RTG_FREQ_NORMAL_UPDATE = (1 << 1), 60 }; 61 62 int sched_set_group_id(struct task_struct *p, unsigned int group_id); 63 unsigned int sched_get_group_id(struct task_struct *p); 64 #endif /* CONFIG_SCHED_RTG */ 65 #endif 66