Skip to content

Commit cdb8c10

Browse files
superm1rafaeljw
authored andcommitted
include/linux/suspend.h: Only show pm_pr_dbg messages at suspend/resume
All uses in the kernel are currently already oriented around suspend/resume. As some other parts of the kernel may also use these messages in functions that could also be used outside of suspend/resume, only enable in suspend/resume path. Signed-off-by: Mario Limonciello <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent ab23ed6 commit cdb8c10

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

include/linux/suspend.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ static inline void unlock_system_sleep(unsigned int flags) {}
555555
#ifdef CONFIG_PM_SLEEP_DEBUG
556556
extern bool pm_print_times_enabled;
557557
extern bool pm_debug_messages_on;
558+
extern bool pm_debug_messages_should_print(void);
558559
static inline int pm_dyn_debug_messages_on(void)
559560
{
560561
#ifdef CONFIG_DYNAMIC_DEBUG
@@ -568,14 +569,14 @@ static inline int pm_dyn_debug_messages_on(void)
568569
#endif
569570
#define __pm_pr_dbg(fmt, ...) \
570571
do { \
571-
if (pm_debug_messages_on) \
572+
if (pm_debug_messages_should_print()) \
572573
printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
573574
else if (pm_dyn_debug_messages_on()) \
574575
pr_debug(fmt, ##__VA_ARGS__); \
575576
} while (0)
576577
#define __pm_deferred_pr_dbg(fmt, ...) \
577578
do { \
578-
if (pm_debug_messages_on) \
579+
if (pm_debug_messages_should_print()) \
579580
printk_deferred(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
580581
} while (0)
581582
#else
@@ -593,7 +594,8 @@ static inline int pm_dyn_debug_messages_on(void)
593594
/**
594595
* pm_pr_dbg - print pm sleep debug messages
595596
*
596-
* If pm_debug_messages_on is enabled, print message.
597+
* If pm_debug_messages_on is enabled and the system is entering/leaving
598+
* suspend, print message.
597599
* If pm_debug_messages_on is disabled and CONFIG_DYNAMIC_DEBUG is enabled,
598600
* print message only from instances explicitly enabled on dynamic debug's
599601
* control.

kernel/power/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,12 @@ power_attr_ro(pm_wakeup_irq);
556556

557557
bool pm_debug_messages_on __read_mostly;
558558

559+
bool pm_debug_messages_should_print(void)
560+
{
561+
return pm_debug_messages_on && pm_suspend_target_state != PM_SUSPEND_ON;
562+
}
563+
EXPORT_SYMBOL_GPL(pm_debug_messages_should_print);
564+
559565
static ssize_t pm_debug_messages_show(struct kobject *kobj,
560566
struct kobj_attribute *attr, char *buf)
561567
{

0 commit comments

Comments
 (0)