From fca7035863bd570270376a0c06776e5549ff813e Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 6 Jul 2011 20:12:54 +0200 Subject: [PATCH] Add --max-jobs/-j command line option And shrink OSX max default number of jobs supported. OSX has, by default, a very small shared memory segment available. Signed-off-by: Jens Axboe --- README | 1 + eta.c | 2 +- fio.c | 2 +- fio.h | 2 +- init.c | 16 +++++++++++++++- os/os-mac.h | 6 ++++++ os/os.h | 4 ++++ 7 files changed, 29 insertions(+), 4 deletions(-) diff --git a/README b/README index ca7f73c3..08b4df64 100644 --- a/README +++ b/README @@ -145,6 +145,7 @@ $ fio sections can be specified. --alloc-size=kb Set smalloc pool to this size in kb (def 1024) --warnings-fatal Fio parser warnings are fatal + --max-jobs Maximum number of threads/processes to support Any parameters following the options will be assumed to be job files, diff --git a/eta.c b/eta.c index b367ce9d..e1cced46 100644 --- a/eta.c +++ b/eta.c @@ -7,7 +7,7 @@ #include "fio.h" -static char run_str[MAX_JOBS + 1]; +static char run_str[REAL_MAX_JOBS + 1]; /* * Sets the status of the 'td' in the printed status map. diff --git a/fio.c b/fio.c index 5ea1a2c3..01aa1d67 100644 --- a/fio.c +++ b/fio.c @@ -1515,7 +1515,7 @@ static void run_threads(void) set_genesis_time(); while (todo) { - struct thread_data *map[MAX_JOBS]; + struct thread_data *map[REAL_MAX_JOBS]; struct timeval this_start; int this_jobs = 0, left; diff --git a/fio.h b/fio.h index 16866ddf..fc64e3ad 100644 --- a/fio.h +++ b/fio.h @@ -557,7 +557,7 @@ static inline void fio_ro_check(struct thread_data *td, struct io_u *io_u) #define RAND_MAP_IDX(f, b) (TO_MAP_BLOCK(f, b) / BLOCKS_PER_MAP) #define RAND_MAP_BIT(f, b) (TO_MAP_BLOCK(f, b) & (BLOCKS_PER_MAP - 1)) -#define MAX_JOBS (2048) +#define REAL_MAX_JOBS 2048 #define td_non_fatal_error(e) ((e) == EIO || (e) == EILSEQ) diff --git a/init.c b/init.c index d5813c60..baf3130b 100644 --- a/init.c +++ b/init.c @@ -27,7 +27,7 @@ static char fio_version_string[] = "fio 1.55"; #define FIO_RANDSEED (0xb1899bedUL) static char **ini_file; -static int max_jobs = MAX_JOBS; +static int max_jobs = FIO_MAX_JOBS; static int dump_cmdline; static struct thread_data def_thread; @@ -143,6 +143,11 @@ static struct option l_opts[FIO_NR_OPTIONS] = { .has_arg = no_argument, .val = 'w', }, + { + .name = (char *) "max-jobs", + .has_arg = required_argument, + .val = 'j', + }, { .name = NULL, }, @@ -1039,6 +1044,7 @@ static void usage(const char *name) printf("\t--alloc-size=kb\tSet smalloc pool to this size in kb" " (def 1024)\n"); printf("\t--warnings-fatal Fio parser warnings are fatal\n"); + printf("\t--max-jobs\tMaximum number of threads/processes to support\n"); printf("\nFio was written by Jens Axboe "); printf("\n Jens Axboe \n"); } @@ -1247,6 +1253,14 @@ static int parse_cmd_line(int argc, char *argv[]) case 'w': warnings_fatal = 1; break; + case 'j': + max_jobs = atoi(optarg); + if (!max_jobs || max_jobs > REAL_MAX_JOBS) { + log_err("fio: invalid max jobs: %d\n", max_jobs); + do_exit++; + exit_val = 1; + } + break; default: do_exit++; exit_val = 1; diff --git a/os/os-mac.h b/os/os-mac.h index 42e1fea9..7446a43d 100644 --- a/os/os-mac.h +++ b/os/os-mac.h @@ -25,6 +25,12 @@ #define OS_MAP_ANON MAP_ANON +/* + * OSX has a pitifully small shared memory segment by default, + * so default to a lower number of max jobs supported + */ +#define FIO_MAX_JOBS 128 + typedef off_t off64_t; /* OS X as of 10.6 doesn't have the timer_* functions. diff --git a/os/os.h b/os/os.h index 1569e409..4bbdd623 100644 --- a/os/os.h +++ b/os/os.h @@ -106,6 +106,10 @@ typedef unsigned long os_cpu_mask_t; #define FIO_PREFERRED_ENGINE "sync" #endif +#ifndef FIO_MAX_JOBS +#define FIO_MAX_JOBS 2048 +#endif + #ifndef FIO_HAVE_BLKTRACE static inline int is_blktrace(const char *fname) { -- 2.25.1