Skip to content

Commit a449dfb

Browse files
committed
PM: sleep: Avoid using pr_cont() in the tasks freezing code
Using pr_cont() in the tasks freezing code related to system-wide suspend and hibernation is problematic, because the continuation messages printed there are susceptible to interspersing with other unrelated messages which results in output that is hard to understand. Address this issue by modifying try_to_freeze_tasks() to print messages that don't require continuations and adjusting its callers accordingly. Reported-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Petr Mladek <pmladek@suse.com>
1 parent 3363e0a commit a449dfb

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

kernel/power/process.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ unsigned int __read_mostly freeze_timeout_msecs = 20 * MSEC_PER_SEC;
2727

2828
static int try_to_freeze_tasks(bool user_only)
2929
{
30+
const char *what = user_only ? "user space processes" :
31+
"remaining freezable tasks";
3032
struct task_struct *g, *p;
3133
unsigned long end_time;
3234
unsigned int todo;
@@ -36,6 +38,8 @@ static int try_to_freeze_tasks(bool user_only)
3638
bool wakeup = false;
3739
int sleep_usecs = USEC_PER_MSEC;
3840

41+
pr_info("Freezing %s\n", what);
42+
3943
start = ktime_get_boottime();
4044

4145
end_time = jiffies + msecs_to_jiffies(freeze_timeout_msecs);
@@ -82,7 +86,6 @@ static int try_to_freeze_tasks(bool user_only)
8286
elapsed_msecs = ktime_to_ms(elapsed);
8387

8488
if (todo) {
85-
pr_cont("\n");
8689
pr_err("Freezing of tasks %s after %d.%03d seconds "
8790
"(%d tasks refusing to freeze, wq_busy=%d):\n",
8891
wakeup ? "aborted" : "failed",
@@ -101,8 +104,8 @@ static int try_to_freeze_tasks(bool user_only)
101104
read_unlock(&tasklist_lock);
102105
}
103106
} else {
104-
pr_cont("(elapsed %d.%03d seconds) ", elapsed_msecs / 1000,
105-
elapsed_msecs % 1000);
107+
pr_info("Freezing %s completed (elapsed %d.%03d seconds)\n",
108+
what, elapsed_msecs / 1000, elapsed_msecs % 1000);
106109
}
107110

108111
return todo ? -EBUSY : 0;
@@ -130,14 +133,11 @@ int freeze_processes(void)
130133
static_branch_inc(&freezer_active);
131134

132135
pm_wakeup_clear(0);
133-
pr_info("Freezing user space processes ... ");
134136
pm_freezing = true;
135137
error = try_to_freeze_tasks(true);
136-
if (!error) {
138+
if (!error)
137139
__usermodehelper_set_disable_depth(UMH_DISABLED);
138-
pr_cont("done.");
139-
}
140-
pr_cont("\n");
140+
141141
BUG_ON(in_atomic());
142142

143143
/*
@@ -166,14 +166,9 @@ int freeze_kernel_threads(void)
166166
{
167167
int error;
168168

169-
pr_info("Freezing remaining freezable tasks ... ");
170-
171169
pm_nosig_freezing = true;
172170
error = try_to_freeze_tasks(false);
173-
if (!error)
174-
pr_cont("done.");
175171

176-
pr_cont("\n");
177172
BUG_ON(in_atomic());
178173

179174
if (error)

0 commit comments

Comments
 (0)