vianney/arch-luks-suspend — pull request #4 by guns (2014-07-21 23:12:50+00:00)
Title: Stop systemd-journal before entering suspend

Attempting to sleep a busy system often causes a suspend to fail with
the following error:

```
Freezing of tasks failed after 20.005 seconds (1 tasks refusing to freeze, wq_busy=0):
systemd-journal D 0000000000000000 0 161 1 0x00000004
ffff8800b96efc18 0000000000000086 ffffffffa032141d ffff88007f9d3f80
ffff88007f9d3f80 ffff8800b96effd8 0000000000014640 ffff88007f9d4328
0000000000014640 ffff88007f9d3f80 0000000000000000 000000000fe00000
Call Trace:
[] ? jbd2_journal_stop+0x22d/0x3d0 [jbd2]
[] ? ext4_dirty_inode+0x40/0x60 [ext4]
[] ? __find_get_block+0xca/0x290
[] ? __set_page_dirty+0x74/0xc0
[] ? __find_get_block+0xca/0x290
[] __sb_start_write+0xbd/0x110
[] ? __wake_up_sync+0x20/0x20
[] ext4_page_mkwrite+0x58/0x460 [ext4]
[] do_page_mkwrite+0x4e/0xb0
[] ? number.isra.2+0x319/0x350
[] do_wp_page+0x539/0x920
[] ? schedule+0x7aa/0xfb0
[] handle_mm_fault+0x953/0xeb0
[] ? vsnprintf+0x284/0x580
[] __do_page_fault+0x18f/0x600
[] ? devkmsg_read+0x16f/0x420
[] do_page_fault+0x22/0x30
[] page_fault+0x28/0x30
```

Here, systemd-journal has triggered a page fault (the persistent log
file is mmap'ed) and goes into uninterruptible sleep while the kernel
attempts to load a page from the recently locked dm-crypt device.

This operation will hang, and since the journal process can not receive
signals, the machine never enters suspend-to-RAM.

While this problem is not particular to systemd-journal, it is the
most frequent trigger for the problem as the journal is recording the
operations of the suspend operation as it happens.

The deeper issue of IO on the crypt device after freezing, but before
machine suspend, is not addressed here.