@@ -42,6 +42,7 @@ static u64 set_pd_power_limit(struct dtpm *dtpm, u64 power_limit)
42
42
{
43
43
struct dtpm_cpu * dtpm_cpu = to_dtpm_cpu (dtpm );
44
44
struct em_perf_domain * pd = em_cpu_get (dtpm_cpu -> cpu );
45
+ struct em_perf_state * table ;
45
46
struct cpumask cpus ;
46
47
unsigned long freq ;
47
48
u64 power ;
@@ -50,20 +51,22 @@ static u64 set_pd_power_limit(struct dtpm *dtpm, u64 power_limit)
50
51
cpumask_and (& cpus , cpu_online_mask , to_cpumask (pd -> cpus ));
51
52
nr_cpus = cpumask_weight (& cpus );
52
53
54
+ rcu_read_lock ();
55
+ table = em_perf_state_from_pd (pd );
53
56
for (i = 0 ; i < pd -> nr_perf_states ; i ++ ) {
54
57
55
- power = pd -> table [i ].power * nr_cpus ;
58
+ power = table [i ].power * nr_cpus ;
56
59
57
60
if (power > power_limit )
58
61
break ;
59
62
}
60
63
61
- freq = pd -> table [i - 1 ].frequency ;
64
+ freq = table [i - 1 ].frequency ;
65
+ power_limit = table [i - 1 ].power * nr_cpus ;
66
+ rcu_read_unlock ();
62
67
63
68
freq_qos_update_request (& dtpm_cpu -> qos_req , freq );
64
69
65
- power_limit = pd -> table [i - 1 ].power * nr_cpus ;
66
-
67
70
return power_limit ;
68
71
}
69
72
@@ -87,9 +90,11 @@ static u64 scale_pd_power_uw(struct cpumask *pd_mask, u64 power)
87
90
static u64 get_pd_power_uw (struct dtpm * dtpm )
88
91
{
89
92
struct dtpm_cpu * dtpm_cpu = to_dtpm_cpu (dtpm );
93
+ struct em_perf_state * table ;
90
94
struct em_perf_domain * pd ;
91
95
struct cpumask * pd_mask ;
92
96
unsigned long freq ;
97
+ u64 power = 0 ;
93
98
int i ;
94
99
95
100
pd = em_cpu_get (dtpm_cpu -> cpu );
@@ -98,33 +103,43 @@ static u64 get_pd_power_uw(struct dtpm *dtpm)
98
103
99
104
freq = cpufreq_quick_get (dtpm_cpu -> cpu );
100
105
106
+ rcu_read_lock ();
107
+ table = em_perf_state_from_pd (pd );
101
108
for (i = 0 ; i < pd -> nr_perf_states ; i ++ ) {
102
109
103
- if (pd -> table [i ].frequency < freq )
110
+ if (table [i ].frequency < freq )
104
111
continue ;
105
112
106
- return scale_pd_power_uw (pd_mask , pd -> table [i ].power );
113
+ power = scale_pd_power_uw (pd_mask , table [i ].power );
114
+ break ;
107
115
}
116
+ rcu_read_unlock ();
108
117
109
- return 0 ;
118
+ return power ;
110
119
}
111
120
112
121
static int update_pd_power_uw (struct dtpm * dtpm )
113
122
{
114
123
struct dtpm_cpu * dtpm_cpu = to_dtpm_cpu (dtpm );
115
124
struct em_perf_domain * em = em_cpu_get (dtpm_cpu -> cpu );
125
+ struct em_perf_state * table ;
116
126
struct cpumask cpus ;
117
127
int nr_cpus ;
118
128
119
129
cpumask_and (& cpus , cpu_online_mask , to_cpumask (em -> cpus ));
120
130
nr_cpus = cpumask_weight (& cpus );
121
131
122
- dtpm -> power_min = em -> table [0 ].power ;
132
+ rcu_read_lock ();
133
+ table = em_perf_state_from_pd (em );
134
+
135
+ dtpm -> power_min = table [0 ].power ;
123
136
dtpm -> power_min *= nr_cpus ;
124
137
125
- dtpm -> power_max = em -> table [em -> nr_perf_states - 1 ].power ;
138
+ dtpm -> power_max = table [em -> nr_perf_states - 1 ].power ;
126
139
dtpm -> power_max *= nr_cpus ;
127
140
141
+ rcu_read_unlock ();
142
+
128
143
return 0 ;
129
144
}
130
145
@@ -180,6 +195,7 @@ static int __dtpm_cpu_setup(int cpu, struct dtpm *parent)
180
195
{
181
196
struct dtpm_cpu * dtpm_cpu ;
182
197
struct cpufreq_policy * policy ;
198
+ struct em_perf_state * table ;
183
199
struct em_perf_domain * pd ;
184
200
char name [CPUFREQ_NAME_LEN ];
185
201
int ret = - ENOMEM ;
@@ -216,9 +232,12 @@ static int __dtpm_cpu_setup(int cpu, struct dtpm *parent)
216
232
if (ret )
217
233
goto out_kfree_dtpm_cpu ;
218
234
235
+ rcu_read_lock ();
236
+ table = em_perf_state_from_pd (pd );
219
237
ret = freq_qos_add_request (& policy -> constraints ,
220
238
& dtpm_cpu -> qos_req , FREQ_QOS_MAX ,
221
- pd -> table [pd -> nr_perf_states - 1 ].frequency );
239
+ table [pd -> nr_perf_states - 1 ].frequency );
240
+ rcu_read_unlock ();
222
241
if (ret )
223
242
goto out_dtpm_unregister ;
224
243
0 commit comments