The change introduced by the patch is evident in the kernel message log for
Thread 0:
between page indexes 2 and 1 there's now another function call to
write_cache_pages()
instead of just another iteration of the for-loop inside one call.
Original kernel:
[ 695.276320] Thread 0 running, TID = 3293!
[ 695.281210] kp1_pre_handler():070 :: state 1 .... :: pid = 1165, mapping =
0xffff962333263730, comm = 'kworker/u4:2'
[ 695.299026] kp1_pre_handler():101 :: state 1 -> 2 :: pid = 1165, mapping =
0xffff962333263730, comm ('kworker/u4:2') is kworker AND wbc->range_cyclic
(0x1) is true AND mapping->writeback_index (0x2) is 0x2.
[ 695.314808] kp2_pre_handler():119 :: state 2 .... :: pid = 1165, page index =
2
[ 695.322822] kp3_pre_handler():144 :: state 2 .... :: pid = 1165, page index =
2, calling writepage()
<< ... HERE ... >>
[ 695.330308] kp2_pre_handler():119 :: state 2 .... :: pid = 1165, page index =
1
[ 695.334355] kp2_pre_handler():123 :: state 2 -> 3 :: pid = 1165, page index =
1, spin 5 seconds before lock_page()...
Test kernel:
[ 170.194880] Thread 0 running, TID = 2498!
[ 170.200011] kp1_pre_handler():070 :: state 1 .... :: pid = 7, mapping =
0xffff993df9136fb0, comm = 'kworker/u4:0'
[ 170.217616] kp1_pre_handler():101 :: state 1 -> 2 :: pid = 7, mapping =
0xffff993df9136fb0, comm ('kworker/u4:0') is kworker AND wbc->range_cyclic
(0x1) is true AND mapping->writeback_index (0x2) is 0x2.
[ 170.238633] kp2_pre_handler():119 :: state 2 .... :: pid = 7, page index = 2
[ 170.248024] kp3_pre_handler():144 :: state 2 .... :: pid = 7, page index = 2,
calling writepage()
[ 170.261141] kp1_pre_handler():070 :: state 2 .... :: pid = 7, mapping =
0xffff993df9136fb0, comm = 'kworker/u4:0'
[ 170.272150] kp2_pre_handler():119 :: state 2 .... :: pid = 7, page index = 1
[ 170.279860] kp2_pre_handler():123 :: state 2 -> 3 :: pid = 7, page index = 1,
spin 5 seconds before lock_page()...
** Changed in: linux (Ubuntu Cosmic)
Status: Confirmed => In Progress
--
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/1824827
Title:
tasks doing write()/fsync() hit deadlock in write_cache_pages()
Status in linux package in Ubuntu:
Invalid
Status in linux source package in Cosmic:
In Progress
Status in linux source package in Disco:
Invalid
Bug description:
[Impact]
* Tasks of a multi-threaded workload doing write() and fsync()
might deadlock in write_cache_pages(), preventing progress.
* The fix addresses a corner case in write_cache_pages() on
the range_cyclic implementation which allows the deadlock.
* Patch:
- commit 64081362e8ff4587b4554087f3cfc73d3e0a4cd7
("mm/page-writeback.c: fix range_cyclic writeback vs
writepages deadlock"), present in v4.20-rc1~92^2~19.
[Test Case]
* This issue originally has been hit by the 'perforce' (p4d)
tool in a XFS filesystem, but it's difficult/rare to occur.
* We've written an userspace + kernel module (kprobes-based)
to reproduce this problem and verify the test kernel/patch.
* The kprobes are strictly tied to particular kernel versions
because of the assembly instruction offsets. We'll provide
updated versions for -updates and -proposed for verification.
* Steps
(see output examples in comments):
- Userspace part:
$ gcc -o test test.c -pthread
- Kernel part:
$ touch Makefile
$ make -C /lib/modules/$(uname -r)/build M=$(pwd) obj-m=kprobe-test.o clean
$ make -C /lib/modules/$(uname -r)/build M=$(pwd) obj-m=kprobe-test.o
modules
- Shorter hung task timeout and higher console logging level
to notice the deadlocked tasks sooner, and watch progress:
$ echo 10 | sudo tee /proc/sys/kernel/hung_task_timeout_secs
$ echo 9 | sudo tee /proc/sys/kernel/printk
- Load module / Run userspace part (logging to kernel log) in XFS:
$ sudo insmod kprobe-test.ko
$ cd /path/to/xfs-mountpoint && sudo sh -c 'stdbuf -oL /path/to/test
>/dev/kmsg'
$ sudo rmmod kprobe-test
You may need to ctrl-z with the original kernel as 'test' doesn't
finish.
- Check kernel log or watch the system console:
$ dmesg
Check threads in D state.
$ ps -eLo pid,tid,state,comm | grep D | grep -e test -e kworker
[Regression Potential]
* The patch is small but changes core writeback infrastructure,
so there's a chance this may _affect_ some or other behavior
that has not been validated with our regression testing; not
exactly _break_ it. Please note our regression testing.
* This has been verified with 'xfstests' (not only for XFS fs,
despite its original name), used by major Linux filesystems
for regression testing during development. It's been tested
on systems with 24 and 4 CPUs (to exercise differences in
scalability, parallelism, and workload) and XFS and ext4
(reporter's environment + Ubuntu's default).
No regressions were observed (the set of failed tests is
the same in each system and tests failed in the same way).
* This has also been verified with 'iozone' for write intensive
tests, to exercise the writeback mechanism and no errors were
observed.
* The reporter has been running the test kernel with the patch
for weeks and has not observed any other issues/regressions.
[Other Info]
* This is only required in Cosmic (for the Bionic HWE kernel),
and is already applied in Disco.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1824827/+subscriptions
--
Mailing list: https://launchpad.net/~kernel-packages
Post to : [email protected]
Unsubscribe : https://launchpad.net/~kernel-packages
More help : https://help.launchpad.net/ListHelp