X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=init.c;h=8c5e8420c1da8c78d9b1569e8606b5ebb715978d;hb=ccbb91cb902f5a1931681248735551815d12c653;hp=36c1839b18767ef3910a44f4fb56333f2562e2c5;hpb=08aae9a0d5f3d24152abd7515984439bbfd3c05d;p=fio.git diff --git a/init.c b/init.c index 36c1839b..8c5e8420 100644 --- a/init.c +++ b/init.c @@ -29,7 +29,7 @@ #define DEF_IO_ENGINE_NAME "sync" #define DEF_SEQUENTIAL (1) #define DEF_RAND_REPEAT (1) -#define DEF_OVERWRITE (1) +#define DEF_OVERWRITE (0) #define DEF_INVALIDATE (1) #define DEF_SYNCIO (0) #define DEF_RANDSEED (0xb1899bedUL) @@ -48,10 +48,12 @@ #define DEF_RWMIX_READ (50) #define DEF_NICE (0) #define DEF_NR_FILES (1) -#define DEF_UNLINK (0) +#define DEF_UNLINK (1) #define DEF_WRITE_BW_LOG (0) #define DEF_WRITE_LAT_LOG (0) #define DEF_NO_RAND_MAP (0) +#define DEF_HUGEPAGE_SIZE FIO_HUGE_PAGE +#define DEF_THINKTIME_BLOCKS (1) #define td_var_offset(var) ((size_t) &((struct thread_data *)0)->var) @@ -224,87 +226,92 @@ static struct fio_option options[] = { { .name = "thinktime", .type = FIO_OPT_INT, - .off1 = td_var_offset(thinktime) + .off1 = td_var_offset(thinktime), + }, + { + .name = "thinktime_blocks", + .type = FIO_OPT_INT, + .off1 = td_var_offset(thinktime_blocks), }, { .name = "rate", .type = FIO_OPT_INT, - .off1 = td_var_offset(rate) + .off1 = td_var_offset(rate), }, { .name = "ratemin", .type = FIO_OPT_INT, - .off1 = td_var_offset(ratemin) + .off1 = td_var_offset(ratemin), }, { .name = "ratecycle", .type = FIO_OPT_INT, - .off1 = td_var_offset(ratecycle) + .off1 = td_var_offset(ratecycle), }, { .name = "startdelay", .type = FIO_OPT_INT, - .off1 = td_var_offset(start_delay) + .off1 = td_var_offset(start_delay), }, { .name = "timeout", .type = FIO_OPT_STR_VAL_TIME, - .off1 = td_var_offset(timeout) + .off1 = td_var_offset(timeout), }, { .name = "invalidate", .type = FIO_OPT_INT, - .off1 = td_var_offset(invalidate_cache) + .off1 = td_var_offset(invalidate_cache), }, { .name = "sync", .type = FIO_OPT_INT, - .off1 = td_var_offset(sync_io) + .off1 = td_var_offset(sync_io), }, { .name = "bwavgtime", .type = FIO_OPT_INT, - .off1 = td_var_offset(bw_avg_time) + .off1 = td_var_offset(bw_avg_time), }, { .name = "create_serialize", .type = FIO_OPT_INT, - .off1 = td_var_offset(create_serialize) + .off1 = td_var_offset(create_serialize), }, { .name = "create_fsync", .type = FIO_OPT_INT, - .off1 = td_var_offset(create_fsync) + .off1 = td_var_offset(create_fsync), }, { .name = "loops", .type = FIO_OPT_INT, - .off1 = td_var_offset(loops) + .off1 = td_var_offset(loops), }, { .name = "numjobs", .type = FIO_OPT_INT, - .off1 = td_var_offset(numjobs) + .off1 = td_var_offset(numjobs), }, { .name = "cpuload", .type = FIO_OPT_INT, - .off1 = td_var_offset(cpuload) + .off1 = td_var_offset(cpuload), }, { .name = "cpuchunks", .type = FIO_OPT_INT, - .off1 = td_var_offset(cpucycle) + .off1 = td_var_offset(cpucycle), }, { .name = "direct", .type = FIO_OPT_INT, - .off1 = td_var_offset(odirect) + .off1 = td_var_offset(odirect), }, { .name = "overwrite", .type = FIO_OPT_INT, - .off1 = td_var_offset(overwrite) + .off1 = td_var_offset(overwrite), }, #ifdef FIO_HAVE_CPU_AFFINITY { @@ -316,11 +323,11 @@ static struct fio_option options[] = { { .name = "end_fsync", .type = FIO_OPT_INT, - .off1 = td_var_offset(end_fsync) + .off1 = td_var_offset(end_fsync), }, { .name = "unlink", - .type = FIO_OPT_STR_SET, + .type = FIO_OPT_INT, .off1 = td_var_offset(unlink), }, { @@ -358,6 +365,11 @@ static struct fio_option options[] = { .type = FIO_OPT_STR_SET, .off1 = td_var_offset(bs_unaligned), }, + { + .name = "hugepage-size", + .type = FIO_OPT_STR_VAL, + .off1 = td_var_offset(hugepage_size), + }, { .name = NULL, }, @@ -409,7 +421,7 @@ static struct option long_options[FIO_JOB_OPTS + FIO_CMD_OPTS] = { static int def_timeout = DEF_TIMEOUT; -static char fio_version_string[] = "fio 1.9"; +static char fio_version_string[] = "fio 1.10"; static char **ini_file; static int max_jobs = MAX_JOBS; @@ -508,6 +520,12 @@ static void fixup_options(struct thread_data *td) } if (td->bs_unaligned && (td->odirect || td->io_ops->flags & FIO_RAWIO)) log_err("fio: bs_unaligned may not work with raw io\n"); + + /* + * O_DIRECT and char doesn't mix, clear that flag if necessary. + */ + if (td->filetype == FIO_TYPE_CHAR && td->odirect) + td->odirect = 0; } /* @@ -564,8 +582,6 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) if (td->odirect) td->io_ops->flags |= FIO_RAWIO; - fixup_options(td); - td->filetype = FIO_TYPE_FILE; if (!stat(jobname, &sb)) { if (S_ISBLK(sb.st_mode)) @@ -574,6 +590,8 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) td->filetype = FIO_TYPE_CHAR; } + fixup_options(td); + if (td->filename) td->nr_uniq_files = 1; else @@ -582,10 +600,9 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) if (td->filetype == FIO_TYPE_FILE || td->filename) { char tmp[PATH_MAX]; int len = 0; - int i; if (td->directory && td->directory[0] != '\0') - sprintf(tmp, "%s/", td->directory); + len = sprintf(tmp, "%s/", td->directory); td->files = malloc(sizeof(struct fio_file) * td->nr_files); @@ -652,7 +669,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) c3 = to_kmg(td->min_bs[DDIR_WRITE]); c4 = to_kmg(td->max_bs[DDIR_WRITE]); - fprintf(f_out, "%s: (g=%d): rw=%s, odir=%d, bs=%s-%s/%s-%s, rate=%d, ioengine=%s, iodepth=%d\n", td->name, td->groupid, ddir_str[ddir], td->odirect, c1, c2, c3, c4, td->rate, td->io_ops->name, td->iodepth); + fprintf(f_out, "%s: (g=%d): rw=%s, odir=%u, bs=%s-%s/%s-%s, rate=%u, ioengine=%s, iodepth=%u\n", td->name, td->groupid, ddir_str[ddir], td->odirect, c1, c2, c3, c4, td->rate, td->io_ops->name, td->iodepth); free(c1); free(c2); @@ -787,12 +804,12 @@ static int str_rw_cb(void *data, const char *mem) td->sequential = 0; return 0; } else if (!strncmp(mem, "rw", 2)) { - td->ddir = 0; + td->ddir = DDIR_READ; td->iomix = 1; td->sequential = 1; return 0; } else if (!strncmp(mem, "randrw", 6)) { - td->ddir = 0; + td->ddir = DDIR_READ; td->iomix = 1; td->sequential = 0; return 0; @@ -821,6 +838,22 @@ static int str_verify_cb(void *data, const char *mem) return 1; } +/* + * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that. + */ +static char *get_mmap_file(const char *str) +{ + char *p = strstr(str, ":"); + + if (!p) + return NULL; + + p++; + strip_blank_front(&p); + strip_blank_end(p); + return strdup(p); +} + static int str_mem_cb(void *data, const char *mem) { struct thread_data *td = data; @@ -828,15 +861,45 @@ static int str_mem_cb(void *data, const char *mem) if (!strncmp(mem, "malloc", 6)) { td->mem_type = MEM_MALLOC; return 0; - } else if (!strncmp(mem, "shm", 3)) { - td->mem_type = MEM_SHM; + } else if (!strncmp(mem, "mmaphuge", 8)) { +#ifdef FIO_HAVE_HUGETLB + /* + * mmaphuge must be appended with the actual file + */ + td->mmapfile = get_mmap_file(mem); + if (!td->mmapfile) { + log_err("fio: mmaphuge:/path/to/file\n"); + return 1; + } + + td->mem_type = MEM_MMAPHUGE; return 0; +#else + log_err("fio: mmaphuge not available\n"); + return 1; +#endif } else if (!strncmp(mem, "mmap", 4)) { + /* + * Check if the user wants file backed memory. It's ok + * if there's no file given, we'll just use anon mamp then. + */ + td->mmapfile = get_mmap_file(mem); td->mem_type = MEM_MMAP; return 0; + } else if (!strncmp(mem, "shmhuge", 7)) { +#ifdef FIO_HAVE_HUGETLB + td->mem_type = MEM_SHMHUGE; + return 0; +#else + log_err("fio: shmhuge not available\n"); + return 1; +#endif + } else if (!strncmp(mem, "shm", 3)) { + td->mem_type = MEM_SHM; + return 0; } - log_err("fio: mem type: malloc, shm, mmap\n"); + log_err("fio: mem type: malloc, shm, shmhuge, mmap, mmaphuge\n"); return 1; } @@ -894,7 +957,7 @@ static int str_cpumask_cb(void *data, unsigned int *val) /* * This is our [ini] type file parser. */ -int parse_jobs_ini(char *file, int stonewall_flag) +static int parse_jobs_ini(char *file, int stonewall_flag) { unsigned int global; struct thread_data *td; @@ -1022,6 +1085,8 @@ static int fill_def_thread(void) def_thread.write_bw_log = write_bw_log; def_thread.write_lat_log = write_lat_log; def_thread.norandommap = DEF_NO_RAND_MAP; + def_thread.hugepage_size = DEF_HUGEPAGE_SIZE; + def_thread.thinktime_blocks = DEF_THINKTIME_BLOCKS; #ifdef FIO_HAVE_DISK_UTIL def_thread.do_disk_util = 1; #endif @@ -1102,7 +1167,6 @@ static int parse_cmd_line(int argc, char *argv[]) break; } default: - printf("optarg <<%s>>\n", argv[optind]); break; } }