diff options
Diffstat (limited to 'crypto')
| -rw-r--r-- | crypto/xor.c | 18 |
1 files changed, 13 insertions, 5 deletions
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 @@ | |||
| 21 | #include <linux/gfp.h> | 21 | #include <linux/gfp.h> |
| 22 | #include <linux/raid/xor.h> | 22 | #include <linux/raid/xor.h> |
| 23 | #include <linux/jiffies.h> | 23 | #include <linux/jiffies.h> |
| 24 | #include <linux/preempt.h> | ||
| 24 | #include <asm/xor.h> | 25 | #include <asm/xor.h> |
| 25 | 26 | ||
| 26 | /* The xor routines to use. */ | 27 | /* The xor routines to use. */ |
| @@ -63,12 +64,14 @@ static void | |||
| 63 | do_xor_speed(struct xor_block_template *tmpl, void *b1, void *b2) | 64 | do_xor_speed(struct xor_block_template *tmpl, void *b1, void *b2) |
| 64 | { | 65 | { |
| 65 | int speed; | 66 | int speed; |
| 66 | unsigned long now; | 67 | unsigned long now, j; |
| 67 | int i, count, max; | 68 | int i, count, max; |
| 68 | 69 | ||
| 69 | tmpl->next = template_list; | 70 | tmpl->next = template_list; |
| 70 | template_list = tmpl; | 71 | template_list = tmpl; |
| 71 | 72 | ||
| 73 | preempt_disable(); | ||
| 74 | |||
| 72 | /* | 75 | /* |
| 73 | * Count the number of XORs done during a whole jiffy, and use | 76 | * Count the number of XORs done during a whole jiffy, and use |
| 74 | * this to calculate the speed of checksumming. We use a 2-page | 77 | * 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) | |||
| 76 | */ | 79 | */ |
| 77 | max = 0; | 80 | max = 0; |
| 78 | for (i = 0; i < 5; i++) { | 81 | for (i = 0; i < 5; i++) { |
| 79 | now = jiffies; | 82 | j = jiffies; |
| 80 | count = 0; | 83 | count = 0; |
| 81 | while (jiffies == now) { | 84 | while ((now = jiffies) == j) |
| 85 | cpu_relax(); | ||
| 86 | while (time_before(jiffies, now + 1)) { | ||
| 82 | mb(); /* prevent loop optimzation */ | 87 | mb(); /* prevent loop optimzation */ |
| 83 | tmpl->do_2(BENCH_SIZE, b1, b2); | 88 | tmpl->do_2(BENCH_SIZE, b1, b2); |
| 84 | mb(); | 89 | mb(); |
| @@ -89,6 +94,8 @@ do_xor_speed(struct xor_block_template *tmpl, void *b1, void *b2) | |||
| 89 | max = count; | 94 | max = count; |
| 90 | } | 95 | } |
| 91 | 96 | ||
| 97 | preempt_enable(); | ||
| 98 | |||
| 92 | speed = max * (HZ * BENCH_SIZE / 1024); | 99 | speed = max * (HZ * BENCH_SIZE / 1024); |
| 93 | tmpl->speed = speed; | 100 | tmpl->speed = speed; |
| 94 | 101 | ||
| @@ -129,9 +136,9 @@ calibrate_xor_blocks(void) | |||
| 129 | 136 | ||
| 130 | if (fastest) { | 137 | if (fastest) { |
| 131 | printk(KERN_INFO "xor: automatically using best " | 138 | printk(KERN_INFO "xor: automatically using best " |
| 132 | "checksumming function: %s\n", | 139 | "checksumming function:\n"); |
| 133 | fastest->name); | ||
| 134 | xor_speed(fastest); | 140 | xor_speed(fastest); |
| 141 | goto out; | ||
| 135 | } else { | 142 | } else { |
| 136 | printk(KERN_INFO "xor: measuring software checksum speed\n"); | 143 | printk(KERN_INFO "xor: measuring software checksum speed\n"); |
| 137 | XOR_TRY_TEMPLATES; | 144 | XOR_TRY_TEMPLATES; |
| @@ -146,6 +153,7 @@ calibrate_xor_blocks(void) | |||
| 146 | 153 | ||
| 147 | #undef xor_speed | 154 | #undef xor_speed |
| 148 | 155 | ||
| 156 | out: | ||
| 149 | free_pages((unsigned long)b1, 2); | 157 | free_pages((unsigned long)b1, 2); |
| 150 | 158 | ||
| 151 | active_template = fastest; | 159 | active_template = fastest; |
