From 375b2695693f56987e23deef3ded8e5b06ef6797 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 22 May 2007 09:13:02 +0200 Subject: [PATCH] Fix cpumask setting/getting on older kernels Don't call into the affinity functions, unless the user has specified a mask. Signed-off-by: Jens Axboe --- fio.c | 2 +- fio.h | 1 + init.c | 5 +---- options.c | 1 + 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/fio.c b/fio.c index 0c297f7e..6483e64c 100644 --- a/fio.c +++ b/fio.c @@ -792,7 +792,7 @@ static void *thread_main(void *data) if (init_io_u(td)) goto err; - if (fio_setaffinity(td) == -1) { + if (td->o.cpumask_set && fio_setaffinity(td) == -1) { td_verror(td, errno, "cpu_set_affinity"); goto err; } diff --git a/fio.h b/fio.h index 2717f5dd..9a43c6f6 100644 --- a/fio.h +++ b/fio.h @@ -406,6 +406,7 @@ struct thread_options { unsigned int new_group; unsigned int numjobs; os_cpu_mask_t cpumask; + unsigned int cpumask_set; unsigned int iolog; unsigned int rwmixcycle; unsigned int rwmix[2]; diff --git a/init.c b/init.c index 0df30a2e..355de88f 100644 --- a/init.c +++ b/init.c @@ -655,10 +655,7 @@ static int fill_def_thread(void) { memset(&def_thread, 0, sizeof(def_thread)); - if (fio_getaffinity(getpid(), &def_thread.o.cpumask) == -1) { - perror("sched_getaffinity"); - return 1; - } + fio_getaffinity(getpid(), &def_thread.o.cpumask); /* * fill default options diff --git a/options.c b/options.c index 54ceaeed..e67742dd 100644 --- a/options.c +++ b/options.c @@ -117,6 +117,7 @@ static int str_cpumask_cb(void *data, unsigned int *val) struct thread_data *td = data; fill_cpu_mask(td->o.cpumask, *val); + td->o.cpumask_set = 1; return 0; } -- 2.25.1