X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=crypto%2Fxor.c;h=65c7b416b4a3e4d9e2ad08c41a1fcec06e222f8e;hb=fb827ec68446c83e9e8754fa9b55aed27ecc4661;hp=b75182d8ab1460b141619cc63af15d03fe6b2475;hpb=7bd9db83087aecef8279c0b8b9dfef4db4a8fc3c;p=pandora-kernel.git diff --git a/crypto/xor.c b/crypto/xor.c index b75182d8ab14..65c7b416b4a3 100644 --- a/crypto/xor.c +++ b/crypto/xor.c @@ -21,6 +21,7 @@ #include #include #include +#include #include /* The xor routines to use. */ @@ -63,12 +64,14 @@ static void do_xor_speed(struct xor_block_template *tmpl, void *b1, void *b2) { int speed; - unsigned long now; + unsigned long now, j; int i, count, max; tmpl->next = template_list; template_list = tmpl; + preempt_disable(); + /* * Count the number of XORs done during a whole jiffy, and use * this to calculate the speed of checksumming. We use a 2-page @@ -76,9 +79,11 @@ do_xor_speed(struct xor_block_template *tmpl, void *b1, void *b2) */ max = 0; for (i = 0; i < 5; i++) { - now = jiffies; + j = jiffies; count = 0; - while (jiffies == now) { + while ((now = jiffies) == j) + cpu_relax(); + while (time_before(jiffies, now + 1)) { mb(); /* prevent loop optimzation */ tmpl->do_2(BENCH_SIZE, b1, b2); mb(); @@ -89,6 +94,8 @@ do_xor_speed(struct xor_block_template *tmpl, void *b1, void *b2) max = count; } + preempt_enable(); + speed = max * (HZ * BENCH_SIZE / 1024); tmpl->speed = speed; @@ -129,9 +136,9 @@ calibrate_xor_blocks(void) if (fastest) { printk(KERN_INFO "xor: automatically using best " - "checksumming function: %s\n", - fastest->name); + "checksumming function:\n"); xor_speed(fastest); + goto out; } else { printk(KERN_INFO "xor: measuring software checksum speed\n"); XOR_TRY_TEMPLATES; @@ -146,6 +153,7 @@ calibrate_xor_blocks(void) #undef xor_speed + out: free_pages((unsigned long)b1, 2); active_template = fastest;