tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pmf(9) vs sysmon for power events (especially sleep when powerd(8) is not running)



On Fri, May 06, 2011 at 10:35:30AM +0100, Jean-Yves Migeon wrote:
> Yes. However, in the Xen domU case, it is quite unacceptable. Anyone 
> willing to suspend a domain would launch "xm save" from dom0. If 
> powerd(8) is not running, the "xm save" will wait ~forever for the domU 
> to signal it's ready for suspension. I'd like to have a shortcut that 
> handles the "powerd id not running" step, even if that means that 
> specific services have not been turned off cleanly via 
> scripts/sleep_button.

Speaking about normal x86 and other architectures, we should pick good
defaults but not tie things to the kernel. Formulating one-and-true policy
or "power-event state machine" is not a goal that can be even reached. I want
my laptop to suspend when the lid is closed, but someone else may not like.
It is more than natural that things like this are handled in user space.
Like is done currently with powerd(8), it is also a good idea to shutdown
other daemons before entering a suspended state.

> This situation also applies to power button too, but this case is 
> already handled [1]. Albeit, not sleep, hence the XXX I believe.

As I've written already, powerd(8) should be enabled by default on the stock
rc.conf(5). This is again something that should not require manual "tuning".

> I respectfully disagree. The PSWITCH_TYPE_LID event is first handled by 
> sysmon(9), then injected in pmf(9). See [2].
>
> [...]
>
> >The sysmon_pswitch_register(9) is indeed a NOP (it is supposedly there to
> >account some possible future use).  But sysmon_pswitch_event() is not a
> >NOP.  It does not inject anything to pmf(9).
> 
> It does. See [2].

Ah, right. Of course you should follow what those injections actually do
and where the listeners are? The main function in sysmon_power.c is:

    936         if (sysmon_power_daemon != NULL) {
    937                 /*
    938                  * Create a new dictionary for the event.
    939                  */
    940                 ped = kmem_zalloc(sizeof(*ped), KM_NOSLEEP);
    941                 if (!ped)
    942                         return;
    943                 ped->dict = prop_dictionary_create();
    944 
    945                 if (sysmon_power_daemon_task(ped, smpsw, event) ==
    0)
    946                         return;
    947         }


- Jukka.

[1] In lack of a better reference see e.g.

    http://lists.xensource.com/archives/html/xen-devel/2010-05/msg00115.html


Home | Main Index | Thread Index | Old Index