Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm verity: enable WQ_HIGHPRI on verify_wq

WQ_HIGHPRI increases throughput and decreases disk latency when using
dm-verity. This is important in Android for camera startup speed.

The following tests were run by doing 60 seconds of random reads using
a dm-verity device backed by two ramdisks.

Without WQ_HIGHPRI
lat (usec): min=13, max=3947, avg=69.53, stdev=50.55
READ: bw=51.1MiB/s (53.6MB/s), 51.1MiB/s-51.1MiB/s (53.6MB/s-53.6MB/s)

With WQ_HIGHPRI:
lat (usec): min=13, max=7854, avg=31.15, stdev=30.42
READ: bw=116MiB/s (121MB/s), 116MiB/s-116MiB/s (121MB/s-121MB/s)

Further testing was done by measuring how long it takes to open a
camera on an Android device.

Without WQ_HIGHPRI
Total verity work queue wait times (ms):
880.960, 789.517, 898.852

With WQ_HIGHPRI:
Total verity work queue wait times (ms):
528.824, 439.191, 433.300

The average time to open the camera is reduced by 350ms (or 40-50%).

Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>

authored by

Nathan Huckleberry and committed by
Mike Snitzer
afd41fff cea44663

+10 -8
+10 -8
drivers/md/dm-verity-target.c
··· 1401 1401 1402 1402 /* WQ_UNBOUND greatly improves performance when running on ramdisk */ 1403 1403 wq_flags = WQ_MEM_RECLAIM | WQ_UNBOUND; 1404 - if (v->use_tasklet) { 1405 - /* 1406 - * Allow verify_wq to preempt softirq since verification in 1407 - * tasklet will fall-back to using it for error handling 1408 - * (or if the bufio cache doesn't have required hashes). 1409 - */ 1410 - wq_flags |= WQ_HIGHPRI; 1411 - } 1404 + /* 1405 + * Using WQ_HIGHPRI improves throughput and completion latency by 1406 + * reducing wait times when reading from a dm-verity device. 1407 + * 1408 + * Also as required for the "try_verify_in_tasklet" feature: WQ_HIGHPRI 1409 + * allows verify_wq to preempt softirq since verification in tasklet 1410 + * will fall-back to using it for error handling (or if the bufio cache 1411 + * doesn't have required hashes). 1412 + */ 1413 + wq_flags |= WQ_HIGHPRI; 1412 1414 v->verify_wq = alloc_workqueue("kverityd", wq_flags, num_online_cpus()); 1413 1415 if (!v->verify_wq) { 1414 1416 ti->error = "Cannot allocate workqueue";