Forráskód Böngészése

crypto: tcrpyt - Remove unnecessary kmap/kunmap calls

Noticed by Neil Horman: we are doing unnecessary kmap/kunmap calls
on kmalloced memory.  This patch removes them.  For the purposes of
testing SG construction, the underlying crypto code already does plenty
of kmap/kunmap calls anyway.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Herbert Xu 17 éve
szülő
commit
4b22f0ddb6
1 módosított fájl, 5 hozzáadás és 10 törlés
  1. 5 10
      crypto/tcrypt.c

+ 5 - 10
crypto/tcrypt.c

@@ -23,7 +23,6 @@
 #include <linux/scatterlist.h>
 #include <linux/scatterlist.h>
 #include <linux/string.h>
 #include <linux/string.h>
 #include <linux/crypto.h>
 #include <linux/crypto.h>
-#include <linux/highmem.h>
 #include <linux/moduleparam.h>
 #include <linux/moduleparam.h>
 #include <linux/jiffies.h>
 #include <linux/jiffies.h>
 #include <linux/timex.h>
 #include <linux/timex.h>
@@ -31,7 +30,7 @@
 #include "tcrypt.h"
 #include "tcrypt.h"
 
 
 /*
 /*
- * Need to kmalloc() memory for testing kmap().
+ * Need to kmalloc() memory for testing.
  */
  */
 #define TVMEMSIZE	16384
 #define TVMEMSIZE	16384
 #define XBUFSIZE	32768
 #define XBUFSIZE	32768
@@ -376,13 +375,12 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
 				goto next_one;
 				goto next_one;
 			}
 			}
 
 
-			q = kmap(sg_page(&sg[0])) + sg[0].offset;
+			q = input;
 			hexdump(q, template[i].rlen);
 			hexdump(q, template[i].rlen);
 
 
 			printk(KERN_INFO "enc/dec: %s\n",
 			printk(KERN_INFO "enc/dec: %s\n",
 			       memcmp(q, template[i].result,
 			       memcmp(q, template[i].result,
 				      template[i].rlen) ? "fail" : "pass");
 				      template[i].rlen) ? "fail" : "pass");
-			kunmap(sg_page(&sg[0]));
 next_one:
 next_one:
 			if (!template[i].key)
 			if (!template[i].key)
 				kfree(key);
 				kfree(key);
@@ -482,7 +480,7 @@ next_one:
 
 
 			for (k = 0, temp = 0; k < template[i].np; k++) {
 			for (k = 0, temp = 0; k < template[i].np; k++) {
 				printk(KERN_INFO "page %u\n", k);
 				printk(KERN_INFO "page %u\n", k);
-				q = kmap(sg_page(&sg[k])) + sg[k].offset;
+				q = &axbuf[IDX[k]];
 				hexdump(q, template[i].tap[k]);
 				hexdump(q, template[i].tap[k]);
 				printk(KERN_INFO "%s\n",
 				printk(KERN_INFO "%s\n",
 				       memcmp(q, template[i].result + temp,
 				       memcmp(q, template[i].result + temp,
@@ -500,7 +498,6 @@ next_one:
 				}
 				}
 
 
 				temp += template[i].tap[k];
 				temp += template[i].tap[k];
-				kunmap(sg_page(&sg[k]));
 			}
 			}
 		}
 		}
 	}
 	}
@@ -609,13 +606,12 @@ static void test_cipher(char *algo, int enc,
 				goto out;
 				goto out;
 			}
 			}
 
 
-			q = kmap(sg_page(&sg[0])) + sg[0].offset;
+			q = data;
 			hexdump(q, template[i].rlen);
 			hexdump(q, template[i].rlen);
 
 
 			printk("%s\n",
 			printk("%s\n",
 			       memcmp(q, template[i].result,
 			       memcmp(q, template[i].result,
 				      template[i].rlen) ? "fail" : "pass");
 				      template[i].rlen) ? "fail" : "pass");
-			kunmap(sg_page(&sg[0]));
 		}
 		}
 		kfree(data);
 		kfree(data);
 	}
 	}
@@ -689,7 +685,7 @@ static void test_cipher(char *algo, int enc,
 			temp = 0;
 			temp = 0;
 			for (k = 0; k < template[i].np; k++) {
 			for (k = 0; k < template[i].np; k++) {
 				printk("page %u\n", k);
 				printk("page %u\n", k);
-				q = kmap(sg_page(&sg[k])) + sg[k].offset;
+				q = &xbuf[IDX[k]];
 				hexdump(q, template[i].tap[k]);
 				hexdump(q, template[i].tap[k]);
 				printk("%s\n",
 				printk("%s\n",
 					memcmp(q, template[i].result + temp,
 					memcmp(q, template[i].result + temp,
@@ -704,7 +700,6 @@ static void test_cipher(char *algo, int enc,
 					hexdump(&q[template[i].tap[k]], n);
 					hexdump(&q[template[i].tap[k]], n);
 				}
 				}
 				temp += template[i].tap[k];
 				temp += template[i].tap[k];
-				kunmap(sg_page(&sg[k]));
 			}
 			}
 		}
 		}
 	}
 	}