Skip to content

Commit

Permalink
crypto: wait for a full jiffy in do_xor_speed
Browse files Browse the repository at this point in the history
In the existing do_xor_speed(), there is no guarantee that we actually
run do_2() for a full jiffy. We get the current jiffy, then run do_2()
until the next jiffy.

Instead, let's get the current jiffy, then wait until the next jiffy
to start our test.

Signed-off-by: Jim Kukunas <[email protected]>
Signed-off-by: NeilBrown <[email protected]>
  • Loading branch information
jtkukunas authored and neilbrown committed May 22, 2012
1 parent 3ea7daa commit 6a32847
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crypto/xor.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ 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;
Expand All @@ -76,9 +76,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();
Expand Down

0 comments on commit 6a32847

Please sign in to comment.