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>
This commit is contained in:
parent
8915aa2042
commit
cb08e0353c
|
@ -492,16 +492,22 @@ static inline void unlock_system_sleep(void) {}
|
||||||
|
|
||||||
#ifdef CONFIG_PM_SLEEP_DEBUG
|
#ifdef CONFIG_PM_SLEEP_DEBUG
|
||||||
extern bool pm_print_times_enabled;
|
extern bool pm_print_times_enabled;
|
||||||
extern __printf(1, 2) void pm_pr_dbg(const char *fmt, ...);
|
extern __printf(2, 3) void __pm_pr_dbg(bool defer, const char *fmt, ...);
|
||||||
#else
|
#else
|
||||||
#define pm_print_times_enabled (false)
|
#define pm_print_times_enabled (false)
|
||||||
|
|
||||||
#include <linux/printk.h>
|
#include <linux/printk.h>
|
||||||
|
|
||||||
#define pm_pr_dbg(fmt, ...) \
|
#define __pm_pr_dbg(defer, fmt, ...) \
|
||||||
no_printk(KERN_DEBUG fmt, ##__VA_ARGS__)
|
no_printk(KERN_DEBUG fmt, ##__VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define pm_pr_dbg(fmt, ...) \
|
||||||
|
__pm_pr_dbg(false, fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
#define pm_deferred_pr_dbg(fmt, ...) \
|
||||||
|
__pm_pr_dbg(true, fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
#ifdef CONFIG_PM_AUTOSLEEP
|
#ifdef CONFIG_PM_AUTOSLEEP
|
||||||
|
|
||||||
/* kernel/power/autosleep.c */
|
/* kernel/power/autosleep.c */
|
||||||
|
|
|
@ -388,13 +388,14 @@ static ssize_t pm_debug_messages_store(struct kobject *kobj,
|
||||||
power_attr(pm_debug_messages);
|
power_attr(pm_debug_messages);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pm_pr_dbg - Print a suspend debug message to the kernel log.
|
* __pm_pr_dbg - Print a suspend debug message to the kernel log.
|
||||||
|
* @defer: Whether or not to use printk_deferred() to print the message.
|
||||||
* @fmt: Message format.
|
* @fmt: Message format.
|
||||||
*
|
*
|
||||||
* The message will be emitted if enabled through the pm_debug_messages
|
* The message will be emitted if enabled through the pm_debug_messages
|
||||||
* sysfs attribute.
|
* sysfs attribute.
|
||||||
*/
|
*/
|
||||||
void pm_pr_dbg(const char *fmt, ...)
|
void __pm_pr_dbg(bool defer, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
struct va_format vaf;
|
struct va_format vaf;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
@ -407,7 +408,10 @@ void pm_pr_dbg(const char *fmt, ...)
|
||||||
vaf.fmt = fmt;
|
vaf.fmt = fmt;
|
||||||
vaf.va = &args;
|
vaf.va = &args;
|
||||||
|
|
||||||
printk(KERN_DEBUG "PM: %pV", &vaf);
|
if (defer)
|
||||||
|
printk_deferred(KERN_DEBUG "PM: %pV", &vaf);
|
||||||
|
else
|
||||||
|
printk(KERN_DEBUG "PM: %pV", &vaf);
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/seq_file.h>
|
#include <linux/seq_file.h>
|
||||||
|
#include <linux/suspend.h>
|
||||||
#include <linux/time.h>
|
#include <linux/time.h>
|
||||||
|
|
||||||
#include "timekeeping_internal.h"
|
#include "timekeeping_internal.h"
|
||||||
|
@ -75,7 +76,7 @@ void tk_debug_account_sleep_time(struct timespec64 *t)
|
||||||
int bin = min(fls(t->tv_sec), NUM_BINS-1);
|
int bin = min(fls(t->tv_sec), NUM_BINS-1);
|
||||||
|
|
||||||
sleep_time_bin[bin]++;
|
sleep_time_bin[bin]++;
|
||||||
printk_deferred(KERN_INFO "Suspended for %lld.%03lu seconds\n",
|
pm_deferred_pr_dbg("Timekeeping suspended for %lld.%03lu seconds\n",
|
||||||
(s64)t->tv_sec, t->tv_nsec / NSEC_PER_MSEC);
|
(s64)t->tv_sec, t->tv_nsec / NSEC_PER_MSEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue