Hello Tollef,
On Sunday 28 October 2012 03:18 PM, Tollef Fog Heen wrote: >> [Service] >> > Type=simple > I suspect you want type=forking here? I had tried that too. But it inherits similar problems. Here's the output when: Doing a start: rrs@champaran:/var/lock$ sudo systemctl status laptop-mode.service laptop-mode.service - Laptop Mode Tools Loaded: loaded (/lib/systemd/system/laptop-mode.service; enabled) Active: active (running) since Sun, 28 Oct 2012 21:59:39 +0530; 13s ago Process: 3059 ExecStopPost=/bin/rm -f /var/run/laptop-mode-tools/enabled (code=exited, status=0/SUCCESS) Process: 3002 ExecStop=/usr/sbin/laptop_mode init stop (code=exited, status=0/SUCCESS) Process: 3230 ExecStart=/usr/sbin/laptop_mode init auto (code=exited, status=0/SUCCESS) Main PID: 3248 (lm-polling-daem) CGroup: name=systemd:/system/laptop-mode.service ├ 3248 /bin/sh /usr/share/laptop-mode-tools/module-helpers/lm-polling-daemon └ 3250 sleep 150 rrs@champaran:/var/lock$ sudo lsof lm* COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME lm-pollin 3248 root 7w REG 0,14 0 3664 lmt-battpoll.lock sleep 3250 root 7w REG 0,14 0 3664 lmt-battpoll.lock Everything looks fine till here. The main script ran, backgrounded the polling script and then exited clean. Now I did a stop of the service. rrs@champaran:/var/lock$ sudo systemctl stop laptop-mode.service rrs@champaran:/var/lock$ sudo lsof lm* rrs@champaran:/var/lock$ sudo systemctl status laptop-mode.service laptop-mode.service - Laptop Mode Tools Loaded: loaded (/lib/systemd/system/laptop-mode.service; enabled) Active: inactive (dead) since Sun, 28 Oct 2012 22:00:45 +0530; 5s ago Process: 4083 ExecStopPost=/bin/rm -f /var/run/laptop-mode-tools/enabled (code=exited, status=0/SUCCESS) Process: 3379 ExecStop=/usr/sbin/laptop_mode init stop (code=exited, status=0/SUCCESS) Process: 3230 ExecStart=/usr/sbin/laptop_mode init auto (code=exited, status=0/SUCCESS) Main PID: 3248 (code=killed, signal=TERM) CGroup: name=systemd:/system/laptop-mode.service Oct 28 22:00:43 champaran laptop-mode[3424]: AC97 power saving is not available. Perhaps CONFIG_SND_AC97_POWER_SAVE option Oct 28 22:00:43 champaran su[3552]: Successful su for rrs by root Oct 28 22:00:43 champaran su[3552]: + ??? root:rrs Oct 28 22:00:43 champaran su[3552]: pam_unix(su:session): session opened for user rrs by (uid=0) Oct 28 22:00:43 champaran laptop-mode[3704]: Executing: echo 1200000 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq Oct 28 22:00:43 champaran laptop-mode[3736]: Executing: echo ondemand > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor Oct 28 22:00:43 champaran laptop-mode[3745]: Not setting CPU ignore_nice_load for cpu /sys/devices/system/cpu/cpu3. Oct 28 22:00:43 champaran laptop-mode[3984]: Setting CPU ignore_nice_load for all cpus It stopped clean. No locks are help and the status shows correct. Now I did a start again. rrs@champaran:/var/lock$ sudo systemctl start laptop-mode.service Job failed. See system journal and 'systemctl status' for details. rrs@champaran:/run/lock$ sudo systemctl status laptop-mode.service [sudo] password for rrs: laptop-mode.service - Laptop Mode Tools Loaded: loaded (/lib/systemd/system/laptop-mode.service; enabled) Active: activating (start) since Sun, 28 Oct 2012 22:01:25 +0530; 41s ago Process: 4083 ExecStopPost=/bin/rm -f /var/run/laptop-mode-tools/enabled (code=exited, status=0/SUCCESS) Process: 3379 ExecStop=/usr/sbin/laptop_mode init stop (code=exited, status=0/SUCCESS) Main PID: 3248 (code=killed, signal=TERM); Control: 4132 (laptop_mode) CGroup: name=systemd:/system/laptop-mode.service ├ 4132 /bin/sh /usr/sbin/laptop_mode init auto ├ 4150 /bin/sh /usr/share/laptop-mode-tools/module-helpers/lm-polling-daemon └ 4152 sleep 150 Oct 28 22:01:25 champaran laptop-mode[4329]: Executing: echo 1200000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq Oct 28 22:01:25 champaran su[4327]: Successful su for rrs by root Oct 28 22:01:25 champaran su[4327]: + ??? root:rrs Oct 28 22:01:25 champaran su[4327]: pam_unix(su:session): session opened for user rrs by (uid=0) Oct 28 22:01:25 champaran laptop-mode[4471]: Executing comand Oct 28 22:01:25 champaran laptop-mode[4695]: Executing: echo 2601000 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_max_freq Here, The status shows that it was hung. The systemd status reported was "activating". This status lasted for 41 seconds. Once it exited as failed, I again checked the status and systemd too reported it as failed, as below. rrs@champaran:/var/lock$ sudo systemctl status laptop-mode.service laptop-mode.service - Laptop Mode Tools Loaded: loaded (/lib/systemd/system/laptop-mode.service; enabled) Active: failed (Result: timeout) since Sun, 28 Oct 2012 22:02:55 +0530; 2min 49s ago Process: 4083 ExecStopPost=/bin/rm -f /var/run/laptop-mode-tools/enabled (code=exited, status=0/SUCCESS) Process: 3379 ExecStop=/usr/sbin/laptop_mode init stop (code=exited, status=0/SUCCESS) Process: 4132 ExecStart=/usr/sbin/laptop_mode init auto (code=killed, signal=TERM) Main PID: 3248 (code=killed, signal=TERM) CGroup: name=systemd:/system/laptop-mode.service Oct 28 22:01:25 champaran laptop-mode[4329]: Executing: echo 1200000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq Oct 28 22:01:25 champaran su[4327]: Successful su for rrs by root Oct 28 22:01:25 champaran su[4327]: + ??? root:rrs Oct 28 22:01:25 champaran su[4327]: pam_unix(su:session): session opened for user rrs by (uid=0) Oct 28 22:01:25 champaran laptop-mode[4471]: Executing comand Oct 28 22:01:25 champaran laptop-mode[4695]: Executing: echo 2601000 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_max_freq What should I do here? The way LMT operates is: * When service started on AC, run, detect the system in on AC, echo /var/run/laptop-mode-tools/enabled, and then clean exit. * When service started on BATT, run, detect the system is on BATT, echo /var/run/laptop-mode-toools/enabled, background a polling script, run the actual scripts for power savings and then clean exit. * When on BATT and LMT was enabled, keep polling using the polling script, every 120 seconds, to check any power saving state change. * When on AC and LMT was enabled, check the polling script, kill it. Then change the power saving settings and then clean exit. Apart from the above logs I have provided of consecutive stop/start of LMT, how would systmed deal the following case: * LMT was started by systemd. Then I switched to BATT. polling script was invoked and the main script ran and clean exited. Now I switch back to AC. Will systemd again invoke LMT ? * LMT is designed to act on events. The events invoke LMT. The events come form acpid or udev. Since the invocation could come from either one (and also manually through the init script) and in multiple event numbers (udev likes to fire multiple events), we have a lock to ensure that only 1 event gets processed in a given window. Will systemd interfere here? Since systemd is also events based, does it do anything special? I was hoping that systemd also would catch events and just invoke LMT, in which case, LMT would still be able to handle it with its locking. But that is not the case. You can see this here: rrs@champaran:/run/lock$ sudo lsof lm* [sudo] password for rrs: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME laptop_mo 7985 root 7w REG 0,14 0 3664 lmt-battpoll.lock laptop_mo 7985 root 8w REG 0,14 0 6980 lmt-req.lock laptop_mo 7985 root 9w REG 0,14 0 3682 lmt-invoc.lock lm-pollin 8003 root 7w REG 0,14 0 3664 lmt-battpoll.lock sleep 8005 root 7w REG 0,14 0 3664 lmt-battpoll.lock Ideally, pid 7985 should not exist. It (laptop_mode) should have clean exited. But since it forked lm-polling-daemon, it never released the lock on lmt-battpoll.lock. If it is not too much to ask, and if you have the time, you may want to install LMT and check it yourself. Not everything is crisp in my english. Please let me know if you'd be willing to. I can prepare the new deb for you, that I am currently holding for release, because of this issue. * rrs@champaran:/var/lock$ sudo systemctl status laptop-mode.service laptop-mode.service - Laptop Mode Tools Loaded: loaded (/lib/systemd/system/laptop-mode.service; enabled) Active: failed (Result: timeout) since Sun, 28 Oct 2012 22:02:55 +0530; 2min 49s ago Can you shed some light what timeout is here being referred to? I can't find a bug in the LMT script related to timeout yet. I works fine right now under SysV init. > >> > ExecStartPre=/usr/bin/install -d /var/run/laptop-mode-tools ; >> > /usr/bin/touch /var/run/laptop-mode-tools/enabled > You should rather do this using tmpfiles.d than with an execstart.d Thanks. I changed it to use tmpfiles. -- Ritesh Raj Sarraf | http://people.debian.org/~rrs Debian - The Universal Operating System
signature.asc
Description: OpenPGP digital signature