From: Jens Axboe Date: Tue, 22 May 2007 07:13:02 +0000 (+0200) Subject: Fix cpumask setting/getting on older kernels X-Git-Tag: fio-1.16.2~7 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=375b2695693f56987e23deef3ded8e5b06ef6797;ds=sidebyside 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 --- 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; }