Skip to content

Commit

Permalink
selftests/powerpc: Fix argument order to timer_sub()
Browse files Browse the repository at this point in the history
Commit c814bf9 ("powerpc/selftests: Use timersub() for
gettimeofday()"), got the order of arguments to timersub() wrong,
leading to a negative time delta being reported, eg:

  test: gettimeofday
  tags: git_version:v6.12-rc5-409-gdddf291c3030
  time = -3.297781
  success: gettimeofday

The correct order is minuend, subtrahend, which in this case is end,
start. Which gives:

  test: gettimeofday
  tags: git_version:v6.12-rc5-409-gdddf291c3030-dirty
  time = 3.300650
  success: gettimeofday

Fixes: c814bf9 ("powerpc/selftests: Use timersub() for gettimeofday()")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20241218114347.428108-1-mpe@ellerman.id.au
  • Loading branch information
Michael Ellerman authored and Madhavan Srinivasan committed Jan 11, 2025
1 parent 200f22f commit 2bf66e6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/testing/selftests/powerpc/benchmarks/gettimeofday.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static int test_gettimeofday(void)
gettimeofday(&tv_end, NULL);
}

timersub(&tv_start, &tv_end, &tv_diff);
timersub(&tv_end, &tv_start, &tv_diff);

printf("time = %.6f\n", tv_diff.tv_sec + (tv_diff.tv_usec) * 1e-6);

Expand Down

0 comments on commit 2bf66e6

Please sign in to comment.