Return-Path: Received: from mail.bisel.ru (mail.bisel.ru [80.93.56.210]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.saout.de (Postfix) with ESMTPS for ; Tue, 16 Nov 2010 07:54:08 +0100 (CET) Date: Tue, 16 Nov 2010 09:53:56 +0300 From: Igor Novgorodov Message-ID: <1906221959.20101116095356@novg.net> In-Reply-To: <4CE142C3.1070408@redhat.com> References: <566573504.20101115153604@novg.net> <4CE142C3.1070408@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [dm-crypt] AES-XTS performance Reply-To: Igor Novgorodov List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Milan Broz Cc: dm-crypt@saout.de > On 11/15/2010 01:36 PM, Igor Novgorodov wrote: >> Hello! >> I've got a question regarding encryption performance with >> XTS mode in dm-crypt, which is too low for what i >> get. >>=20 >> Test system: >> - Supermicro X8DTH-6F >> - 1 x 4-Core Xeon E5620 with HyperThreading & AES-NI >> - 12Gb RAM DDR3 Reg ECC >>=20 >> Preparation: >> # mount -t tmpfs tmpfs -o size=3D4G /mnt/tmpfs >> # dd if=3D/dev/zero of=3D/mnt/tmpfs/image >> # losetup /dev/loop0 /mnt/tmpfs/image > Loop is not ideal device to test but it is not the problem. > The main problem is that dm-crypt uses only one core per device. > If you want to do some tests, try this patch > http://lkml.org/lkml/2010/11/12/344 > (but there is still some issues and it will not help much > if only one process generates IOs.) Yes, i know about synchronous nature of dm-crypt, but i thought that using AES-NI somehow alleviates this problem, as it as i remember uses asynchronous crypto api (AEAD?), but i may be wrong, just read somewhere. Thanks, i'll try your patch and will report of any problems found. >> And with CBC mode we get reasonable read performance (for AES-NI), but >> writing is as almost slow as before: > I think the write slowdown is partially loop problem here. Yes, it looks so, as AES is quite symmetrical on encryption/decryption. Tests on real filesystem shows same enc/dec speed. >> What is the problem here? >> With aes-cbc-plain64 i get ~560Mb read, and another slow write ~110Mb. > Nice to benchmarking, but do not use plain/plain64 in CBC mode for data. > (It is vulnerable.) Of course, i've read about watermarking attacks. If XTS mode will remain too slow, i'll switch to CBC-ESSIV. >> Any suggestions? Why write speed is so low? > Can you please try patch above? Will it help here? > (There are more possible fixes but stability is the No.1 here, > and we have still some unresolved problems with that.) >> And why with XTS i get 50% speed drop, is that normal? > In principle, XTS run 2x AES operation in comparison to CBC mode, > so I would say it is expected. Hmm. It looks correct. >> In Windows with Trucrypt internal benchmark i get 1.6Gb/s >> AES encryption speed with AES-NI even on low-end Core i5-620. > You cannot compare internal benchmark to dm-crypt over loop. > dm-crypt uses 512b sectors and mainly block layer limits it here. Accoding to http://www.truecrypt.org/docs/?s=3Dmodes-of-operation truecrypt uses 512b unit size too, but, of course, raw in-memory encryption is not compared to multiple-layer model of linux, but i thought that difference of hunderds of percents is too big. But it may be due to a multithreaded nature of TC. > If you use device-mapper zero target as backing device you can get > better numbers but still it is comparing something different. I'll try that, thanks, i didn't even thought of this target before :) > Milan