summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@suse.de>2005-12-05 19:52:56 +0100
committerJens Axboe <axboe@suse.de>2005-12-05 19:52:56 +0100
commita984b9e542f2c54358fabaee996b0235019f6e56 (patch)
tree6cf893417336dfd34ed54003fdfd380abdce27d8
parent4263983c39ec2cffde0d4b9beb3df78737ed0a45 (diff)
[PATCH] fio: more portability fixes
-rw-r--r--fio-ini.c4
-rw-r--r--fio.c4
-rw-r--r--fio.h2
-rw-r--r--os-linux.h14
-rw-r--r--os.h12
5 files changed, 29 insertions, 7 deletions
diff --git a/fio-ini.c b/fio-ini.c
index 36ca1ad..ecb9aa7 100644
--- a/fio-ini.c
+++ b/fio-ini.c
@@ -613,6 +613,10 @@ int parse_jobs_ini(char *file)
continue;
}
if (!check_int(p, "cpumask", &cpu)) {
+#ifndef FIO_HAVE_CPU_AFFINITY
+ fprintf(stderr, "cpu affinity not available\n");
+ return 1;
+#endif
fill_cpu_mask(td->cpumask, cpu);
fgetpos(f, &off);
continue;
diff --git a/fio.c b/fio.c
index d7eaa31..4e32dce 100644
--- a/fio.c
+++ b/fio.c
@@ -1175,7 +1175,7 @@ static int init_io_u(struct thread_data *td)
return 1;
}
} else if (td->mem_type == MEM_MMAP) {
- td->orig_buffer = mmap(NULL, td->orig_buffer_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+ td->orig_buffer = mmap(NULL, td->orig_buffer_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | OS_MAP_ANON, 0, 0);
if (td->orig_buffer == MAP_FAILED) {
td_verror(td, errno);
perror("mmap");
@@ -1731,7 +1731,7 @@ static void *thread_main(void *data)
if (init_io_u(td))
goto err;
- if (sched_setaffinity(td->pid, sizeof(td->cpumask), &td->cpumask) == -1) {
+ if (fio_setaffinity(td) == -1) {
td_verror(td, errno);
goto err;
}
diff --git a/fio.h b/fio.h
index 930ca2e..c8bc18e 100644
--- a/fio.h
+++ b/fio.h
@@ -132,7 +132,7 @@ struct thread_data {
unsigned int numjobs;
unsigned int use_thread;
unsigned int use_mmap;
- cpu_set_t cpumask;
+ os_cpu_mask_t cpumask;
struct drand48_data bsrange_state;
struct drand48_data verify_state;
diff --git a/os-linux.h b/os-linux.h
index c7c0aa1..06c32a5 100644
--- a/os-linux.h
+++ b/os-linux.h
@@ -1,16 +1,22 @@
#ifndef FIO_OS_LINUX_H
#define FIO_OS_LINUX_H
-#include <libaio.h>
-#include <aio.h>
-
#define FIO_HAVE_LIBAIO
#define FIO_HAVE_POSIXAIO
#define FIO_HAVE_FADVISE
+#define FIO_HAVE_CPU_AFFINITY
+
+#define OS_MAP_ANON (MAP_ANONYMOUS)
+
+typedef cpu_set_t os_cpu_mask_t;
/*
* we want fadvise64 really, but it's so tangled... later
*/
-#define fadvise(fd, off, len, advice) posix_fadvise((fd), (off_t)(off), (len), (advice))
+#define fadvise(fd, off, len, advice) \
+ posix_fadvise((fd), (off_t)(off), (len), (advice))
+
+#define fio_setaffinity(td) \
+ sched_setaffinity((td)->pid, sizeof((td)->cpumask), &(td)->cpumask)
#endif
diff --git a/os.h b/os.h
index 069f9c8..14065cd 100644
--- a/os.h
+++ b/os.h
@@ -7,6 +7,14 @@
#error "unsupported os"
#endif
+#ifdef FIO_HAVE_LIBAIO
+#include <libaio.h>
+#endif
+
+#ifdef FIO_HAVE_POSIXAIO
+#include <aio.h>
+#endif
+
#ifndef FIO_HAVE_FADVISE
static int fadvise(int fd, loff_t offset, size_t len, int advice)
{
@@ -18,6 +26,10 @@ static int fadvise(int fd, loff_t offset, size_t len, int advice)
#define POSIX_FADV_RANDOM (0)
#endif /* FIO_HAVE_FADVISE */
+#ifndef FIO_HAVE_CPU_AFFINITY
+#define fio_setaffinity(td) do { } while (0)
+#endif
+
struct thread_data;
extern int fio_libaio_init(struct thread_data *);
extern void fio_libaio_cleanup(struct thread_data *);