Add --max-jobs/-j command line option
authorJens Axboe <jaxboe@fusionio.com>
Wed, 6 Jul 2011 18:12:54 +0000 (20:12 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Wed, 6 Jul 2011 18:12:54 +0000 (20:12 +0200)
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 <jaxboe@fusionio.com>
README
eta.c
fio.c
fio.h
init.c
os/os-mac.h
os/os.h

diff --git a/README b/README
index ca7f73c33d4f19b299536edd95a59aef2c8fd697..08b4df645ff1287a7e2571bb84d9d9fe35876365 100644 (file)
--- 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
                                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,
 
 
 Any parameters following the options will be assumed to be job files,
diff --git a/eta.c b/eta.c
index b367ce9d7722cf492811b38deb85e83afc56cf35..e1cced4643873a1e1388ac3c9b27bc0eeb904e26 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -7,7 +7,7 @@
 
 #include "fio.h"
 
 
 #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.
 
 /*
  * Sets the status of the 'td' in the printed status map.
diff --git a/fio.c b/fio.c
index 5ea1a2c32fc3d44edda83d910c8d11f8015cc1c9..01aa1d67fd02168bdcf980a147234ca49cb417c3 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -1515,7 +1515,7 @@ static void run_threads(void)
        set_genesis_time();
 
        while (todo) {
        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;
 
                struct timeval this_start;
                int this_jobs = 0, left;
 
diff --git a/fio.h b/fio.h
index 16866ddff95737805abc5610be8e471bc805ca39..fc64e3adf22b3f626f662b260c292934c107548f 100644 (file)
--- 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 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)
 
 
 #define td_non_fatal_error(e)  ((e) == EIO || (e) == EILSEQ)
 
diff --git a/init.c b/init.c
index d5813c60b22d39615bffed9333556918a5bedb65..baf3130b34f171fd73605794ba7dd0d5f70cb4dd 100644 (file)
--- 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;
 #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;
 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',
        },
                .has_arg        = no_argument,
                .val            = 'w',
        },
+       {
+               .name           = (char *) "max-jobs",
+               .has_arg        = required_argument,
+               .val            = 'j',
+       },
        {
                .name           = NULL,
        },
        {
                .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--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 <jens.axboe@oracle.com>");
        printf("\n                   Jens Axboe <jaxboe@fusionio.com>\n");
 }
        printf("\nFio was written by Jens Axboe <jens.axboe@oracle.com>");
        printf("\n                   Jens Axboe <jaxboe@fusionio.com>\n");
 }
@@ -1247,6 +1253,14 @@ static int parse_cmd_line(int argc, char *argv[])
                case 'w':
                        warnings_fatal = 1;
                        break;
                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;
                default:
                        do_exit++;
                        exit_val = 1;
index 42e1fea98e0bf9e01112f4cf55c5c2d3fab057f8..7446a43d47e8c842a72b5b4e2e4469184ce4a974 100644 (file)
 
 #define OS_MAP_ANON            MAP_ANON
 
 
 #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. 
 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 1569e409dd964c027b676227d44820e717165d2d..4bbdd623a987c174122b2577b2899332605a0a0c 100644 (file)
--- 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
 
 #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)
 {
 #ifndef FIO_HAVE_BLKTRACE
 static inline int is_blktrace(const char *fname)
 {