Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'laptop_mode auto force' ignores ENABLE_LAPTOP_MODE_TOOLS=0 aswell as CONTROL_USB_AUTOSUSPEND="0" #37

Closed
bendlas opened this issue Sep 15, 2014 · 5 comments

Comments

@bendlas
Copy link

bendlas commented Sep 15, 2014

With the help of systemtap I finally found the culprit for my mouse switching off after resume from standby: laptop-mode-tools

I had ruled it out, because with it being disabled in systemd, aswell any and all of its config options switched off, it couldn't possibly be the cause for for my mouse's auto-suspend turning on after resume, making it unusable. Right? Wrong!

Due to 99-laptop-mode.rules, it auto-starts itself from udev as lmt-udev auto force. This then merrily turns on auto-suspend for all usb devices (despite ENABLE_LAPTOP_MODE_TOOLS=0 in /etc/laptop-mode/laptop-mode.conf and CONTROL_USB_AUTOSUSPEND="0" in /etc/laptop-mode/conf.d/usb-autosuspend.conf).

It does so, even while it logs ++ log VERBOSE 'USB autosuspend is disabled.'. Still, I cross-checked: I can turn off my mouse by calling laptop_mode auto force. OTOH when I remove 99-laptop-mode.rules, my mouse suddenly survives a suspend-resume.

Observed with app-laptop/laptop-mode-tools-1.65-r1 from gentoo.

Thanks to the fantastic fche and jistone from #systemtap on freenode. With their help, I managed to use systemtap to trace writes to /sys/bus/usb/devices/*/power/control, which allowed me to find the needle in this hay stack.

@bendlas
Copy link
Author

bendlas commented Sep 16, 2014

Here is, how I found the issue on my gentoo system:

# uname -sr 
Linux 3.15.10-gentoo
# equery l -p laptop-mode-tools
.... ## LMT is installed
[IP-] [  ] app-laptop/laptop-mode-tools-1.65-r1:0
... ## but I didn't enable it in its config file, or systemd

Steps

When running the following command in a shell:

stap -v --all-modules -e '
  probe kernel.function("pm_runtime_allow").call {
    printf("PM ALLOW AUTOSUSPEND %d[%s]: pn[%s], parms[%s]\n", pid(), execname(), pn(), $$parms);
    print_backtrace()
  }
  probe syscall.execve {
    printf("EXECVE from %d[%s]: %s\n", ppid(), pexecname(), argstr);
  }
  probe kernel.function("dpm_resume") {
    println("RESUME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
  }'

and then suspending, then resuming my computer, it produced the following (severly shortened) output:

EXECVE from 1[systemd]: "/usr/lib/systemd/systemd-sleep" "suspend"
RESUME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EXECVE from 23013[systemd-udevd]: "/lib/udev/lmt-udev" "auto" "force"
EXECVE from 1[systemd]: "/usr/sbin/laptop_mode" "auto" "force"
... ### After resuming and some EXECVEs from shell execution, it turns on power management:
EXECVE from 24048[laptop_mode]: "/usr/bin/basename" "/sys/bus/serio/devices/serio1"
PM ALLOW AUTOSUSPEND 23457[laptop_mode]: pn[kernel.function("pm_runtime_allow@drivers/base/power/runtime.c:1226").call], parms[dev=0xffff88041e5b6558]
 0xffffffff81422374 : pm_runtime_allow+0x0/0x4e [kernel]
 0xffffffff8141f929 : control_store+0x66/0xab [kernel]
 0xffffffff811780cc : kernfs_fop_write+0xcc/0x110 [kernel]
 0xffffffff8111c3bc : vfs_write+0xbf/0x177 [kernel]
 0xffffffff8111cce2 : sys_write+0x46/0x89 [kernel]
 0xffffffff815a954b : tracesys+0xdd/0xe2 [kernel]
... ### for a lot of devices, including my mouse
EXECVE from 24056[laptop_mode]: "/usr/bin/basename" "/sys/bus/usb/devices/3-1"
PM ALLOW AUTOSUSPEND 23457[laptop_mode]: pn[kernel.function("pm_runtime_allow@drivers/base/power/runtime.c:1226").call], parms[dev=0xffff88041693d090]
 0xffffffff81422374 : pm_runtime_allow+0x0/0x4e [kernel]
 0xffffffff8141f929 : control_store+0x66/0xab [kernel]
 0xffffffff811780cc : kernfs_fop_write+0xcc/0x110 [kernel]
 0xffffffff8111c3bc : vfs_write+0xbf/0x177 [kernel]
 0xffffffff8111cce2 : sys_write+0x46/0x89 [kernel]
 0xffffffff815a954b : tracesys+0xdd/0xe2 [kernel]
... ### many
... ### many devices

after that, all my devices had turned to 'Good' in powertop and my mouse had stopped working.

After turning my mouse back, deinstalling laptop-mode-tools and standby-cycling with the same stap invokation again, produced no pm_allow and very few system resume tasks:

EXECVE from 1[systemd]: "/usr/lib/systemd/systemd-sleep" "suspend"
RESUME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EXECVE from 643[gdm-session-wor]: "/usr/libexec/gdm-session-worker" 
EXECVE from 390[NetworkManager]: "/sbin/dhcpcd" "-B" "-K" "-L" "-G" "-c" "/usr/libexec/nm-dhcp-client.action" "-4" "enp5s0"
EXECVE from 25842[dhcpcd]: "/usr/libexec/nm-dhcp-client.action" 

@rickysarraf
Copy link
Owner

Okay!!. Thanks for your additional information. I still checked the code
and see no errors. Hence it could possibly be a problem specific to your
machine. Have you been able to reproduce it on another box ?

BTW, in 1.65 there is no usb-autosuspend module. It was dropped in favor
on runtime-pm module.

On Tuesday 16 September 2014 06:42 AM, bendlas wrote:

Here I found the issue on my gentoo system:

|# uname -sr
Linux 3.15.10-gentoo

equery l -p laptop-mode-tools

.... ## LMT is installed
[IP-] [ ] app-laptop/laptop-mode-tools-1.65-r1:0
|

Steps

When running the following command in a shell:

|stap -v --all-modules -d /usr/lib/systemd/systemd -d /usr/lib/systemd/systemd-udevd -e '
probe kernel.function("pm_runtime_allow").call {
printf("PM ALLOW AUTOSUSPEND %d[%s]: pn[%s], parms[%s]\n", pid(), execname(), pn(), $$parms);
print_backtrace()
}
probe syscall.execve {
printf("EXECVE from %d[%s]: %s\n", ppid(), pexecname(), argstr);
}
probe kernel.function("dpm_resume") {
println("RESUME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
}'
|

and then suspending, then resuming my computer, it produced the
following (severly shortened) output:

|EXECVE from 1[systemd]: "/usr/lib/systemd/systemd-sleep" "suspend"
RESUME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EXECVE from 23013[systemd-udevd]: "/lib/udev/lmt-udev" "auto" "force"
EXECVE from 1[systemd]: "/usr/sbin/laptop_mode" "auto" "force"
... ### After resuming and some EXECVEs from shell execution, it turns on power management:
EXECVE from 24048[laptop_mode]: "/usr/bin/basename" "/sys/bus/serio/devices/serio1"
PM ALLOW AUTOSUSPEND 23457[laptop_mode]: pn[kernel.function("pm_runtime_allow@drivers/base/power/runtime.c:1226").call], parms[dev=0xffff88041e5b6558]
0xffffffff81422374 : pm_runtime_allow+0x0/0x4e [kernel]
0xffffffff8141f929 : control_store+0x66/0xab [kernel]
0xffffffff811780cc : kernfs_fop_write+0xcc/0x110 [kernel]
0xffffffff8111c3bc : vfs_write+0xbf/0x177 [kernel]
0xffffffff8111cce2 : sys_write+0x46/0x89 [kernel]
0xffffffff815a954b : tracesys+0xdd/0xe2 [kernel]
... ### for a lot of devices, including my mouse
EXECVE from 24056[laptop_mode]: "/usr/bin/basename" "/sys/bus/usb/devices/3-1"
PM ALLOW AUTOSUSPEND 23457[laptop_mode]: pn[kernel.function("pm_runtime_allow@drivers/base/power/runtime.c:1226").call], parms[dev=0xffff88041693d090]
0xffffffff81422374 : pm_runtime_allow+0x0/0x4e [kernel]
0xffffffff8141f929 : control_store+0x66/0xab [kernel]
0xffffffff811780cc : kernfs_fop_write+0xcc/0x110 [kernel]
0xffffffff8111c3bc : vfs_write+0xbf/0x177 [kernel]
0xffffffff8111cce2 : sys_write+0x46/0x89 [kernel]
0xffffffff815a954b : tracesys+0xdd/0xe2 [kernel]
... ### many
... ### many devices
|

after that, all my devices had turned to 'Good' in powertop and my
mouse had stopped working.

After turning my mouse back, deinstalling laptop-mode-tools and
standby-cycling with the same stap invokation again, produced no
pm_allow and very few system resume tasks:

|EXECVE from 1[systemd]: "/usr/lib/systemd/systemd-sleep" "suspend"
RESUME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EXECVE from 643[gdm-session-wor]: "/usr/libexec/gdm-session-worker"
EXECVE from 390[NetworkManager]: "/sbin/dhcpcd" "-B" "-K" "-L" "-G" "-c" "/usr/libexec/nm-dhcp-client.action" "-4" "enp5s0"
EXECVE from 25842[dhcpcd]: "/usr/libexec/nm-dhcp-client.action"
|


Reply to this email directly or view it on GitHub
#37 (comment).

Ritesh Raj Sarraf
RESEARCHUT - http://www.researchut.com
"Necessity is the mother of invention."

@bendlas
Copy link
Author

bendlas commented Sep 16, 2014

Have you tried running laptop_mode auto force (with disabled config) and see what it does to the Tunables page in powertop?

@rickysarraf
Copy link
Owner

I'll check it today

s3nt fr0m a $martph0ne, excuse typ0s
On Sep 16, 2014 7:21 PM, "bendlas" notifications@github.com wrote:

Have you tried running laptop_mode auto force (with disabled config) and
see what it does to the Tunables page in powertop?


Reply to this email directly or view it on GitHub
#37 (comment)
.

@rickysarraf
Copy link
Owner

Thanks for the report. I've fixed LMT to honor user settings. Will be part of the 1.66 release.

rickysarraf added a commit that referenced this issue Sep 17, 2014
rickysarraf added a commit that referenced this issue Sep 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants