Re: [RFC][PATCHv5 06/13] printk: register PM notifier

Sergey Senozhatsky
2017-08-16T07:31:04Z

On (08/15/17 13:51), Rafael J. Wysocki wrote:
> On Tuesday, August 15, 2017 4:56:18 AM CEST Sergey Senozhatsky wrote:
[..]
> > This patch registers PM notifier, so PM can switch printk
> > to emergency mode from PM_FOO_PREPARE notifiers and return
>
> Isn't that too early? That's before user space is frozen even.
>
> > back to printk threaded mode from PM_POST_FOO notifiers.
>
> And isn't that too late?

hm, those two are interesting questions. in short - well, it might
be. I don't want to interfere with PM by doing 'accidental' offloading
etc., PM is too complicated already. so I'd prefer to switch to old
printk behavior early (besides, I tend to see lockups reports more
often when the kernel is up and running, rather than during PM events.)
but, once again, may be it is too early and we can move emergency_mode
switch.

[..]
> > +static int printk_pm_notify(struct notifier_block *notify_block,
> > + unsigned long mode, void *unused)
> > +{
> > + switch (mode) {
> > + case PM_HIBERNATION_PREPARE:
> > + case PM_SUSPEND_PREPARE:
> > + case PM_RESTORE_PREPARE:
> > + printk_emergency_begin_sync();
>
> I'm not sure what would be wrong with calling this directly
> from dpm_suspend_noirq().
>
> > + break;
> > +
> > + case PM_POST_SUSPEND:
> > + case PM_POST_HIBERNATION:
> > + case PM_POST_RESTORE:
> > + printk_emergency_end_sync();
>
> And this could be called from dpm_resume_noirq().
>
> In which case you wouldn't really need the stuff below.

we didn't want to spread printk_emergency_{begin, end}
calls across the kernel.

as of dpm_suspend_noirq/dpm_resume_noirq - I need to look more.
isn't dpm_{suspend, resume}_noirq too late/early? :)

dpm_resume_noirq() happens much earlier than
suspend_finish()->suspend_thaw_processes(), right?
do we want to enable offloading this early?

currently what we have is the following sequence

suspend_finish()
suspend_thaw_processes()
pm_notifier_call_chain(PM_POST_SUSPEND) // enable offloading
pm_restore_console()

which looks OK to me, frankly.
do you see any problems here?

-ss