From 1f809d151ddc4a4c348c2e4f6007db510e3e08a2 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 25 Oct 2007 18:34:02 +0200 Subject: [PATCH] Fixes for CPU burn engine Signed-off-by: Jens Axboe --- engines/cpu.c | 2 +- filesetup.c | 3 ++- fio.c | 8 +++++--- fio.h | 1 + init.c | 1 + 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/engines/cpu.c b/engines/cpu.c index 14ad9717..c8eb6b30 100644 --- a/engines/cpu.c +++ b/engines/cpu.c @@ -48,7 +48,7 @@ static struct ioengine_ops ioengine = { .queue = fio_cpuio_queue, .init = fio_cpuio_init, .open_file = fio_cpuio_open, - .flags = FIO_SYNCIO | FIO_DISKLESSIO, + .flags = FIO_SYNCIO | FIO_DISKLESSIO | FIO_NOIO, }; static void fio_init fio_cpuio_register(void) diff --git a/filesetup.c b/filesetup.c index fca90be7..5134fdbb 100644 --- a/filesetup.c +++ b/filesetup.c @@ -373,7 +373,8 @@ int setup_files(struct thread_data *td) /* * device/file sizes are zero and no size given, punt */ - if ((!total_size || total_size == -1ULL) && !td->o.size) { + if ((!total_size || total_size == -1ULL) && !td->o.size && + !(td->io_ops->flags & FIO_NOIO)) { log_err("%s: you need to specify size=\n", td->o.name); td_verror(td, EINVAL, "total_file_size"); return 1; diff --git a/fio.c b/fio.c index 02ed91db..0ec4f5a0 100644 --- a/fio.c +++ b/fio.c @@ -987,12 +987,12 @@ static int fork_main(int shmid, int offset) static void reap_threads(int *nr_running, int *t_rate, int *m_rate) { struct thread_data *td; - int i, cputhreads, pending, status, ret; + int i, cputhreads, realthreads, pending, status, ret; /* * reap exited threads (TD_EXITED -> TD_REAPED) */ - pending = cputhreads = 0; + realthreads = pending = cputhreads = 0; for_each_td(td, i) { int flags = 0; @@ -1002,6 +1002,8 @@ static void reap_threads(int *nr_running, int *t_rate, int *m_rate) */ if (td->io_ops && !strcmp(td->io_ops->name, "cpuio")) cputhreads++; + else + realthreads++; if (!td->pid || td->runstate == TD_REAPED) continue; @@ -1068,7 +1070,7 @@ reaped: exit_value++; } - if (*nr_running == cputhreads && !pending) + if (*nr_running == cputhreads && !pending && realthreads) terminate_threads(TERMINATE_ALL); } diff --git a/fio.h b/fio.h index 0d57b608..208f7428 100644 --- a/fio.h +++ b/fio.h @@ -278,6 +278,7 @@ enum fio_ioengine_flags { FIO_NOEXTEND = 1 << 3, /* engine can't extend file */ FIO_NODISKUTIL = 1 << 4, /* diskutil can't handle filename */ FIO_UNIDIR = 1 << 5, /* engine is uni-directional */ + FIO_NOIO = 1 << 6, /* thread does only pseudo IO */ }; enum fio_file_flags { diff --git a/init.c b/init.c index dc5fed94..201a405b 100644 --- a/init.c +++ b/init.c @@ -746,6 +746,7 @@ static int setup_thread_area(void) return 1; } + memset(threads, 0, max_jobs * sizeof(struct thread_data)); atexit(free_shm); return 0; } -- 2.25.1