summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mason <clm@fb.com>2024-04-09 12:15:10 -0700
committerChris Mason <clm@fb.com>2024-04-09 12:15:10 -0700
commit13bd9cb0246d1c363a82ed91fcd4261652267a55 (patch)
tree87d187d4e6f1d16af629f402dde6605e0a8709c7
parent18929adabe5ca889a8e3ae84568b4bd8384fed5e (diff)
downloadsimoop-13bd9cb0246d1c363a82ed91fcd4261652267a55.tar.gz
Add fillonly
Signed-off-by: Chris Mason <clm@fb.com>
-rw-r--r--simoop.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/simoop.c b/simoop.c
index 6410ab6..cda681f 100644
--- a/simoop.c
+++ b/simoop.c
@@ -84,6 +84,9 @@ static unsigned long thinking_mem = 128 * 1024 * 1024UL;
static int funksync = 0;
static int writethrough = 0;
+/* should we just exit after filling? */
+static int fill_only = 0;
+
/* are we just appending bytes onto the ends of the working set files */
static int append_mode = 0;
static int truncate_original = 0;
@@ -263,11 +266,7 @@ static void init_pattern_buffer(char *buffer, uint64_t seed)
pattern[0] = rand_r(&randr_seed);
for (i = 1; i < 128; i++) {
- /*
- * we originally used data here, but this is easier for
- * debugging memory corruptions
- */
- pattern[i] = 'd';
+ pattern[i] = rand_r(&randr_seed);
}
while(length > 0) {
@@ -470,7 +469,7 @@ unsigned long long parse_size(char *s)
return ret;
}
-char *option_string = "t:s:C:c:r:n:f:FR:T:m:W:M:w:i:D:oaOVzNIevUu";
+char *option_string = "t:s:C:c:r:n:f:FR:T:m:W:M:w:i:D:oaOVzNIevUuE";
static struct option long_options[] = {
{"appendmode", required_argument, 0, 'a'},
{"mmapsize", required_argument, 0, 'M'},
@@ -498,6 +497,7 @@ static struct option long_options[] = {
{"zallocate", no_argument, 0, 'z'},
{"nocleanup", no_argument, 0, 'N'},
{"erase", no_argument, 0, 'e'},
+ {"fillonly", no_argument, 0, 'E'},
{"help", no_argument, 0, HELP_LONG_OPT},
{0, 0, 0, 0}
};
@@ -529,6 +529,7 @@ static void print_usage(void)
"\t-z (--zallocate): use fallocate for initial file creation\n"
"\t-N (--nocleanup): don't cleanup temp files from the last run\n"
"\t-e (--erase): delete the data files at the start of the run\n"
+ "\t-E (--fillonly): exit after filling\n"
"\t-U (--writethrough): sync_file_range every write\n"
"\t-u (--unalignedstress): take extra steps to be mean to the FS\n"
"\t dir1 [dir2 ... dirN]\n"
@@ -560,6 +561,9 @@ static void parse_options(int ac, char **av)
case 'e':
truncate_original = 1;
break;
+ case 'E':
+ fill_only = 1;
+ break;
case 's':
found_sleeptime = atoi(optarg);
break;
@@ -601,6 +605,7 @@ static void parse_options(int ac, char **av)
case 'n':
num_files = atoi(optarg);
num_files = ((num_files + FILES_SPLIT - 1)/ FILES_SPLIT) * FILES_SPLIT;
+ fprintf(stderr, "Creating %d files\n", num_files);
break;
case 'R':
read_size = parse_size(optarg);
@@ -1661,14 +1666,18 @@ void *worker_thread(void *arg)
memset(td->stats, 0, sizeof(*td->stats) * TOTAL_STATS);
warmup_zerod = 1;
}
- if (read_size)
- read_buf = aligned_memory_alloc(read_size);
- else
+ if (read_size) {
+ if (!read_buf)
+ read_buf = aligned_memory_alloc(read_size);
+ } else {
read_buf = NULL;
- if (write_size)
- write_buf = aligned_memory_alloc(write_size);
- else
+ }
+ if (write_size) {
+ if (!write_buf)
+ write_buf = aligned_memory_alloc(write_size);
+ } else {
write_buf = NULL;
+ }
/* if someone swapped out our thinking mem, bring it back */
if (thinking_mem)
@@ -1725,14 +1734,14 @@ void *worker_thread(void *arg)
}
usec_spin(cputime);
- aligned_memory_free(read_buf, read_size);
- aligned_memory_free(write_buf, write_size);
td->work_done++;
if (sleeptime)
usleep(sleeptime);
}
+ aligned_memory_free(read_buf, read_size);
+ aligned_memory_free(write_buf, write_size);
free(mem);
return NULL;
}
@@ -2017,6 +2026,9 @@ int main(int ac, char **av)
/* fill up our directory tree. This might take a really long time */
run_filler_threads();
+ if (fill_only)
+ exit(0);
+
stopping = 0;
if (signal(SIGINT, mysigint) == SIG_ERR) {
perror("signal");