Skip to content

Commit dad2ad8

Browse files
author
Linus Torvalds
committed
Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
2 parents 7079060 + b7fb358 commit dad2ad8

File tree

7 files changed

+29
-41
lines changed

7 files changed

+29
-41
lines changed

arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,9 @@ acpi_cpufreq_cpu_init (
377377
arg0.buffer.length = 12;
378378
arg0.buffer.pointer = (u8 *) arg0_buf;
379379

380-
data = kmalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL);
380+
data = kzalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL);
381381
if (!data)
382382
return (-ENOMEM);
383-
memset(data, 0, sizeof(struct cpufreq_acpi_io));
384383

385384
acpi_io_data[cpu] = data;
386385

arch/i386/kernel/cpu/cpufreq/powernow-k7.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,9 @@ static int get_ranges (unsigned char *pst)
171171
unsigned int speed;
172172
u8 fid, vid;
173173

174-
powernow_table = kmalloc((sizeof(struct cpufreq_frequency_table) * (number_scales + 1)), GFP_KERNEL);
174+
powernow_table = kzalloc((sizeof(struct cpufreq_frequency_table) * (number_scales + 1)), GFP_KERNEL);
175175
if (!powernow_table)
176176
return -ENOMEM;
177-
memset(powernow_table, 0, (sizeof(struct cpufreq_frequency_table) * (number_scales + 1)));
178177

179178
for (j=0 ; j < number_scales; j++) {
180179
fid = *pst++;
@@ -305,16 +304,13 @@ static int powernow_acpi_init(void)
305304
goto err0;
306305
}
307306

308-
acpi_processor_perf = kmalloc(sizeof(struct acpi_processor_performance),
307+
acpi_processor_perf = kzalloc(sizeof(struct acpi_processor_performance),
309308
GFP_KERNEL);
310-
311309
if (!acpi_processor_perf) {
312310
retval = -ENOMEM;
313311
goto err0;
314312
}
315313

316-
memset(acpi_processor_perf, 0, sizeof(struct acpi_processor_performance));
317-
318314
if (acpi_processor_register_performance(acpi_processor_perf, 0)) {
319315
retval = -EIO;
320316
goto err1;
@@ -337,14 +333,12 @@ static int powernow_acpi_init(void)
337333
goto err2;
338334
}
339335

340-
powernow_table = kmalloc((number_scales + 1) * (sizeof(struct cpufreq_frequency_table)), GFP_KERNEL);
336+
powernow_table = kzalloc((number_scales + 1) * (sizeof(struct cpufreq_frequency_table)), GFP_KERNEL);
341337
if (!powernow_table) {
342338
retval = -ENOMEM;
343339
goto err2;
344340
}
345341

346-
memset(powernow_table, 0, ((number_scales + 1) * sizeof(struct cpufreq_frequency_table)));
347-
348342
pc.val = (unsigned long) acpi_processor_perf->states[0].control;
349343
for (i = 0; i < number_scales; i++) {
350344
u8 fid, vid;

arch/i386/kernel/cpu/cpufreq/powernow-k8.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,6 @@ static int check_supported_cpu(unsigned int cpu)
462462

463463
oldmask = current->cpus_allowed;
464464
set_cpus_allowed(current, cpumask_of_cpu(cpu));
465-
schedule();
466465

467466
if (smp_processor_id() != cpu) {
468467
printk(KERN_ERR "limiting to cpu %u failed\n", cpu);
@@ -497,9 +496,7 @@ static int check_supported_cpu(unsigned int cpu)
497496

498497
out:
499498
set_cpus_allowed(current, oldmask);
500-
schedule();
501499
return rc;
502-
503500
}
504501

505502
static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst, u8 maxvid)
@@ -913,7 +910,6 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
913910
/* only run on specific CPU from here on */
914911
oldmask = current->cpus_allowed;
915912
set_cpus_allowed(current, cpumask_of_cpu(pol->cpu));
916-
schedule();
917913

918914
if (smp_processor_id() != pol->cpu) {
919915
printk(KERN_ERR "limiting to cpu %u failed\n", pol->cpu);
@@ -968,8 +964,6 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
968964

969965
err_out:
970966
set_cpus_allowed(current, oldmask);
971-
schedule();
972-
973967
return ret;
974968
}
975969

@@ -991,12 +985,11 @@ static int __init powernowk8_cpu_init(struct cpufreq_policy *pol)
991985
if (!check_supported_cpu(pol->cpu))
992986
return -ENODEV;
993987

994-
data = kmalloc(sizeof(struct powernow_k8_data), GFP_KERNEL);
988+
data = kzalloc(sizeof(struct powernow_k8_data), GFP_KERNEL);
995989
if (!data) {
996990
printk(KERN_ERR PFX "unable to alloc powernow_k8_data");
997991
return -ENOMEM;
998992
}
999-
memset(data,0,sizeof(struct powernow_k8_data));
1000993

1001994
data->cpu = pol->cpu;
1002995

@@ -1026,7 +1019,6 @@ static int __init powernowk8_cpu_init(struct cpufreq_policy *pol)
10261019
/* only run on specific CPU from here on */
10271020
oldmask = current->cpus_allowed;
10281021
set_cpus_allowed(current, cpumask_of_cpu(pol->cpu));
1029-
schedule();
10301022

10311023
if (smp_processor_id() != pol->cpu) {
10321024
printk(KERN_ERR "limiting to cpu %u failed\n", pol->cpu);
@@ -1045,7 +1037,6 @@ static int __init powernowk8_cpu_init(struct cpufreq_policy *pol)
10451037

10461038
/* run on any CPU again */
10471039
set_cpus_allowed(current, oldmask);
1048-
schedule();
10491040

10501041
pol->governor = CPUFREQ_DEFAULT_GOVERNOR;
10511042
pol->cpus = cpu_core_map[pol->cpu];
@@ -1080,7 +1071,6 @@ static int __init powernowk8_cpu_init(struct cpufreq_policy *pol)
10801071

10811072
err_out:
10821073
set_cpus_allowed(current, oldmask);
1083-
schedule();
10841074
powernow_k8_cpu_exit_acpi(data);
10851075

10861076
kfree(data);
@@ -1116,17 +1106,14 @@ static unsigned int powernowk8_get (unsigned int cpu)
11161106
set_cpus_allowed(current, oldmask);
11171107
return 0;
11181108
}
1119-
preempt_disable();
1120-
1109+
11211110
if (query_current_values_with_pending_wait(data))
11221111
goto out;
11231112

11241113
khz = find_khz_freq_from_fid(data->currfid);
11251114

1126-
out:
1127-
preempt_enable_no_resched();
1115+
out:
11281116
set_cpus_allowed(current, oldmask);
1129-
11301117
return khz;
11311118
}
11321119

arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,11 @@ static int centrino_cpu_init_acpi(struct cpufreq_policy *policy)
423423
}
424424
}
425425

426-
centrino_model[cpu] = kmalloc(sizeof(struct cpu_model), GFP_KERNEL);
426+
centrino_model[cpu] = kzalloc(sizeof(struct cpu_model), GFP_KERNEL);
427427
if (!centrino_model[cpu]) {
428428
result = -ENOMEM;
429429
goto err_unreg;
430430
}
431-
memset(centrino_model[cpu], 0, sizeof(struct cpu_model));
432431

433432
centrino_model[cpu]->model_name=NULL;
434433
centrino_model[cpu]->max_freq = p.states[0].core_frequency * 1000;

drivers/cpufreq/cpufreq.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,12 +593,11 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
593593
goto module_out;
594594
}
595595

596-
policy = kmalloc(sizeof(struct cpufreq_policy), GFP_KERNEL);
596+
policy = kzalloc(sizeof(struct cpufreq_policy), GFP_KERNEL);
597597
if (!policy) {
598598
ret = -ENOMEM;
599599
goto nomem_out;
600600
}
601-
memset(policy, 0, sizeof(struct cpufreq_policy));
602601

603602
policy->cpu = cpu;
604603
policy->cpus = cpumask_of_cpu(cpu);

drivers/cpufreq/cpufreq_ondemand.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@
4848
* All times here are in uS.
4949
*/
5050
static unsigned int def_sampling_rate;
51-
#define MIN_SAMPLING_RATE (def_sampling_rate / 2)
51+
#define MIN_SAMPLING_RATE_RATIO (2)
52+
/* for correct statistics, we need at least 10 ticks between each measure */
53+
#define MIN_STAT_SAMPLING_RATE (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10))
54+
#define MIN_SAMPLING_RATE (def_sampling_rate / MIN_SAMPLING_RATE_RATIO)
5255
#define MAX_SAMPLING_RATE (500 * def_sampling_rate)
5356
#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000)
5457
#define DEF_SAMPLING_DOWN_FACTOR (1)
@@ -416,13 +419,16 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
416419
if (dbs_enable == 1) {
417420
unsigned int latency;
418421
/* policy latency is in nS. Convert it to uS first */
422+
latency = policy->cpuinfo.transition_latency / 1000;
423+
if (latency == 0)
424+
latency = 1;
419425

420-
latency = policy->cpuinfo.transition_latency;
421-
if (latency < 1000)
422-
latency = 1000;
423-
424-
def_sampling_rate = (latency / 1000) *
426+
def_sampling_rate = latency *
425427
DEF_SAMPLING_RATE_LATENCY_MULTIPLIER;
428+
429+
if (def_sampling_rate < MIN_STAT_SAMPLING_RATE)
430+
def_sampling_rate = MIN_STAT_SAMPLING_RATE;
431+
426432
dbs_tuners_ins.sampling_rate = def_sampling_rate;
427433
dbs_tuners_ins.ignore_nice = 0;
428434

drivers/cpufreq/cpufreq_stats.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,15 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
193193
unsigned int cpu = policy->cpu;
194194
if (cpufreq_stats_table[cpu])
195195
return -EBUSY;
196-
if ((stat = kmalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL)
196+
if ((stat = kzalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL)
197197
return -ENOMEM;
198-
memset(stat, 0, sizeof (struct cpufreq_stats));
199198

200199
data = cpufreq_cpu_get(cpu);
200+
if (data == NULL) {
201+
ret = -EINVAL;
202+
goto error_get_fail;
203+
}
204+
201205
if ((ret = sysfs_create_group(&data->kobj, &stats_attr_group)))
202206
goto error_out;
203207

@@ -217,12 +221,11 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
217221
alloc_size += count * count * sizeof(int);
218222
#endif
219223
stat->max_state = count;
220-
stat->time_in_state = kmalloc(alloc_size, GFP_KERNEL);
224+
stat->time_in_state = kzalloc(alloc_size, GFP_KERNEL);
221225
if (!stat->time_in_state) {
222226
ret = -ENOMEM;
223227
goto error_out;
224228
}
225-
memset(stat->time_in_state, 0, alloc_size);
226229
stat->freq_table = (unsigned int *)(stat->time_in_state + count);
227230

228231
#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
@@ -245,6 +248,7 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
245248
return 0;
246249
error_out:
247250
cpufreq_cpu_put(data);
251+
error_get_fail:
248252
kfree(stat);
249253
cpufreq_stats_table[cpu] = NULL;
250254
return ret;

0 commit comments

Comments
 (0)