Skip to content

Commit a7b4b00

Browse files
committed
Merge tag 'pm-5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management fixes from Rafael Wysocki: "These make the buffer handling in pm_show_wakelocks() more robust and drop an unused hibernation-related function. Specifics: - Make the buffer handling in pm_show_wakelocks() more robust by using sysfs_emit_at() in it to generate output (Greg Kroah-Hartman). - Drop register_nosave_region_late() which is not used (Amadeusz Sławiński)" * tag 'pm-5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: PM: hibernate: Remove register_nosave_region_late() PM: wakeup: simplify the output logic of pm_show_wakelocks()
2 parents df00015 + 33569ef commit a7b4b00

File tree

3 files changed

+12
-31
lines changed

3 files changed

+12
-31
lines changed

include/linux/suspend.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -430,15 +430,7 @@ struct platform_hibernation_ops {
430430

431431
#ifdef CONFIG_HIBERNATION
432432
/* kernel/power/snapshot.c */
433-
extern void __register_nosave_region(unsigned long b, unsigned long e, int km);
434-
static inline void __init register_nosave_region(unsigned long b, unsigned long e)
435-
{
436-
__register_nosave_region(b, e, 0);
437-
}
438-
static inline void __init register_nosave_region_late(unsigned long b, unsigned long e)
439-
{
440-
__register_nosave_region(b, e, 1);
441-
}
433+
extern void register_nosave_region(unsigned long b, unsigned long e);
442434
extern int swsusp_page_is_forbidden(struct page *);
443435
extern void swsusp_set_page_free(struct page *);
444436
extern void swsusp_unset_page_free(struct page *);
@@ -458,7 +450,6 @@ int pfn_is_nosave(unsigned long pfn);
458450
int hibernate_quiet_exec(int (*func)(void *data), void *data);
459451
#else /* CONFIG_HIBERNATION */
460452
static inline void register_nosave_region(unsigned long b, unsigned long e) {}
461-
static inline void register_nosave_region_late(unsigned long b, unsigned long e) {}
462453
static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
463454
static inline void swsusp_set_page_free(struct page *p) {}
464455
static inline void swsusp_unset_page_free(struct page *p) {}

kernel/power/snapshot.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -978,8 +978,7 @@ static void memory_bm_recycle(struct memory_bitmap *bm)
978978
* Register a range of page frames the contents of which should not be saved
979979
* during hibernation (to be used in the early initialization code).
980980
*/
981-
void __init __register_nosave_region(unsigned long start_pfn,
982-
unsigned long end_pfn, int use_kmalloc)
981+
void __init register_nosave_region(unsigned long start_pfn, unsigned long end_pfn)
983982
{
984983
struct nosave_region *region;
985984

@@ -995,18 +994,12 @@ void __init __register_nosave_region(unsigned long start_pfn,
995994
goto Report;
996995
}
997996
}
998-
if (use_kmalloc) {
999-
/* During init, this shouldn't fail */
1000-
region = kmalloc(sizeof(struct nosave_region), GFP_KERNEL);
1001-
BUG_ON(!region);
1002-
} else {
1003-
/* This allocation cannot fail */
1004-
region = memblock_alloc(sizeof(struct nosave_region),
1005-
SMP_CACHE_BYTES);
1006-
if (!region)
1007-
panic("%s: Failed to allocate %zu bytes\n", __func__,
1008-
sizeof(struct nosave_region));
1009-
}
997+
/* This allocation cannot fail */
998+
region = memblock_alloc(sizeof(struct nosave_region),
999+
SMP_CACHE_BYTES);
1000+
if (!region)
1001+
panic("%s: Failed to allocate %zu bytes\n", __func__,
1002+
sizeof(struct nosave_region));
10101003
region->start_pfn = start_pfn;
10111004
region->end_pfn = end_pfn;
10121005
list_add_tail(&region->list, &nosave_regions);

kernel/power/wakelock.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,20 @@ ssize_t pm_show_wakelocks(char *buf, bool show_active)
3939
{
4040
struct rb_node *node;
4141
struct wakelock *wl;
42-
char *str = buf;
43-
char *end = buf + PAGE_SIZE;
42+
int len = 0;
4443

4544
mutex_lock(&wakelocks_lock);
4645

4746
for (node = rb_first(&wakelocks_tree); node; node = rb_next(node)) {
4847
wl = rb_entry(node, struct wakelock, node);
4948
if (wl->ws->active == show_active)
50-
str += scnprintf(str, end - str, "%s ", wl->name);
49+
len += sysfs_emit_at(buf, len, "%s ", wl->name);
5150
}
52-
if (str > buf)
53-
str--;
5451

55-
str += scnprintf(str, end - str, "\n");
52+
len += sysfs_emit_at(buf, len, "\n");
5653

5754
mutex_unlock(&wakelocks_lock);
58-
return (str - buf);
55+
return len;
5956
}
6057

6158
#if CONFIG_PM_WAKELOCKS_LIMIT > 0

0 commit comments

Comments
 (0)