On Wednesday 14 November 2007 07:14, Herbert Xu wrote: > On Wed, Nov 14, 2007 at 12:15:19AM -0700, Denys Vlasenko wrote: > > Use alternative key setup implementation with mostly 64-bit ops > > if BITS_PER_LONG >= 64. Both much smaller and much faster. > > Can we please not have two versions of the same algorithm in C? > They're a pain to maintain and test. > > Where performance is paramount you could look at doing an assembly > version. Unlike two C versions at least that can be easily tested > by someone who has access to the platform in question. Having two versions, one in C and another in assembly cannot be easier than two C versions. Moreover, asm version will be arch specific - one needs to write separate amd64/ppc64/sparc64/etc versions. It means even more versions to maintain. It would be faster too, though, and I think it makes sense to do it for most popular arches sometime in future. What I have now is a generic 64-bit C implentation which is likely to be much faster and a bit smaller than 32-bit one on _all_ 64-bit arches. For i386 it's 33% faster. I think this win is big enough to justify having two versions. I think that you are right that having separate camellia_64.c with substantial duplication is bad. I reworked ot so that both 32-bit and 64-bit code is now in camellia.c, and I removed (merged) all duplicated stuff (constants, macros, and whole encryption/decryption part). I also split this patch into two parts for easier review: camellia5: adds 64-bit key setup camellia6: unifies encrypt/decrypt routines for different key lengths. This reduces module size by ~25%, with tiny (less than 1%) speed impact. Also collapses encrypt/decrypt into more readable (visually shorter) form using macros. Compiled it on i385 and amd64: text data bss dec hex filename 29724 224 0 29948 74fc 2.6.23.1.camellia.t/crypto/camellia.o 29233 224 0 29457 7311 2.6.23.1.camellia5.t/crypto/camellia.o 21190 224 0 21414 53a6 2.6.23.1.camellia6.t/crypto/camellia.o 22498 288 0 22786 5902 2.6.23.1.camellia.t64/crypto/camellia.o 21134 288 0 21422 53ae 2.6.23.1.camellia5.t64/crypto/camellia.o 16067 288 0 16355 3fe3 2.6.23.1.camellia6.t64/crypto/camellia.o Takamiya-san, can you review attached patches please? Signed-off-by: Denys Vlasenko -- vda