Skip to main content
Topic: How to know what wakes up the laptop after suspend? (Read 2070 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to know what wakes up the laptop after suspend?

Hi,
the situation : Arch/Artix is not meant for suspend/resume. It never works for long. I am getting tired of spending time to try to fix it after each kernel update.


The problem: when I close the laptop lid, it suspends, then after 10 seconds, it wake up again. it is very problematic because it become very hot inside its bag,  and because it drains the battery  to 0.  Bad surprise when you have a 3h train trip and you open the laptop ;-(
sometimes, suspend works at first, sometimes, it works afer 2 times (I close the laptop lid) or even 3 times.

To deal with this, for some times, Hibernate was an option for me, until I found out that KDE does not behave reliably after a wake up from hibernate. So suspend is more reliable, you can actually continue working after a wake up.

So in reality  I have a trick to workaround this, but the whole thing is so lame.

Does someone know how to find out what (process or device or event) actually woke up the laptop after it woke up ?

I use
- Artix on KDE
- there always are 4-5 docker containers running (apache, mysql etc)


Code: [Select]
$ rc-status 
Runlevel: default
 dmcrypt                                                                                                                                                               [  started  ]
 NetworkManager                                                                                                                                                        [ stopping  ]
 syslog-ng                                                                                                                                                             [  started  ]
 acpid                                                                                                                                                                 [  started  ]
 bluetooth                                                                                                                                                             [  started  ]
 consolefont                                                                                                                                                           [  started  ]
 cpupower                                                                                                                                                              [  stopped  ]
 cronie                                                                                                                                                                [  started  ]
 cupsd                                                                                                                                                                 [  started  ]
 docker                                                                                                                                                                [  started  ]
 netmount                                                                                                                                                              [  stopped  ]
 ntpd                                                                                                                                                                  [  started  ]
 xdm                                                                                                                                                                   [  started  ]
 local                                                                                                                                                                 [  started  ]
 agetty.tty5                                                                                                                                      [  started 1 day(s) 10:20:54 (0) ]
 agetty.tty3                                                                                                                                      [  started 1 day(s) 10:20:54 (0) ]
 agetty.tty2                                                                                                                                      [  started 1 day(s) 10:20:54 (0) ]
 agetty.tty1                                                                                                                                      [  started 1 day(s) 10:20:54 (0) ]
 agetty.tty6                                                                                                                                      [  started 1 day(s) 10:20:54 (0) ]
 agetty.tty4                                                                                                                                      [  started 1 day(s) 10:20:54 (0) ]
Dynamic Runlevel: hotplugged
Dynamic Runlevel: needed/wanted
 xdm-setup                                                                                                                                                             [  started  ]
 dbus                                                                                                                                                                  [  started  ]
 avahi-daemon                                                                                                                                                          [  started  ]
Dynamic Runlevel: manual
 openrc-settingsd              


Ps: I know eveything to know about grup options,  Mkinitcpio  & the following page "Power management/Suspend and hibernate on Arch"
https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate#Hibernation

Re: How to know what wakes up the laptop after suspend?

Reply #1
I can't help with your problem as you use a laptop.
On my desktop suspend works fine wakes up everything is how i left it.
Have you tried using the power button for suspend to see if that works for you

Re: How to know what wakes up the laptop after suspend?

Reply #2
no. never

i supposed it was the same action.

Re: How to know what wakes up the laptop after suspend?

Reply #3
> The machines wakes up after suspend.
Have you checked in BIOS or UEFI network wake up ?
Do you have anything plugged in USB when that happens?

I had similar problem with Lenovo Ideapad B580. Laptop just decided to wake up few seconds after suspend.
For me the solution was to disable network wake up and have nothing plugged in USB (like wire less mouse; this can be tweaked with some cammnd...)

Re: How to know what wakes up the laptop after suspend?

Reply #4
Suspend is pretty complicated and depends on a lot of different parts being setup correctly to actually work. I'm going to assume that you have dbus and elogind enabled and running (it probably won't work without those two parts). Anyways, you should be able to use the loginctl (from elogind) to control suspending a laptop. You might have to write some kind of script to get the exact behavior you want, but it should be possible. I believe elogind can query the laptop's current state so an if/else shell script should be possible.

Re: How to know what wakes up the laptop after suspend?

Reply #5
What @SGOrava said. There's must be an ACPI event that triggers a wake up in BIOS->PowerManagement somewhere.

 

Re: How to know what wakes up the laptop after suspend?

Reply #6
So, I had the opportunity to debug a bit, looking at the kernel logs: It is not about BIOS->PowerManagement.
So I am answering my own post for reference.

Looking at kernel.log, it appears that there are 2 or more process that refuses to freeze. The kernel tries for 20 seconds, then decided to cancel suspend. This is the cause of this weird behavior where the laptop wake up bit itself after a short while.

This is part of the log when suspend appears:

Jul  8 06:31:01 nadir-pc kernel: PM: suspend entry (s2idle)
Jul  8 06:31:21 nadir-pc kernel: PM: Syncing filesystems ... done.
Jul  8 06:31:21 nadir-pc kernel: Freezing user space processes ...
Jul  8 06:31:21 nadir-pc kernel: Freezing of tasks failed after 20.009 seconds (2 tasks refusing to freeze, wq_busy=0):

then here listed are udevd & trash.so

After a while I think I found out what happens: I inserted a USB key, then removed it without "ejecting". and there are several instances of Dolphin referencing it, that still can browse it, just like it was still mounted. If I try to unmount it by hand, I get a "device is busy" message. So it is a kernel problem with mounted temporary drives, probably fuse. I often use sshfs which uses fuse.

It appears it is a know Kernel problem from 4.9+
Source: Bug #1676912 “Kernel 4.9+ regression: Suspend - Freezing of task...” :
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1676912

I am currenlty trying to use pm-utils in order to be able to kill everything that blocks suspend, but I really don't know how it works, when & how it is called. Like described here:   How can I figure out why Suspend sometimes fails? 
https://askubuntu.com/questions/158115/how-can-i-figure-out-why-suspend-sometimes-fails

I found pm-utils in AUR, the sleepd. script are in a different folder so I created  /usr/lib/pm-utils/sleep.d/02udev 
with the following content (work in progress):


Code: [Select]
#!/bin/sh
date >> /var/log/pmtest.log
 
for i in $(ls /run/media/nadir/|grep -v "\."); do echo $i;  fusermount -uz  /run/media/nadir/$i;  umount -l /run/media/nadir/$i;  umount -f /run/media/nadir/$i;  done

(killall -9 trash.so ; exit 0)
(killall -9 udevd; exit 0)
(killall -9 udisksd; exit 0)

I umounted manually, shutdown failed, suspend failed with additionnal process that refused to freeze : udisksd & trash.so  several times. I plan to also try udevadm in this script because I noticed that in such situation it raises errors during shutdown.


full logs during suspend:


Code: [Select]
Jul  8 06:31:01 nadir-pc kernel: PM: suspend entry (s2idle)
Jul  8 06:31:21 nadir-pc kernel: PM: Syncing filesystems ... done.
Jul  8 06:31:21 nadir-pc kernel: Freezing user space processes ...
Jul  8 06:31:21 nadir-pc kernel: Freezing of tasks failed after 20.009 seconds (2 tasks refusing to freeze, wq_busy=0):
Jul  8 06:31:21 nadir-pc kernel: udevd           D    0 10234    820 0x00000004
Jul  8 06:31:21 nadir-pc kernel: Call Trace:
Jul  8 06:31:21 nadir-pc kernel:  ? __schedule+0x26c/0x8b0
Jul  8 06:31:21 nadir-pc kernel:  schedule+0x32/0x80
Jul  8 06:31:21 nadir-pc kernel:  rwsem_down_read_failed+0xfe/0x160
Jul  8 06:31:21 nadir-pc kernel:  ? get_disk_and_module+0x3b/0x70
Jul  8 06:31:21 nadir-pc kernel:  call_rwsem_down_read_failed+0x14/0x30
Jul  8 06:31:21 nadir-pc kernel:  down_read+0x13/0x30
Jul  8 06:31:21 nadir-pc kernel:  get_gendisk+0x50/0x130
Jul  8 06:31:21 nadir-pc kernel:  __blkdev_get+0x150/0x540
Jul  8 06:31:21 nadir-pc kernel:  ? bd_acquire+0xc0/0xc0
Jul  8 06:31:21 nadir-pc kernel:  blkdev_get+0x4a/0x300
Jul  8 06:31:21 nadir-pc kernel:  ? inode_permission+0x35/0x190
Jul  8 06:31:21 nadir-pc kernel:  ? bd_acquire+0xc0/0xc0
Jul  8 06:31:21 nadir-pc kernel:  do_dentry_open+0x13f/0x380
Jul  8 06:31:21 nadir-pc kernel:  path_openat+0x30c/0x15b0
Jul  8 06:31:21 nadir-pc kernel:  ? reuse_swap_page+0x103/0x320
Jul  8 06:31:21 nadir-pc kernel:  do_filp_open+0x91/0x100
Jul  8 06:31:21 nadir-pc kernel:  ? __check_object_size+0xbe/0x14f
Jul  8 06:31:21 nadir-pc kernel:  do_sys_open+0x184/0x210
Jul  8 06:31:21 nadir-pc kernel:  do_syscall_64+0x4e/0x100
Jul  8 06:31:21 nadir-pc kernel:  entry_SYSCALL_64_after_hwframe+0x44/0xa9
Jul  8 06:31:21 nadir-pc kernel: RIP: 0033:0x7f2f18047eac
Jul  8 06:31:21 nadir-pc kernel: Code: Bad RIP value.
Jul  8 06:31:21 nadir-pc kernel: RSP: 002b:00007ffd5d9c7440 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
Jul  8 06:31:21 nadir-pc kernel: RAX: ffffffffffffffda RBX: 000055c718f73be0 RCX: 00007f2f18047eac
Jul  8 06:31:21 nadir-pc kernel: RDX: 00000000000a0800 RSI: 000055c718f6b2e0 RDI: 00000000ffffff9c
Jul  8 06:31:21 nadir-pc kernel: RBP: 000055c718f6b2e0 R08: 431bde82d7b634db R09: 000000000000000b
Jul  8 06:31:21 nadir-pc kernel: R10: 0000000000000000 R11: 0000000000000246 R12: 00000000000a0800
Jul  8 06:31:21 nadir-pc kernel: R13: 000055c718f857d0 R14: 000055c718f841e0 R15: 000055c718f87970
Jul  8 06:31:21 nadir-pc kernel: trash.so        D    0 14063   3314 0x00000004
Jul  8 06:31:21 nadir-pc kernel: Call Trace:
Jul  8 06:31:21 nadir-pc kernel:  ? __schedule+0x26c/0x8b0
Jul  8 06:31:21 nadir-pc kernel:  schedule+0x32/0x80
Jul  8 06:31:21 nadir-pc kernel:  rwsem_down_read_failed+0xfe/0x160
Jul  8 06:31:21 nadir-pc kernel:  ? __attach_extent_node+0x82/0xa0 [f2fs]
Jul  8 06:31:21 nadir-pc kernel:  call_rwsem_down_read_failed+0x14/0x30
Jul  8 06:31:21 nadir-pc kernel:  down_read+0x13/0x30
Jul  8 06:31:21 nadir-pc kernel:  f2fs_need_inode_block_update+0x1c/0x50 [f2fs]
Jul  8 06:31:21 nadir-pc kernel:  f2fs_iget+0x4e7/0xf20 [f2fs]
Jul  8 06:31:21 nadir-pc kernel:  f2fs_lookup+0xe6/0x380 [f2fs]
Jul  8 06:31:21 nadir-pc kernel:  __lookup_slow+0x94/0x160
Jul  8 06:31:21 nadir-pc kernel:  lookup_slow+0x36/0x50
Jul  8 06:31:21 nadir-pc kernel:  walk_component+0x1c2/0x2e0
Jul  8 06:31:21 nadir-pc kernel:  path_lookupat.isra.0+0x80/0x230
Jul  8 06:31:21 nadir-pc kernel:  ? terminate_walk+0x8c/0x100
Jul  8 06:31:21 nadir-pc kernel:  filename_lookup+0xae/0x180
Jul  8 06:31:21 nadir-pc kernel:  ? __check_object_size+0xbe/0x14f
Jul  8 06:31:21 nadir-pc kernel:  ? strncpy_from_user+0x41/0x120
Jul  8 06:31:21 nadir-pc kernel:  vfs_statx+0x7a/0xf0
Jul  8 06:31:21 nadir-pc kernel:  __se_sys_newlstat+0x3e/0x70
Jul  8 06:31:21 nadir-pc kernel:  ? _cond_resched+0x15/0x30
Jul  8 06:31:21 nadir-pc kernel:  ? exit_to_usermode_loop+0x4b/0xc0
Jul  8 06:31:21 nadir-pc kernel:  do_syscall_64+0x4e/0x100
Jul  8 06:31:21 nadir-pc kernel:  entry_SYSCALL_64_after_hwframe+0x44/0xa9
Jul  8 06:31:21 nadir-pc kernel: RIP: 0033:0x7ff9e05c581a
Jul  8 06:31:21 nadir-pc kernel: Code: Bad RIP value.
Jul  8 06:31:21 nadir-pc kernel: RSP: 002b:00007ffcddcb3038 EFLAGS: 00000246 ORIG_RAX: 0000000000000006
Jul  8 06:31:21 nadir-pc kernel: RAX: ffffffffffffffda RBX: 00007ffcddcb3588 RCX: 00007ff9e05c581a
Jul  8 06:31:21 nadir-pc kernel: RDX: 00007ffcddcb30a0 RSI: 00007ffcddcb30a0 RDI: 0000558b94087658
Jul  8 06:31:21 nadir-pc kernel: RBP: 00007ffcddcb3860 R08: 0000000000000001 R09: 0000558b940876d0
Jul  8 06:31:21 nadir-pc kernel: R10: 0000000000000007 R11: 0000000000000246 R12: 00007ffcddcb35a0
Jul  8 06:31:21 nadir-pc kernel: R13: 00007ffcddcb3588 R14: 00007ffcddcb3860 R15: 0000558b94051cf0
Jul  8 06:31:21 nadir-pc kernel: OOM killer enabled.
Jul  8 06:31:21 nadir-pc kernel: Restarting tasks ...
Jul  8 06:31:21 nadir-pc kernel: IPv6: ADDRCONF(NETDEV_UP): wlp1s0: link is not ready
Jul  8 06:31:21 nadir-pc kernel: done.
Jul  8 06:31:22 nadir-pc kernel: PM: suspend exit

regarding "umount error The device is currently busy Error unmounting target is busy" :
 
linux - How to unmount a busy device - Stack Overflow
https://stackoverflow.com/questions/7878707/how-to-unmount-a-busy-device