From 0353050fe32065e1932a43a7c39a7c390ea71142 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 19 Mar 2012 21:45:12 +0100 Subject: [PATCH] cpu: move cpuload/cpuchunks options into private engine option space Signed-off-by: Jens Axboe --- HOWTO | 11 +++++----- cconv.c | 4 ---- engines/cpu.c | 53 +++++++++++++++++++++++++++++++++++++++++++----- fio.1 | 6 ++++++ init.c | 7 +------ options.c | 21 ------------------- thread_options.h | 12 ----------- 7 files changed, 60 insertions(+), 54 deletions(-) diff --git a/HOWTO b/HOWTO index e4614ea8..091484a0 100644 --- 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. -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. @@ -1286,6 +1280,11 @@ that defines them is selected. 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 diff --git a/cconv.c b/cconv.c index a9b404a6..14ee9c5b 100644 --- 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->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); @@ -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->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); diff --git a/engines/cpu.c b/engines/cpu.c index 8bc9fd5c..c798f188 100644 --- a/engines/cpu.c +++ b/engines/cpu.c @@ -7,32 +7,73 @@ */ #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) { - 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; + struct cpu_options *co = td->eo; - if (!o->cpuload) { + if (!co->cpuload) { 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; - 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; + + log_info("%s: ioengine=cpu, cpuload=%u, cpucycle=%u\n", td->o.name, + co->cpuload, co->cpucycle); + 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, + .options = options, + .option_struct_size = sizeof(struct cpu_options), }; static void fio_init fio_cpuio_register(void) diff --git a/fio.1 b/fio.1 index c4c90b42..938038e4 100644 --- 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 +.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. diff --git a/init.c b/init.c index 0f992803..7bddcea4 100644 --- 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 (!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]); diff --git a/options.c b/options.c index 22cc5116..819c06d7 100644 --- 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, }, - { - .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", diff --git a/thread_options.h b/thread_options.h index 51ac0908..61f4f576 100644 --- a/thread_options.h +++ b/thread_options.h @@ -187,12 +187,6 @@ struct thread_options { char *ioscheduler; - /* - * CPU "io" cycle burner - */ - unsigned int cpuload; - unsigned int cpucycle; - /* * I/O Error handling */ @@ -376,12 +370,6 @@ struct thread_options_pack { uint8_t ioscheduler[FIO_TOP_STR_MAX]; - /* - * CPU "io" cycle burner - */ - uint32_t cpuload; - uint32_t cpucycle; - /* * I/O Error handling */ -- 2.25.1