From 3c3eb14a6617fc53a9993dda156cf35a2dbc30d2 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 23 Feb 2017 09:38:54 +0000 Subject: [PATCH] stress-ng: fix rounding error in bogo ops-calculation 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 Signed-off-by: Colin Ian King --- stress-ng.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stress-ng.c b/stress-ng.c index bb1d5d845..6e1f971d4 100644 --- a/stress-ng.c +++ b/stress-ng.c @@ -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)