aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-06-25 06:43:48 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2009-06-25 06:43:48 -0400
commit0b67fb65d1b2ba1396de69112b8b9bc95d8d5feb (patch)
tree0e94ffea1c1c7a42fb36e231472ccab963901355
parent435578aeaad5859dda8657e3ed2c1a5bc1e524ec (diff)
crypto: skcipher - Change default sync geniv on SMP to eseqiv
As it stands we use chainiv for sync algorithms and eseqiv for async algorithms. However, when there is more than one CPU chainiv forces all processing to be serialised which is usually not what you want. Also, the added overhead of eseqiv isn't that great. Therefore this patch changes the default sync geniv on SMP machines to eseqiv. For the odd situation where the overhead is unacceptable then chainiv is still available as an option. Note that on UP machines chainiv is still preferred over eseqiv for sync algorithms. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/ablkcipher.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c
index 43fc8fb9f978..03fb5facf0b4 100644
--- a/crypto/ablkcipher.c
+++ b/crypto/ablkcipher.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <crypto/internal/skcipher.h> 16#include <crypto/internal/skcipher.h>
17#include <linux/cpumask.h>
17#include <linux/err.h> 18#include <linux/err.h>
18#include <linux/init.h> 19#include <linux/init.h>
19#include <linux/kernel.h> 20#include <linux/kernel.h>
@@ -25,6 +26,8 @@
25 26
26#include "internal.h" 27#include "internal.h"
27 28
29static const char *skcipher_default_geniv __read_mostly;
30
28static int setkey_unaligned(struct crypto_ablkcipher *tfm, const u8 *key, 31static int setkey_unaligned(struct crypto_ablkcipher *tfm, const u8 *key,
29 unsigned int keylen) 32 unsigned int keylen)
30{ 33{
@@ -180,7 +183,8 @@ EXPORT_SYMBOL_GPL(crypto_givcipher_type);
180 183
181const char *crypto_default_geniv(const struct crypto_alg *alg) 184const char *crypto_default_geniv(const struct crypto_alg *alg)
182{ 185{
183 return alg->cra_flags & CRYPTO_ALG_ASYNC ? "eseqiv" : "chainiv"; 186 return alg->cra_flags & CRYPTO_ALG_ASYNC ?
187 "eseqiv" : skcipher_default_geniv;
184} 188}
185 189
186static int crypto_givcipher_default(struct crypto_alg *alg, u32 type, u32 mask) 190static int crypto_givcipher_default(struct crypto_alg *alg, u32 type, u32 mask)
@@ -361,3 +365,17 @@ err:
361 return ERR_PTR(err); 365 return ERR_PTR(err);
362} 366}
363EXPORT_SYMBOL_GPL(crypto_alloc_ablkcipher); 367EXPORT_SYMBOL_GPL(crypto_alloc_ablkcipher);
368
369static int __init skcipher_module_init(void)
370{
371 skcipher_default_geniv = num_possible_cpus() > 1 ?
372 "eseqiv" : "chainiv";
373 return 0;
374}
375
376static void skcipher_module_exit(void)
377{
378}
379
380module_init(skcipher_module_init);
381module_exit(skcipher_module_exit);