cpu: move cpuload/cpuchunks options into private engine option space
authorJens Axboe <axboe@kernel.dk>
Mon, 19 Mar 2012 20:45:12 +0000 (21:45 +0100)
committerJens Axboe <axboe@kernel.dk>
Mon, 19 Mar 2012 20:45:12 +0000 (21:45 +0100)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
HOWTO
cconv.c
engines/cpu.c
fio.1
init.c
options.c
thread_options.h

diff --git a/HOWTO b/HOWTO
index e4614ea8675a0c8b2f958ad8c2d6b04e12181939..091484a0b4ba9466baba0708177edb37dde1b313 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -1150,12 +1150,6 @@ exec_postrun=str After the job completes, issue the command specified
 ioscheduler=str        Attempt to switch the device hosting the file to the specified
                io scheduler before running.
 
 ioscheduler=str        Attempt to switch the device hosting the file to the specified
                io scheduler before running.
 
-cpuload=int    If the job is a CPU cycle eater, attempt to use the specified
-               percentage of CPU cycles.
-
-cpuchunks=int  If the job is a CPU cycle eater, split the load into
-               cycles of the given time. In microseconds.
-
 disk_util=bool Generate disk utilization statistics, if the platform
                supports it. Defaults to on.
 
 disk_util=bool Generate disk utilization statistics, if the platform
                supports it. Defaults to on.
 
@@ -1286,6 +1280,11 @@ that defines them is selected.
                enabled when polling for a minimum of 0 events (eg when
                iodepth_batch_complete=0).
 
                enabled when polling for a minimum of 0 events (eg when
                iodepth_batch_complete=0).
 
+[cpu] cpuload=int Attempt to use the specified percentage of CPU cycles.
+
+[cpu] cpuchunks=int Split the load into cycles of the given time. In
+               microseconds.
+
 [netsplice] hostname=str
 [net] hostname=str The host name or IP address to use for TCP or UDP based IO.
                If the job is a TCP listener or UDP reader, the hostname is not
 [netsplice] hostname=str
 [net] hostname=str The host name or IP address to use for TCP or UDP based IO.
                If the job is a TCP listener or UDP reader, the hostname is not
diff --git a/cconv.c b/cconv.c
index a9b404a6e0e62857f89dc6b91a6885cb8b5fba5d..14ee9c5b2738a2a1fb3d0d49e05ee3f61dde4d3d 100644 (file)
--- a/cconv.c
+++ b/cconv.c
@@ -173,8 +173,6 @@ void convert_thread_options_to_cpu(struct thread_options *o,
        o->trim_zero = le32_to_cpu(top->trim_zero);
        o->clat_percentiles = le32_to_cpu(top->clat_percentiles);
        o->overwrite_plist = le32_to_cpu(top->overwrite_plist);
        o->trim_zero = le32_to_cpu(top->trim_zero);
        o->clat_percentiles = le32_to_cpu(top->clat_percentiles);
        o->overwrite_plist = le32_to_cpu(top->overwrite_plist);
-       o->cpuload = le32_to_cpu(top->cpuload);
-       o->cpucycle = le32_to_cpu(top->cpucycle);
        o->continue_on_error = le32_to_cpu(top->continue_on_error);
        o->cgroup_weight = le32_to_cpu(top->cgroup_weight);
        o->cgroup_nodelete = le32_to_cpu(top->cgroup_nodelete);
        o->continue_on_error = le32_to_cpu(top->continue_on_error);
        o->cgroup_weight = le32_to_cpu(top->cgroup_weight);
        o->cgroup_nodelete = le32_to_cpu(top->cgroup_nodelete);
@@ -312,8 +310,6 @@ void convert_thread_options_to_net(struct thread_options_pack *top,
        top->trim_zero = cpu_to_le32(o->trim_zero);
        top->clat_percentiles = cpu_to_le32(o->clat_percentiles);
        top->overwrite_plist = cpu_to_le32(o->overwrite_plist);
        top->trim_zero = cpu_to_le32(o->trim_zero);
        top->clat_percentiles = cpu_to_le32(o->clat_percentiles);
        top->overwrite_plist = cpu_to_le32(o->overwrite_plist);
-       top->cpuload = cpu_to_le32(o->cpuload);
-       top->cpucycle = cpu_to_le32(o->cpucycle);
        top->continue_on_error = cpu_to_le32(o->continue_on_error);
        top->cgroup_weight = cpu_to_le32(o->cgroup_weight);
        top->cgroup_nodelete = cpu_to_le32(o->cgroup_nodelete);
        top->continue_on_error = cpu_to_le32(o->continue_on_error);
        top->cgroup_weight = cpu_to_le32(o->cgroup_weight);
        top->cgroup_nodelete = cpu_to_le32(o->cgroup_nodelete);
index 8bc9fd5c3c8c8919d4618bf6f149fb5b142093a6..c798f1884e8dff8df9b079d87d61c8c4259ae10c 100644 (file)
@@ -7,32 +7,73 @@
  */
 #include "../fio.h"
 
  */
 #include "../fio.h"
 
+struct cpu_options {
+       struct thread_data *td;
+       unsigned int cpuload;
+       unsigned int cpucycle;
+};
+
+static struct fio_option options[] = {
+       {
+               .name   = "cpuload",
+               .lname  = "CPU load",
+               .type   = FIO_OPT_INT,
+               .off1   = offsetof(struct cpu_options, cpuload),
+               .help   = "Use this percentage of CPU",
+               .category = FIO_OPT_C_GENERAL,
+               .group  = FIO_OPT_G_INVALID,
+       },
+       {
+               .name   = "cpuchunks",
+               .lname  = "CPU chunk",
+               .type   = FIO_OPT_INT,
+               .off1   = offsetof(struct cpu_options, cpucycle),
+               .help   = "Length of the CPU burn cycles (usecs)",
+               .def    = "50000",
+               .parent = "cpuload",
+               .hide   = 1,
+               .category = FIO_OPT_C_GENERAL,
+               .group  = FIO_OPT_G_INVALID,
+       },
+       {
+               .name   = NULL,
+       },
+};
+
+
 static int fio_cpuio_queue(struct thread_data *td, struct io_u fio_unused *io_u)
 {
 static int fio_cpuio_queue(struct thread_data *td, struct io_u fio_unused *io_u)
 {
-       usec_spin(td->o.cpucycle);
+       struct cpu_options *co = td->eo;
+
+       usec_spin(co->cpucycle);
        return FIO_Q_COMPLETED;
 }
 
 static int fio_cpuio_init(struct thread_data *td)
 {
        struct thread_options *o = &td->o;
        return FIO_Q_COMPLETED;
 }
 
 static int fio_cpuio_init(struct thread_data *td)
 {
        struct thread_options *o = &td->o;
+       struct cpu_options *co = td->eo;
 
 
-       if (!o->cpuload) {
+       if (!co->cpuload) {
                td_vmsg(td, EINVAL, "cpu thread needs rate (cpuload=)","cpuio");
                return 1;
        }
 
                td_vmsg(td, EINVAL, "cpu thread needs rate (cpuload=)","cpuio");
                return 1;
        }
 
-       if (o->cpuload > 100)
-               o->cpuload = 100;
+       if (co->cpuload > 100)
+               co->cpuload = 100;
 
        /*
         * set thinktime_sleep and thinktime_spin appropriately
         */
        o->thinktime_blocks = 1;
        o->thinktime_spin = 0;
 
        /*
         * set thinktime_sleep and thinktime_spin appropriately
         */
        o->thinktime_blocks = 1;
        o->thinktime_spin = 0;
-       o->thinktime = (o->cpucycle * (100 - o->cpuload)) / o->cpuload;
+       o->thinktime = (co->cpucycle * (100 - co->cpuload)) / co->cpuload;
 
        o->nr_files = o->open_files = 1;
 
        o->nr_files = o->open_files = 1;
+
+       log_info("%s: ioengine=cpu, cpuload=%u, cpucycle=%u\n", td->o.name,
+                                               co->cpuload, co->cpucycle);
+
        return 0;
 }
 
        return 0;
 }
 
@@ -49,6 +90,8 @@ static struct ioengine_ops ioengine = {
        .init           = fio_cpuio_init,
        .open_file      = fio_cpuio_open,
        .flags          = FIO_SYNCIO | FIO_DISKLESSIO | FIO_NOIO,
        .init           = fio_cpuio_init,
        .open_file      = fio_cpuio_open,
        .flags          = FIO_SYNCIO | FIO_DISKLESSIO | FIO_NOIO,
+       .options                = options,
+       .option_struct_size     = sizeof(struct cpu_options),
 };
 
 static void fio_init fio_cpuio_register(void)
 };
 
 static void fio_init fio_cpuio_register(void)
diff --git a/fio.1 b/fio.1
index c4c90b42e0c2a6d4bdfb23319e6dce42947f5602..938038e4f0a0a61a98a7423ce5c6f175a302eb9f 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -1015,6 +1015,12 @@ Some parameters are only valid when a specific ioengine is in use. These are
 used identically to normal parameters, with the caveat that when used on the
 command line, the must come after the ioengine that defines them is selected.
 .TP
 used identically to normal parameters, with the caveat that when used on the
 command line, the must come after the ioengine that defines them is selected.
 .TP
+.BI (cpu)cpuload \fR=\fPint
+Attempt to use the specified percentage of CPU cycles.
+.TP
+.BI (cpu)cpuchunks \fR=\fPint
+Split the load into cycles of the given time. In microseconds.
+.TP
 .BI (libaio)userspace_reap
 Normally, with the libaio engine in use, fio will use
 the io_getevents system call to reap newly returned events.
 .BI (libaio)userspace_reap
 Normally, with the libaio engine in use, fio will use
 the io_getevents system call to reap newly returned events.
diff --git a/init.c b/init.c
index 0f992803729c92aac6844f89b6c220f5b3380f37..7bddcea4b88bcd217e343267a45c4e0f1c7a7a26 100644 (file)
--- a/init.c
+++ b/init.c
@@ -865,12 +865,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
                        if (is_backend && !recursed)
                                fio_server_send_add_job(td);
 
                        if (is_backend && !recursed)
                                fio_server_send_add_job(td);
 
-                       if (!strcmp(td->io_ops->name, "cpuio")) {
-                               log_info("%s: ioengine=cpu, cpuload=%u,"
-                                        " cpucycle=%u\n", td->o.name,
-                                                       td->o.cpuload,
-                                                       td->o.cpucycle);
-                       } else {
+                       if (!(td->io_ops->flags & FIO_NOIO)) {
                                char *c1, *c2, *c3, *c4;
 
                                c1 = fio_uint_to_kmg(td->o.min_bs[DDIR_READ]);
                                char *c1, *c2, *c3, *c4;
 
                                c1 = fio_uint_to_kmg(td->o.min_bs[DDIR_READ]);
index 22cc511681503982a0630ee1cdab085fcc4045cf..819c06d77b31e5a7cbfcb147dcfae0e91a4e22e6 100644 (file)
--- a/options.c
+++ b/options.c
@@ -2393,27 +2393,6 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .category = FIO_OPT_C_FILE,
                .group  = FIO_OPT_G_INVALID,
        },
                .category = FIO_OPT_C_FILE,
                .group  = FIO_OPT_G_INVALID,
        },
-       {
-               .name   = "cpuload",
-               .lname  = "CPU load",
-               .type   = FIO_OPT_INT,
-               .off1   = td_var_offset(cpuload),
-               .help   = "Use this percentage of CPU",
-               .category = FIO_OPT_C_GENERAL,
-               .group  = FIO_OPT_G_INVALID,
-       },
-       {
-               .name   = "cpuchunks",
-               .lname  = "CPU chunk",
-               .type   = FIO_OPT_INT,
-               .off1   = td_var_offset(cpucycle),
-               .help   = "Length of the CPU burn cycles (usecs)",
-               .def    = "50000",
-               .parent = "cpuload",
-               .hide   = 1,
-               .category = FIO_OPT_C_GENERAL,
-               .group  = FIO_OPT_G_INVALID,
-       },
 #ifdef FIO_HAVE_CPU_AFFINITY
        {
                .name   = "cpumask",
 #ifdef FIO_HAVE_CPU_AFFINITY
        {
                .name   = "cpumask",
index 51ac0908a2c3c1dccaebd549cd74c593b3fe2aa6..61f4f5766e0904181689c09b1d15a4b664b25611 100644 (file)
@@ -187,12 +187,6 @@ struct thread_options {
 
        char *ioscheduler;
 
 
        char *ioscheduler;
 
-       /*
-        * CPU "io" cycle burner
-        */
-       unsigned int cpuload;
-       unsigned int cpucycle;
-
        /*
         * I/O Error handling
         */
        /*
         * I/O Error handling
         */
@@ -376,12 +370,6 @@ struct thread_options_pack {
 
        uint8_t ioscheduler[FIO_TOP_STR_MAX];
 
 
        uint8_t ioscheduler[FIO_TOP_STR_MAX];
 
-       /*
-        * CPU "io" cycle burner
-        */
-       uint32_t cpuload;
-       uint32_t cpucycle;
-
        /*
         * I/O Error handling
         */
        /*
         * I/O Error handling
         */