Skip to contentSkip to conversation

Performance problems

dm-crypt Joakim Reinert 2 participants 2 messages Nov 19, 2012

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

i intended to use dm-crypt + LUKS to encrypt my entire file system. I ran into the following problem: After finishing cryptsetup i noticed by testing with dd (dd if=/dev/zero of=/dev/mapper/cryptroot) with different blocksizes, that i had read and write speeds of roughly 50MB/s. If you consider my setup, you will agree, that this is way too slow:

cpu:        i7-2620 (AES-NI integrated)
disk:       Crucial m4 226GB SSD
ram:       4GB DDR-3 1333Mhz (Single Channel)

Additional information:

kernel:    linux 3.6.6.1
os:         arch linux

I have loaded the module aesni_intel and verified that the refcnt changes in /proc/crypto when i open/close the encrypted partition.

I've already harrassed everybody at #archlinux and #crypto in IRC but nobody seems to know what the problem might be. I also installed truecrypt and did some benchmarks which show encryption and decryption speeds of roughly 2GB/s.

Might this have something to do with the data alignment on disk? At least with lvm it's suggested to define dataalignment=1m on SSD's. Is it possible to define data alignment for dm-crypt?

Another possibility that would come to mind is a bug in the kernel.

I followed this guide to set up the encryption by the way:
https://wiki.archlinux.org/index.php/Dm-crypt_with_LUKS

Hoping to hear from you soon.

Kind regards

Joakim Reinert
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQIcBAEBAgAGBQJQqh0yAAoJEMy9easHXAWxKCoQALOEDTnrfTRi8dNb254TDqt9 m8v5iwvZ/AcKAERp6BSHdFd+Vugu+oi/263nz6vpl7eFPXbkjaYg9YJn89Xmah/Q sQ0Ck4Jxv2Q4NSyLr9TzFPm9m7hbU/eKByJP3MuZSI8YXBH+7F+A8YeKFdq3WGTQ 5R26n87ERibOxtBFbcktcdrVhBEo7NNdlpwAQlh5VKn2w6WKFjxqZtLvCRSCK7dq nRHsfJVxMizQkVVhLyyoKxotqLLbeW7867faY3S9/vDfPqZtY6skgCPEpb/aZYBI k+/9E5jKLlDLOCHG0F8SUflFH4y0gMP3OP5MsAuysCQWjgZL2qGhcq/pjQy/Oabk LGB7CLNBHeNAABVUmxfPEBji2fAXx7ke84KNNpWRLzy4FCj2tJsqUM9remsXsvo+ efS97IME+WAZ0H4M0DJU31z/pj6Tk8fXamN1KqnvazEqf5qFL3hBlZ4pSyIQBkZs 29JgFF8sBon5Vq+j+thG3CPJRxREssf+tddm60w27+fxXxceBjePPgBolsw3e9UZ 4/ksgYiG6mOmLXO61sREd3W+hqdwhHy7cAeVrYr9dFHFu29DFgOZ7WZijNVJxnks gZd0uagk32LYySBYpvqslNNA//T+u2mcDF9vvXm+c94DfFqxD/ffYnZFwZCkFiY0 okEEhdqVpTNzaZpAxyIa
=C6JE
-----END PGP SIGNATURE-----

#1 lore raw
Quoted 2 lines · Joakim Reinert

I have loaded the module aesni_intel and verified that the refcnt changes in /proc/crypto when i open/close the encrypted partition.

How exactly the storage stack looks like? Using underlying partition? please paste lsblk output and cryptsetup luksDump
(you can remove slot info and hash, algorithm and payload offset is important here)

Try to add oflag=direct to your dd command (for write) or iflag=direct for read.

Yes, AES-NI should provide more than necessary performance.

Quoted 4 lines

I've already harrassed everybody at #archlinux and #crypto in IRC but nobody seems to know what the problem might be. I also installed truecrypt and did some benchmarks which show encryption and decryption speeds of roughly 2GB/s.

Truecrypt by default use dm-crypt (if not switched off in config), but internal benchmarks measure non-kernel services.

Quoted 3 lines

Might this have something to do with the data alignment on disk? At least with lvm it's suggested to define dataalignment=1m on SSD's. Is it possible to define data alignment for dm-crypt?

1MiB alignment is default for LUKS (and for LVM as well btw), depends on version and if underlying partition is aligned.

Need info above to check.

Milan