Skip to content

Commit

Permalink
stress-ng: fix rounding error in bogo ops-calculation
Browse files Browse the repository at this point in the history
There is a somewhat non-intuitive operation if one specifies the
number of stressors and the number of bogo-ops on the command line
and the number of bogo-ops is less than the number of stressors.
The expectation in this case (#stressors > #bogo-ops) that one  would
effectively run one op on each stressor.  However, what happens is
the number of operations rounds to 0 and the test runs until the
timeout period is reached instead of the expected short test run time.

If we round up the bogo ops calculation, then we get 1 ops run in
this case which feels more like the expected behavior.

Signed-off-by: Rob Colclaser <[email protected]>
Signed-off-by: Colin Ian King <[email protected]>
  • Loading branch information
Colin Ian King committed Feb 23, 2017
1 parent 57359ce commit 3c3eb14
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions stress-ng.c
Original file line number Diff line number Diff line change
Expand Up @@ -3067,10 +3067,10 @@ int main(int argc, char **argv)
" second run per stressor\n", g_opt_timeout);
}

/* Share bogo ops between processes equally */
/* Share bogo ops between processes equally, rounding up if nonzero bogo_ops */
for (i = 0; i < STRESS_MAX; i++) {
procs[i].bogo_ops = procs[i].num_procs ?
procs[i].bogo_ops / procs[i].num_procs : 0;
(procs[i].bogo_ops + (procs[i].num_procs - 1)) / procs[i].num_procs : 0;
procs[i].pids = NULL;

if (max_procs < procs[i].num_procs)
Expand Down

0 comments on commit 3c3eb14

Please sign in to comment.