Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[CPUFREQ] Remove unneeded locks

There cannot be any concurrent access to these through
different cpu sysfs files anymore, because these tunables
are now all global (not per cpu).

I still have some doubts whether some of these locks
were needed at all. Anyway, let's get rid of them.

Signed-off-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Dave Jones <davej@redhat.com>
CC: cpufreq@vger.kernel.org

authored by

Thomas Renninger and committed by
Dave Jones
326c86de e8951251

+6 -53
+5 -29
drivers/cpufreq/cpufreq_conservative.c
··· 76 76 static unsigned int dbs_enable; /* number of CPUs using this policy */ 77 77 78 78 /* 79 - * dbs_mutex protects data in dbs_tuners_ins from concurrent changes on 80 - * different CPUs. It protects dbs_enable in governor start/stop. 79 + * dbs_mutex protects dbs_enable in governor start/stop. 81 80 */ 82 81 static DEFINE_MUTEX(dbs_mutex); 83 82 ··· 194 195 if (ret != 1 || input > MAX_SAMPLING_DOWN_FACTOR || input < 1) 195 196 return -EINVAL; 196 197 197 - mutex_lock(&dbs_mutex); 198 198 dbs_tuners_ins.sampling_down_factor = input; 199 - mutex_unlock(&dbs_mutex); 200 - 201 199 return count; 202 200 } 203 201 ··· 208 212 if (ret != 1) 209 213 return -EINVAL; 210 214 211 - mutex_lock(&dbs_mutex); 212 215 dbs_tuners_ins.sampling_rate = max(input, min_sampling_rate); 213 - mutex_unlock(&dbs_mutex); 214 - 215 216 return count; 216 217 } 217 218 ··· 219 226 int ret; 220 227 ret = sscanf(buf, "%u", &input); 221 228 222 - mutex_lock(&dbs_mutex); 223 229 if (ret != 1 || input > 100 || 224 - input <= dbs_tuners_ins.down_threshold) { 225 - mutex_unlock(&dbs_mutex); 230 + input <= dbs_tuners_ins.down_threshold) 226 231 return -EINVAL; 227 - } 228 232 229 233 dbs_tuners_ins.up_threshold = input; 230 - mutex_unlock(&dbs_mutex); 231 - 232 234 return count; 233 235 } 234 236 ··· 234 246 int ret; 235 247 ret = sscanf(buf, "%u", &input); 236 248 237 - mutex_lock(&dbs_mutex); 238 249 /* cannot be lower than 11 otherwise freq will not fall */ 239 250 if (ret != 1 || input < 11 || input > 100 || 240 - input >= dbs_tuners_ins.up_threshold) { 241 - mutex_unlock(&dbs_mutex); 251 + input >= dbs_tuners_ins.up_threshold) 242 252 return -EINVAL; 243 - } 244 253 245 254 dbs_tuners_ins.down_threshold = input; 246 - mutex_unlock(&dbs_mutex); 247 - 248 255 return count; 249 256 } 250 257 ··· 258 275 if (input > 1) 259 276 input = 1; 260 277 261 - mutex_lock(&dbs_mutex); 262 - if (input == dbs_tuners_ins.ignore_nice) { /* nothing to do */ 263 - mutex_unlock(&dbs_mutex); 278 + if (input == dbs_tuners_ins.ignore_nice) /* nothing to do */ 264 279 return count; 265 - } 280 + 266 281 dbs_tuners_ins.ignore_nice = input; 267 282 268 283 /* we need to re-evaluate prev_cpu_idle */ ··· 272 291 if (dbs_tuners_ins.ignore_nice) 273 292 dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice; 274 293 } 275 - mutex_unlock(&dbs_mutex); 276 - 277 294 return count; 278 295 } 279 296 ··· 290 311 291 312 /* no need to test here if freq_step is zero as the user might actually 292 313 * want this, they would be crazy though :) */ 293 - mutex_lock(&dbs_mutex); 294 314 dbs_tuners_ins.freq_step = input; 295 - mutex_unlock(&dbs_mutex); 296 - 297 315 return count; 298 316 } 299 317
+1 -24
drivers/cpufreq/cpufreq_ondemand.c
··· 99 99 static unsigned int dbs_enable; /* number of CPUs using this policy */ 100 100 101 101 /* 102 - * dbs_mutex protects data in dbs_tuners_ins from concurrent changes on 103 - * different CPUs. It protects dbs_enable in governor start/stop. 102 + * dbs_mutex protects dbs_enable in governor start/stop. 104 103 */ 105 104 static DEFINE_MUTEX(dbs_mutex); 106 105 ··· 264 265 ret = sscanf(buf, "%u", &input); 265 266 if (ret != 1) 266 267 return -EINVAL; 267 - 268 - mutex_lock(&dbs_mutex); 269 268 dbs_tuners_ins.sampling_rate = max(input, min_sampling_rate); 270 - mutex_unlock(&dbs_mutex); 271 - 272 269 return count; 273 270 } 274 271 ··· 277 282 ret = sscanf(buf, "%u", &input); 278 283 if (ret != 1) 279 284 return -EINVAL; 280 - 281 - mutex_lock(&dbs_mutex); 282 285 dbs_tuners_ins.io_is_busy = !!input; 283 - mutex_unlock(&dbs_mutex); 284 - 285 286 return count; 286 287 } 287 288 ··· 292 301 input < MIN_FREQUENCY_UP_THRESHOLD) { 293 302 return -EINVAL; 294 303 } 295 - 296 - mutex_lock(&dbs_mutex); 297 304 dbs_tuners_ins.up_threshold = input; 298 - mutex_unlock(&dbs_mutex); 299 - 300 305 return count; 301 306 } 302 307 ··· 305 318 306 319 if (ret != 1 || input > MAX_SAMPLING_DOWN_FACTOR || input < 1) 307 320 return -EINVAL; 308 - mutex_lock(&dbs_mutex); 309 321 dbs_tuners_ins.sampling_down_factor = input; 310 322 311 323 /* Reset down sampling multiplier in case it was active */ ··· 313 327 dbs_info = &per_cpu(od_cpu_dbs_info, j); 314 328 dbs_info->rate_mult = 1; 315 329 } 316 - mutex_unlock(&dbs_mutex); 317 - 318 330 return count; 319 331 } 320 332 ··· 331 347 if (input > 1) 332 348 input = 1; 333 349 334 - mutex_lock(&dbs_mutex); 335 350 if (input == dbs_tuners_ins.ignore_nice) { /* nothing to do */ 336 - mutex_unlock(&dbs_mutex); 337 351 return count; 338 352 } 339 353 dbs_tuners_ins.ignore_nice = input; ··· 346 364 dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice; 347 365 348 366 } 349 - mutex_unlock(&dbs_mutex); 350 - 351 367 return count; 352 368 } 353 369 ··· 362 382 if (input > 1000) 363 383 input = 1000; 364 384 365 - mutex_lock(&dbs_mutex); 366 385 dbs_tuners_ins.powersave_bias = input; 367 386 ondemand_powersave_bias_init(); 368 - mutex_unlock(&dbs_mutex); 369 - 370 387 return count; 371 388 } 372 389