Skip to content

Commit c9d2642

Browse files
committed
Merge tag 'pm+acpi-3.17-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull more ACPI and power management updates from Rafael Wysocki: "These are a couple of regression fixes, cpuidle menu governor optimizations, fixes for ACPI proccessor and battery drivers, hibernation fix to avoid problems related to the e820 memory map, fixes for a few cpufreq drivers and a new version of the suspend profiling tool analyze_suspend.py. Specifics: - Fix for an ACPI-based device hotplug regression introduced in 3.14 that causes a kernel panic to trigger when memory hot-remove is attempted with CONFIG_ACPI_HOTPLUG_MEMORY unset from Tang Chen - Fix for a cpufreq regression introduced in 3.16 that triggers a "sleeping function called from invalid context" bug in dev_pm_opp_init_cpufreq_table() from Stephen Boyd - ACPI battery driver fix for a warning message added in 3.16 that prints silly stuff sometimes from Mariusz Ceier - Hibernation fix for safer handling of mismatches in the 820 memory map between the configurations during image creation and during the subsequent restore from Chun-Yi Lee - ACPI processor driver fix to handle CPU hotplug notifications correctly during system suspend/resume from Lan Tianyu - Series of four cpuidle menu governor cleanups that also should speed it up a bit from Mel Gorman - Fixes for the speedstep-smi, integrator, cpu0 and arm_big_little cpufreq drivers from Hans Wennborg, Himangi Saraogi, Markus Pargmann and Uwe Kleine-König - Version 3.0 of the analyze_suspend.py suspend profiling tool from Todd E Brandt" * tag 'pm+acpi-3.17-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: ACPI / battery: Fix warning message in acpi_battery_get_state() PM / tools: analyze_suspend.py: update to v3.0 cpufreq: arm_big_little: fix module license spec cpufreq: speedstep-smi: fix decimal printf specifiers ACPI / hotplug: Check scan handlers in acpi_scan_hot_remove() cpufreq: OPP: Avoid sleeping while atomic cpufreq: cpu0: Do not print error message when deferring cpufreq: integrator: Use set_cpus_allowed_ptr PM / hibernate: avoid unsafe pages in e820 reserved regions ACPI / processor: Make acpi_cpu_soft_notify() process CPU FROZEN events cpuidle: menu: Lookup CPU runqueues less cpuidle: menu: Call nr_iowait_cpu less times cpuidle: menu: Use ktime_to_us instead of reinventing the wheel cpuidle: menu: Use shifts when calculating averages where possible
2 parents a11c5c9 + af5b7e8 commit c9d2642

File tree

15 files changed

+3051
-878
lines changed

15 files changed

+3051
-878
lines changed

drivers/acpi/battery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,12 +540,12 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
540540
*/
541541
if (battery->capacity_now > battery->full_charge_capacity
542542
&& battery->full_charge_capacity != ACPI_BATTERY_VALUE_UNKNOWN) {
543-
battery->capacity_now = battery->full_charge_capacity;
544543
if (battery->capacity_now != battery->design_capacity)
545544
printk_once(KERN_WARNING FW_BUG
546545
"battery: reported current charge level (%d) "
547546
"is higher than reported maximum charge level (%d).\n",
548547
battery->capacity_now, battery->full_charge_capacity);
548+
battery->capacity_now = battery->full_charge_capacity;
549549
}
550550

551551
if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)

drivers/acpi/processor_driver.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb,
120120
unsigned int cpu = (unsigned long)hcpu;
121121
struct acpi_processor *pr = per_cpu(processors, cpu);
122122
struct acpi_device *device;
123+
action &= ~CPU_TASKS_FROZEN;
123124

124125
/*
125126
* CPU_STARTING and CPU_DYING must not sleep. Return here since

drivers/acpi/scan.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
353353
unsigned long long sta;
354354
acpi_status status;
355355

356-
if (device->handler->hotplug.demand_offline && !acpi_force_hot_remove) {
356+
if (device->handler && device->handler->hotplug.demand_offline
357+
&& !acpi_force_hot_remove) {
357358
if (!acpi_scan_is_offline(device, true))
358359
return -EBUSY;
359360
} else {

drivers/cpufreq/arm_big_little.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/cpufreq.h>
2525
#include <linux/cpumask.h>
2626
#include <linux/export.h>
27+
#include <linux/module.h>
2728
#include <linux/mutex.h>
2829
#include <linux/of_platform.h>
2930
#include <linux/pm_opp.h>
@@ -593,3 +594,7 @@ void bL_cpufreq_unregister(struct cpufreq_arm_bL_ops *ops)
593594
arm_bL_ops = NULL;
594595
}
595596
EXPORT_SYMBOL_GPL(bL_cpufreq_unregister);
597+
598+
MODULE_AUTHOR("Viresh Kumar <viresh.kumar@linaro.org>");
599+
MODULE_DESCRIPTION("Generic ARM big LITTLE cpufreq driver");
600+
MODULE_LICENSE("GPL v2");

drivers/cpufreq/arm_big_little_dt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,4 @@ module_platform_driver(generic_bL_platdrv);
114114

115115
MODULE_AUTHOR("Viresh Kumar <viresh.kumar@linaro.org>");
116116
MODULE_DESCRIPTION("Generic ARM big LITTLE cpufreq driver via DT");
117-
MODULE_LICENSE("GPL");
117+
MODULE_LICENSE("GPL v2");

drivers/cpufreq/cpufreq-cpu0.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev)
137137
* not yet registered, we should try defering probe.
138138
*/
139139
if (PTR_ERR(cpu_reg) == -EPROBE_DEFER) {
140-
dev_err(cpu_dev, "cpu0 regulator not ready, retry\n");
140+
dev_dbg(cpu_dev, "cpu0 regulator not ready, retry\n");
141141
ret = -EPROBE_DEFER;
142142
goto out_put_node;
143143
}

drivers/cpufreq/cpufreq_opp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev,
6060
goto out;
6161
}
6262

63-
freq_table = kzalloc(sizeof(*freq_table) * (max_opps + 1), GFP_KERNEL);
63+
freq_table = kcalloc(sizeof(*freq_table), (max_opps + 1), GFP_ATOMIC);
6464
if (!freq_table) {
6565
ret = -ENOMEM;
6666
goto out;

drivers/cpufreq/integrator-cpufreq.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static int integrator_set_target(struct cpufreq_policy *policy,
9292
* Bind to the specified CPU. When this call returns,
9393
* we should be running on the right CPU.
9494
*/
95-
set_cpus_allowed(current, cpumask_of_cpu(cpu));
95+
set_cpus_allowed_ptr(current, cpumask_of(cpu));
9696
BUG_ON(cpu != smp_processor_id());
9797

9898
/* get current setting */
@@ -118,7 +118,7 @@ static int integrator_set_target(struct cpufreq_policy *policy,
118118
freqs.new = icst_hz(&cclk_params, vco) / 1000;
119119

120120
if (freqs.old == freqs.new) {
121-
set_cpus_allowed(current, cpus_allowed);
121+
set_cpus_allowed_ptr(current, &cpus_allowed);
122122
return 0;
123123
}
124124

@@ -141,7 +141,7 @@ static int integrator_set_target(struct cpufreq_policy *policy,
141141
/*
142142
* Restore the CPUs allowed mask.
143143
*/
144-
set_cpus_allowed(current, cpus_allowed);
144+
set_cpus_allowed_ptr(current, &cpus_allowed);
145145

146146
cpufreq_freq_transition_end(policy, &freqs, 0);
147147

@@ -157,7 +157,7 @@ static unsigned int integrator_get(unsigned int cpu)
157157

158158
cpus_allowed = current->cpus_allowed;
159159

160-
set_cpus_allowed(current, cpumask_of_cpu(cpu));
160+
set_cpus_allowed_ptr(current, cpumask_of(cpu));
161161
BUG_ON(cpu != smp_processor_id());
162162

163163
/* detect memory etc. */
@@ -173,7 +173,7 @@ static unsigned int integrator_get(unsigned int cpu)
173173

174174
current_freq = icst_hz(&cclk_params, vco) / 1000; /* current freq */
175175

176-
set_cpus_allowed(current, cpus_allowed);
176+
set_cpus_allowed_ptr(current, &cpus_allowed);
177177

178178
return current_freq;
179179
}

drivers/cpufreq/speedstep-smi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ static int __init speedstep_init(void)
324324
return -ENODEV;
325325
}
326326

327-
pr_debug("signature:0x%.8ulx, command:0x%.8ulx, "
328-
"event:0x%.8ulx, perf_level:0x%.8ulx.\n",
327+
pr_debug("signature:0x%.8x, command:0x%.8x, "
328+
"event:0x%.8x, perf_level:0x%.8x.\n",
329329
ist_info.signature, ist_info.command,
330330
ist_info.event, ist_info.perf_level);
331331

drivers/cpuidle/governors/menu.c

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
* The default values do not overflow.
3232
*/
3333
#define BUCKETS 12
34-
#define INTERVALS 8
34+
#define INTERVAL_SHIFT 3
35+
#define INTERVALS (1UL << INTERVAL_SHIFT)
3536
#define RESOLUTION 1024
3637
#define DECAY 8
3738
#define MAX_INTERESTING 50000
@@ -133,15 +134,12 @@ struct menu_device {
133134
#define LOAD_INT(x) ((x) >> FSHIFT)
134135
#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
135136

136-
static int get_loadavg(void)
137+
static inline int get_loadavg(unsigned long load)
137138
{
138-
unsigned long this = this_cpu_load();
139-
140-
141-
return LOAD_INT(this) * 10 + LOAD_FRAC(this) / 10;
139+
return LOAD_INT(load) * 10 + LOAD_FRAC(load) / 10;
142140
}
143141

144-
static inline int which_bucket(unsigned int duration)
142+
static inline int which_bucket(unsigned int duration, unsigned long nr_iowaiters)
145143
{
146144
int bucket = 0;
147145

@@ -151,7 +149,7 @@ static inline int which_bucket(unsigned int duration)
151149
* This allows us to calculate
152150
* E(duration)|iowait
153151
*/
154-
if (nr_iowait_cpu(smp_processor_id()))
152+
if (nr_iowaiters)
155153
bucket = BUCKETS/2;
156154

157155
if (duration < 10)
@@ -174,16 +172,16 @@ static inline int which_bucket(unsigned int duration)
174172
* to be, the higher this multiplier, and thus the higher
175173
* the barrier to go to an expensive C state.
176174
*/
177-
static inline int performance_multiplier(void)
175+
static inline int performance_multiplier(unsigned long nr_iowaiters, unsigned long load)
178176
{
179177
int mult = 1;
180178

181179
/* for higher loadavg, we are more reluctant */
182180

183-
mult += 2 * get_loadavg();
181+
mult += 2 * get_loadavg(load);
184182

185183
/* for IO wait tasks (per cpu!) we add 5x each */
186-
mult += 10 * nr_iowait_cpu(smp_processor_id());
184+
mult += 10 * nr_iowaiters;
187185

188186
return mult;
189187
}
@@ -227,7 +225,10 @@ static void get_typical_interval(struct menu_device *data)
227225
max = value;
228226
}
229227
}
230-
do_div(avg, divisor);
228+
if (divisor == INTERVALS)
229+
avg >>= INTERVAL_SHIFT;
230+
else
231+
do_div(avg, divisor);
231232

232233
/* Then try to determine standard deviation */
233234
stddev = 0;
@@ -238,7 +239,11 @@ static void get_typical_interval(struct menu_device *data)
238239
stddev += diff * diff;
239240
}
240241
}
241-
do_div(stddev, divisor);
242+
if (divisor == INTERVALS)
243+
stddev >>= INTERVAL_SHIFT;
244+
else
245+
do_div(stddev, divisor);
246+
242247
/*
243248
* The typical interval is obtained when standard deviation is small
244249
* or standard deviation is small compared to the average interval.
@@ -288,7 +293,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
288293
int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY);
289294
int i;
290295
unsigned int interactivity_req;
291-
struct timespec t;
296+
unsigned long nr_iowaiters, cpu_load;
292297

293298
if (data->needs_update) {
294299
menu_update(drv, dev);
@@ -302,12 +307,10 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
302307
return 0;
303308

304309
/* determine the expected residency time, round up */
305-
t = ktime_to_timespec(tick_nohz_get_sleep_length());
306-
data->next_timer_us =
307-
t.tv_sec * USEC_PER_SEC + t.tv_nsec / NSEC_PER_USEC;
308-
310+
data->next_timer_us = ktime_to_us(tick_nohz_get_sleep_length());
309311

310-
data->bucket = which_bucket(data->next_timer_us);
312+
get_iowait_load(&nr_iowaiters, &cpu_load);
313+
data->bucket = which_bucket(data->next_timer_us, nr_iowaiters);
311314

312315
/*
313316
* Force the result of multiplication to be 64 bits even if both
@@ -325,7 +328,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
325328
* duration / latency ratio. Adjust the latency limit if
326329
* necessary.
327330
*/
328-
interactivity_req = data->predicted_us / performance_multiplier();
331+
interactivity_req = data->predicted_us / performance_multiplier(nr_iowaiters, cpu_load);
329332
if (latency_req > interactivity_req)
330333
latency_req = interactivity_req;
331334

include/linux/sched.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,7 @@ extern int nr_processes(void);
169169
extern unsigned long nr_running(void);
170170
extern unsigned long nr_iowait(void);
171171
extern unsigned long nr_iowait_cpu(int cpu);
172-
extern unsigned long this_cpu_load(void);
173-
172+
extern void get_iowait_load(unsigned long *nr_waiters, unsigned long *load);
174173

175174
extern void calc_global_load(unsigned long ticks);
176175
extern void update_cpu_load_nohz(void);

kernel/power/snapshot.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,25 @@ static void mark_nosave_pages(struct memory_bitmap *bm)
954954
}
955955
}
956956

957+
static bool is_nosave_page(unsigned long pfn)
958+
{
959+
struct nosave_region *region;
960+
961+
list_for_each_entry(region, &nosave_regions, list) {
962+
if (pfn >= region->start_pfn && pfn < region->end_pfn) {
963+
pr_err("PM: %#010llx in e820 nosave region: "
964+
"[mem %#010llx-%#010llx]\n",
965+
(unsigned long long) pfn << PAGE_SHIFT,
966+
(unsigned long long) region->start_pfn << PAGE_SHIFT,
967+
((unsigned long long) region->end_pfn << PAGE_SHIFT)
968+
- 1);
969+
return true;
970+
}
971+
}
972+
973+
return false;
974+
}
975+
957976
/**
958977
* create_basic_memory_bitmaps - create bitmaps needed for marking page
959978
* frames that should not be saved and free page frames. The pointers
@@ -2015,7 +2034,7 @@ static int mark_unsafe_pages(struct memory_bitmap *bm)
20152034
do {
20162035
pfn = memory_bm_next_pfn(bm);
20172036
if (likely(pfn != BM_END_OF_MAP)) {
2018-
if (likely(pfn_valid(pfn)))
2037+
if (likely(pfn_valid(pfn)) && !is_nosave_page(pfn))
20192038
swsusp_set_page_free(pfn_to_page(pfn));
20202039
else
20212040
return -EFAULT;

kernel/sched/core.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2393,6 +2393,13 @@ unsigned long nr_iowait_cpu(int cpu)
23932393
return atomic_read(&this->nr_iowait);
23942394
}
23952395

2396+
void get_iowait_load(unsigned long *nr_waiters, unsigned long *load)
2397+
{
2398+
struct rq *this = this_rq();
2399+
*nr_waiters = atomic_read(&this->nr_iowait);
2400+
*load = this->cpu_load[0];
2401+
}
2402+
23962403
#ifdef CONFIG_SMP
23972404

23982405
/*

kernel/sched/proc.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88

99
#include "sched.h"
1010

11-
unsigned long this_cpu_load(void)
12-
{
13-
struct rq *this = this_rq();
14-
return this->cpu_load[0];
15-
}
16-
17-
1811
/*
1912
* Global load-average calculations
2013
*

0 commit comments

Comments
 (0)