summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-07-22 18:03:43 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-07-22 18:03:43 -0400
commitcb08e0353c249a27aed10c6f60a13871ae449d33 (patch)
tree1f0a5ea686df33423b364a98cc692d94b86676ab
parent8915aa2042f85ecf86d4a202ef6d04bf06f05cca (diff)
PM / timekeeping: Print debug messages when requested
The messages printed by tk_debug_account_sleep_time() are basically useful for system sleep debugging, so print them only when the other debug messages from the core suspend/hibernate code are enabled. While at it, make it clear that the messages from tk_debug_account_sleep_time() are about timekeeping suspend duration, because in general timekeeping may be suspeded and resumed for multiple times during one system suspend-resume cycle. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--include/linux/suspend.h10
-rw-r--r--kernel/power/main.c10
-rw-r--r--kernel/time/timekeeping_debug.c5
3 files changed, 18 insertions, 7 deletions
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 707e4cdf21c2..97e394feabdb 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -492,16 +492,22 @@ static inline void unlock_system_sleep(void) {}
492 492
493#ifdef CONFIG_PM_SLEEP_DEBUG 493#ifdef CONFIG_PM_SLEEP_DEBUG
494extern bool pm_print_times_enabled; 494extern bool pm_print_times_enabled;
495extern __printf(1, 2) void pm_pr_dbg(const char *fmt, ...); 495extern __printf(2, 3) void __pm_pr_dbg(bool defer, const char *fmt, ...);
496#else 496#else
497#define pm_print_times_enabled (false) 497#define pm_print_times_enabled (false)
498 498
499#include <linux/printk.h> 499#include <linux/printk.h>
500 500
501#define pm_pr_dbg(fmt, ...) \ 501#define __pm_pr_dbg(defer, fmt, ...) \
502 no_printk(KERN_DEBUG fmt, ##__VA_ARGS__) 502 no_printk(KERN_DEBUG fmt, ##__VA_ARGS__)
503#endif 503#endif
504 504
505#define pm_pr_dbg(fmt, ...) \
506 __pm_pr_dbg(false, fmt, ##__VA_ARGS__)
507
508#define pm_deferred_pr_dbg(fmt, ...) \
509 __pm_pr_dbg(true, fmt, ##__VA_ARGS__)
510
505#ifdef CONFIG_PM_AUTOSLEEP 511#ifdef CONFIG_PM_AUTOSLEEP
506 512
507/* kernel/power/autosleep.c */ 513/* kernel/power/autosleep.c */
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 5ce00902c7e3..b7876eaf83f3 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -388,13 +388,14 @@ static ssize_t pm_debug_messages_store(struct kobject *kobj,
388power_attr(pm_debug_messages); 388power_attr(pm_debug_messages);
389 389
390/** 390/**
391 * pm_pr_dbg - Print a suspend debug message to the kernel log. 391 * __pm_pr_dbg - Print a suspend debug message to the kernel log.
392 * @defer: Whether or not to use printk_deferred() to print the message.
392 * @fmt: Message format. 393 * @fmt: Message format.
393 * 394 *
394 * The message will be emitted if enabled through the pm_debug_messages 395 * The message will be emitted if enabled through the pm_debug_messages
395 * sysfs attribute. 396 * sysfs attribute.
396 */ 397 */
397void pm_pr_dbg(const char *fmt, ...) 398void __pm_pr_dbg(bool defer, const char *fmt, ...)
398{ 399{
399 struct va_format vaf; 400 struct va_format vaf;
400 va_list args; 401 va_list args;
@@ -407,7 +408,10 @@ void pm_pr_dbg(const char *fmt, ...)
407 vaf.fmt = fmt; 408 vaf.fmt = fmt;
408 vaf.va = &args; 409 vaf.va = &args;
409 410
410 printk(KERN_DEBUG "PM: %pV", &vaf); 411 if (defer)
412 printk_deferred(KERN_DEBUG "PM: %pV", &vaf);
413 else
414 printk(KERN_DEBUG "PM: %pV", &vaf);
411 415
412 va_end(args); 416 va_end(args);
413} 417}
diff --git a/kernel/time/timekeeping_debug.c b/kernel/time/timekeeping_debug.c
index 38bc4d2208e8..0754cadfa9e6 100644
--- a/kernel/time/timekeeping_debug.c
+++ b/kernel/time/timekeeping_debug.c
@@ -19,6 +19,7 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/seq_file.h> 21#include <linux/seq_file.h>
22#include <linux/suspend.h>
22#include <linux/time.h> 23#include <linux/time.h>
23 24
24#include "timekeeping_internal.h" 25#include "timekeeping_internal.h"
@@ -75,7 +76,7 @@ void tk_debug_account_sleep_time(struct timespec64 *t)
75 int bin = min(fls(t->tv_sec), NUM_BINS-1); 76 int bin = min(fls(t->tv_sec), NUM_BINS-1);
76 77
77 sleep_time_bin[bin]++; 78 sleep_time_bin[bin]++;
78 printk_deferred(KERN_INFO "Suspended for %lld.%03lu seconds\n", 79 pm_deferred_pr_dbg("Timekeeping suspended for %lld.%03lu seconds\n",
79 (s64)t->tv_sec, t->tv_nsec / NSEC_PER_MSEC); 80 (s64)t->tv_sec, t->tv_nsec / NSEC_PER_MSEC);
80} 81}
81 82