[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#976616: Abysmally slow writes to crypted partition



Package: partman-crypto

This isn't really a bug in partman-crypto, but I'm reporting it here
for tracking purposes as requested by Steve McIntyre.

The symptom I first experienced was when doing an install on a Tiger
Lake laptop with a 1TB SSD.  The step where we run blockdev-wipe was
going to take over 20 hours.

I am currently investigating *why* it's taking so long.  The SSD is
capable of writing at 1.2GB/s and the CPU is capable of encrypting at
>4GB/s, so the measured 13.7MB/s is ridiculous.

What I've discovered so far is that writing through the page cache
is (part of) the problem:

# dd if=/dev/zero bs=64k count=1000 of=/dev/mapper/nvme0n1p4_crypt
4.79s, 13.7MB/s

# dd if=/dev/zero bs=64k count=100000 of=/dev/mapper/nvme0n1p4_crypt oflag=direct
13.6s, 481MB/s

If you need to get a release out that doesn't crater performance before I
find & fix this bug in the kernel, you could change blockdev-wipe.c to use
O_DIRECT.  That would be a matter of changing the calloc() call on line
86 to posix_memalign() (and an optional memset()) and specifying O_DIRECT
on line 161.  You need to align to at least 512 bytes, and for safety,
I'd align to sysconf(_SC_PAGESIZE).  I have not tested this workaround.


Reply to: