aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Lu <aaron.lu@intel.com>2016-09-30 14:38:19 +0800
committerFengguang Wu <fengguang.wu@intel.com>2016-10-08 14:16:23 +0800
commit7d864b2df83f935272577826d2909c4182a896f5 (patch)
tree31dda2010a8b8713a0c65ae3b8e862911d55d715
parent24cf56be04a0c0ea8a288d10c56a6895aae745a7 (diff)
downloadvm-scalability-7d864b2df83f935272577826d2909c4182a896f5.tar.gz
usemem: do not pass opt_bytes to do_units
The param bytes in function do_units serves two purpose: 1 As the passed param to tell the function how many bytes need to be processed; 2 As a local variable that gets decremented each time a unit is processed and break the loop once it gets zero. Since do_units is always called with the global opt_bytes as its param, the 1st purpose isn't much useful as we can always get the value from the global opt_bytes. For purpose 2, we probably should be using a local variable instead. There should be no functionality change. Signed-off-by: Aaron Lu <aaron.lu@intel.com> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
-rw-r--r--usemem.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usemem.c b/usemem.c
index 9c7481a..ffe89dd 100644
--- a/usemem.c
+++ b/usemem.c
@@ -528,12 +528,13 @@ unsigned long do_unit(unsigned long bytes, struct drand48_data *rand_data)
return rw_bytes;
}
-long do_units(unsigned long bytes)
+long do_units(void)
{
struct drand48_data rand_data;
unsigned long delta_us;
unsigned long throughput;
unsigned long unit_bytes = done_bytes;
+ unsigned long bytes = opt_bytes;
if (opt_detach)
detach();
@@ -591,10 +592,10 @@ int do_task(void)
int i;
if (!nr_thread)
- return do_units(opt_bytes);
+ return do_units();
for (i = 0; i < nr_thread; i++) {
- ret = pthread_create(&threads[i], NULL, (start_routine)do_units, (void *)opt_bytes);
+ ret = pthread_create(&threads[i], NULL, (start_routine)do_units, NULL);
if (ret) {
perror("pthread_create");
exit(1);