summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2009-08-04 23:17:02 +0200
committerJens Axboe <jens.axboe@oracle.com>2009-08-04 23:17:02 +0200
commita1c58075279454a91ec43366846b93e8dcf9753c (patch)
treeb0377d096ad9ab0da2d252b04af44ad982794ee1
parent56075b96f307f8276f9d032ac8404622b94a456c (diff)
downloadfio-a1c58075279454a91ec43366846b93e8dcf9753c.tar.gz
fio-a1c58075279454a91ec43366846b93e8dcf9753c.tar.bz2
Add strong madvise() hint for cache pruning
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r--filesetup.c7
-rw-r--r--os/os-freebsd.h4
-rw-r--r--os/os-linux.h4
-rw-r--r--os/os-solaris.h4
4 files changed, 17 insertions, 2 deletions
diff --git a/filesetup.c b/filesetup.c
index d7c83a79..f8f81d2b 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -303,9 +303,12 @@ static int __file_invalidate_cache(struct thread_data *td, struct fio_file *f,
/*
* FIXME: add blockdev flushing too
*/
- if (f->mmap_ptr)
+ if (f->mmap_ptr) {
ret = madvise(f->mmap_ptr, f->mmap_sz, MADV_DONTNEED);
- else if (f->filetype == FIO_TYPE_FILE) {
+#ifdef FIO_MADV_FREE
+ (void) madvise(f->mmap_ptr, f->mmap_sz, FIO_MADV_FREE);
+#endif
+ } else if (f->filetype == FIO_TYPE_FILE) {
ret = fadvise(f->fd, off, len, POSIX_FADV_DONTNEED);
} else if (f->filetype == FIO_TYPE_BD) {
ret = blockdev_invalidate_cache(f->fd);
diff --git a/os/os-freebsd.h b/os/os-freebsd.h
index 88de7138..26bb8a09 100644
--- a/os/os-freebsd.h
+++ b/os/os-freebsd.h
@@ -51,4 +51,8 @@ static inline long os_random_long(os_random_state_t *rs)
return val;
}
+#ifdef MADV_FREE
+#define FIO_MADV_FREE MADV_FREE
+#endif
+
#endif
diff --git a/os/os-linux.h b/os/os-linux.h
index dd9c5aaf..e4c4c3fd 100644
--- a/os/os-linux.h
+++ b/os/os-linux.h
@@ -250,6 +250,10 @@ static inline int fio_lookup_raw(dev_t dev, int *majdev, int *mindev)
#define FIO_O_NOATIME 0
#endif
+#ifdef MADV_REMOVE
+#define FIO_MADV_FREE MADV_REMOVE
+#endif
+
#define CACHE_LINE_FILE \
"/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size"
diff --git a/os/os-solaris.h b/os/os-solaris.h
index 943d387d..5029d38f 100644
--- a/os/os-solaris.h
+++ b/os/os-solaris.h
@@ -108,4 +108,8 @@ static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
*/
#define FIO_MAX_CPUS 16384
+#ifdef MADV_FREE
+#define FIO_MADV_FREE MADV_FREE
+#endif
+
#endif