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

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 <mario.limonciello@amd.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Mario Limonciello and committed by
Rafael J. Wysocki
cdb8c100 ab23ed6e

+11 -3
+5 -3
include/linux/suspend.h
··· 555 555 #ifdef CONFIG_PM_SLEEP_DEBUG 556 556 extern bool pm_print_times_enabled; 557 557 extern bool pm_debug_messages_on; 558 + extern bool pm_debug_messages_should_print(void); 558 559 static inline int pm_dyn_debug_messages_on(void) 559 560 { 560 561 #ifdef CONFIG_DYNAMIC_DEBUG ··· 569 568 #endif 570 569 #define __pm_pr_dbg(fmt, ...) \ 571 570 do { \ 572 - if (pm_debug_messages_on) \ 571 + if (pm_debug_messages_should_print()) \ 573 572 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \ 574 573 else if (pm_dyn_debug_messages_on()) \ 575 574 pr_debug(fmt, ##__VA_ARGS__); \ 576 575 } while (0) 577 576 #define __pm_deferred_pr_dbg(fmt, ...) \ 578 577 do { \ 579 - if (pm_debug_messages_on) \ 578 + if (pm_debug_messages_should_print()) \ 580 579 printk_deferred(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \ 581 580 } while (0) 582 581 #else ··· 594 593 /** 595 594 * pm_pr_dbg - print pm sleep debug messages 596 595 * 597 - * If pm_debug_messages_on is enabled, print message. 596 + * If pm_debug_messages_on is enabled and the system is entering/leaving 597 + * suspend, print message. 598 598 * If pm_debug_messages_on is disabled and CONFIG_DYNAMIC_DEBUG is enabled, 599 599 * print message only from instances explicitly enabled on dynamic debug's 600 600 * control.
+6
kernel/power/main.c
··· 556 556 557 557 bool pm_debug_messages_on __read_mostly; 558 558 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 + 559 565 static ssize_t pm_debug_messages_show(struct kobject *kobj, 560 566 struct kobj_attribute *attr, char *buf) 561 567 {