On 4/8/24 9:36 PM, Mikulas Patocka wrote:
It was reported that dm-crypt performs badly when the system is loaded[1].
So I'm adding an option "high_priority" that sets the workqueues and the
write_thread to nice level -20. This used to be default in the past, but
it caused audio skipping, so it had to be reverted - see the commit
f612b2132db529feac4f965f28a1b9258ea7c22b. This commit makes it optional,
so that normal users won't be harmed by it.
[1] https://listman.redhat.com/archives/dm-devel/2023-February/053410.html
It is pity that we need an optional flag here leaving decision to the user
(I would prefer a magic workqueue setting that will self-tune automagically.)
I guess people will set it and forgot about it (until some problem reappears)
- as we can store persistent performance flags for LUKS2, so this one will
be a new option there.
...
@@ -3399,18 +3401,22 @@ static int crypt_ctr(struct dm_target *t
}
ret = -ENOMEM;
- cc->io_queue = alloc_workqueue("kcryptd_io/%s", WQ_MEM_RECLAIM, 1, devname);
+ cc->io_queue = alloc_workqueue("kcryptd_io/%s", WQ_MEM_RECLAIM |
+ test_bit(DM_CRYPT_HIGH_PRIORITY, &cc->flags) * WQ_HIGHPRI,
+ 1, devname);
Just one nitpicking though:
test_bit(...) ? WQ_HIGHPRI : 0
looks more clear/readable to me (but I guess test_bit should always return 0/1 only).
Milan