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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
/*
* Copyright (c) 2017 Samsung Electronics Co., Ltd
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/plist.h>
#include <linux/sched/idle.h>
#include <linux/sched/topology.h>
struct gb_qos_request {
struct plist_node node;
char *name;
bool active;
};
#define LEAVE_BAND 0
struct task_band {
int id;
int sse;
pid_t tgid;
raw_spinlock_t lock;
struct list_head members;
int member_count;
struct cpumask playable_cpus;
unsigned long util;
unsigned long last_update_time;
};
struct rq;
extern struct kobject *ems_kobj;
extern unsigned int get_cpu_max_capacity(unsigned int cpu, int sse);
#ifdef CONFIG_SCHED_EMS
/* core */
extern void init_ems(void);
/* task util initialization */
extern void exynos_init_entity_util_avg(struct sched_entity *se);
/* wakeup balance */
extern int
exynos_wakeup_balance(struct task_struct *p, int prev_cpu, int sd_flag, int sync);
/* ontime migration */
extern void ontime_migration(void);
extern int ontime_can_migration(struct task_struct *p, int cpu);
extern void ontime_update_load_avg(u64 delta, int cpu, unsigned long weight, struct sched_avg *sa);
extern void ontime_new_entity_load(struct task_struct *parent, struct sched_entity *se);
extern void ontime_trace_task_info(struct task_struct *p);
/* load balance trigger */
extern bool lbt_overutilized(int cpu, int level);
extern void update_lbt_overutil(int cpu, unsigned long capacity);
/* global boost */
extern void gb_qos_update_request(struct gb_qos_request *req, u32 new_value);
/* task band */
extern void sync_band(struct task_struct *p, bool join);
extern void newbie_join_band(struct task_struct *newbie);
extern void update_band(struct task_struct *p, long old_util);
extern int band_playing(struct task_struct *p, int cpu);
/* multi load */
void update_multi_load(u64 delta, int cpu, struct sched_avg *sa,
unsigned long weight, int running, struct cfs_rq *cfs_rq);
void init_multi_load(struct sched_entity *se);
void detach_entity_multi_load(struct cfs_rq *cfs_rq, struct sched_entity *se);
void attach_entity_multi_load(struct cfs_rq *cfs_rq, struct sched_entity *se);
void remove_entity_multi_load(struct cfs_rq *cfs_rq, struct sched_entity *se);
void apply_removed_multi_load(struct cfs_rq *cfs_rq);
void update_tg_multi_load(struct cfs_rq *cfs_rq, struct sched_entity *se);
void cfs_se_util_change_multi_load(struct task_struct *p, struct sched_avg *avg);
void enqueue_multi_load(struct cfs_rq *cfs_rq, struct task_struct *p);
void dequeue_multi_load(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep);
/* P.A.R.T */
void update_cpu_active_ratio(struct rq *rq, struct task_struct *p, int type);
void part_cpu_active_ratio(unsigned long *util, unsigned long *max, int cpu);
void set_part_period_start(struct rq *rq);
/* load balance */
extern void lb_add_cfs_task(struct rq *rq, struct sched_entity *se);
extern int lb_check_priority(int src_cpu, int dst_cpu);
extern struct list_head *lb_prefer_cfs_tasks(int src_cpu, int dst_cpu);
extern int lb_need_active_balance(enum cpu_idle_type idle,
struct sched_domain *sd, int src_cpu, int dst_cpu);
/* check the status of energy table */
extern bool energy_initialized;
extern void set_energy_table_status(bool status);
extern bool get_energy_table_status(void);
#else
static inline void init_ems(void);
static inline void exynos_init_entity_util_avg(struct sched_entity *se) { }
static inline int
exynos_wakeup_balance(struct task_struct *p, int prev_cpu, int sd_flag, int sync)
{
return -1;
}
static inline void ontime_migration(void) { }
static inline int ontime_can_migration(struct task_struct *p, int cpu)
{
return 1;
}
static inline void ontime_update_load_avg(u64 delta, int cpu, unsigned long weight, struct sched_avg *sa) { }
static inline void ontime_new_entity_load(struct task_struct *p, struct sched_entity *se) { }
static inline void ontime_trace_task_info(struct task_struct *p) { }
static inline bool lbt_overutilized(int cpu, int level)
{
return false;
}
static inline void update_lbt_overutil(int cpu, unsigned long capacity) { }
static inline void gb_qos_update_request(struct gb_qos_request *req, u32 new_value) { }
static inline void sync_band(struct task_struct *p, bool join) { }
static inline void newbie_join_band(struct task_struct *newbie) { }
static inline void update_band(struct task_struct *p, long old_util) { }
static inline int band_playing(struct task_struct *p, int cpu)
{
return 0;
}
static inline void update_multi_load(u64 delta, int cpu, struct sched_avg *sa,
unsigned long weight, int running, struct cfs_rq *cfs_rq) { }
static inline void init_multi_load(struct sched_entity *se) { }
static inline void detach_entity_multi_load(struct cfs_rq *cfs_rq, struct sched_entity *se) { }
static inline void attach_entity_multi_load(struct cfs_rq *cfs_rq, struct sched_entity *se) { }
static inline void remove_entity_multi_load(struct cfs_rq *cfs_rq, struct sched_entity *se) { }
static inline void apply_removed_multi_load(struct cfs_rq *cfs_rq) { }
static inline void update_tg_multi_load(struct cfs_rq *cfs_rq, struct sched_entity *se) { }
static inline void cfs_se_util_change_multi_load(struct task_struct *p, struct sched_avg *avg) { }
static inline void enqueue_multi_load(struct cfs_rq *cfs_rq, struct task_struct *p) { }
static inline void dequeue_multi_load(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep) { }
/* P.A.R.T */
static inline void update_cpu_active_ratio(struct rq *rq, struct task_struct *p, int type) { }
static inline void part_cpu_active_ratio(unsigned long *util, unsigned long *max, int cpu) { }
static inline void set_part_period_start(struct rq *rq) { }
static inline void lb_add_cfs_task(struct rq *rq, struct sched_entity *se) { }
static inline int lb_check_priority(int src_cpu, int dst_cpu)
{
return 0;
}
static inline struct list_head *lb_prefer_cfs_tasks(int src_cpu, int dst_cpu)
{
return NULL;
}
static inline int lb_need_active_balance(enum cpu_idle_type idle,
struct sched_domain *sd, int src_cpu, int dst_cpu)
{
return 0;
}
static inline void set_energy_table_status(bool status) { }
static inline bool get_energy_table_status(void)
{
return false;
}
#endif /* CONFIG_SCHED_EMS */
#ifdef CONFIG_SIMPLIFIED_ENERGY_MODEL
extern void init_sched_energy_table(struct cpumask *cpus, int table_size,
unsigned long *f_table, unsigned int *v_table,
int max_f, int min_f);
extern void update_qos_capacity(int cpu, unsigned long freq, unsigned long max);
#else
static inline void init_sched_energy_table(struct cpumask *cpus, int table_size,
unsigned long *f_table, unsigned int *v_table,
int max_f, int min_f) { }
static inline void update_qos_capacity(int cpu, unsigned long freq, unsigned long max) { }
#endif
/* Fluid Real Time */
extern unsigned int frt_disable_cpufreq;
/*
* Maximum number of boost groups to support
* When per-task boosting is used we still allow only limited number of
* boost groups for two main reasons:
* 1. on a real system we usually have only few classes of workloads which
* make sense to boost with different values (e.g. background vs foreground
* tasks, interactive vs low-priority tasks)
* 2. a limited number allows for a simpler and more memory/time efficient
* implementation especially for the computation of the per-CPU boost
* value
*/
#define BOOSTGROUPS_COUNT 5
struct boost_groups {
/* Maximum boost value for all RUNNABLE tasks on a CPU */
bool idle;
int boost_max;
u64 boost_ts;
struct {
/* The boost for tasks on that boost group */
int boost;
/* Count of RUNNABLE tasks on that boost group */
unsigned tasks;
/* Timestamp of boost activation */
u64 ts;
} group[BOOSTGROUPS_COUNT];
/* CPU's boost group locking */
raw_spinlock_t lock;
};
|