From: Phillip Susi <psusi@ubuntu.com>
To: linux-mm@kvack.org
Subject: [PATCH 2/2] mm: fadvise: implement POSIX_FADV_NOREUSE
Date: Sat, 23 Feb 2013 17:58:01 -0500 [thread overview]
Message-ID: <1361660281-22165-3-git-send-email-psusi@ubuntu.com> (raw)
In-Reply-To: <1361660281-22165-1-git-send-email-psusi@ubuntu.com>
In-Reply-To: <5127E8B7.9080202@ubuntu.com>
This hint was a nop, now it causes the read/write path to deactivate pages
after reading/writing them, so they will be reclaimed sooner.
---
include/linux/fs.h | 3 +++
mm/fadvise.c | 1 +
mm/filemap.c | 11 ++++++++---
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2abd193..de26ee3 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -121,6 +121,9 @@ typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
/* File is opened with O_PATH; almost nothing can be done with it */
#define FMODE_PATH ((__force fmode_t)0x4000)
+/* POSIX_FADV_NOREUSE has been set */
+#define FMODE_NOREUSE ((__force fmode_t)0x8000)
+
/* File was opened by fanotify and shouldn't generate fanotify events */
#define FMODE_NONOTIFY ((__force fmode_t)0x1000000)
diff --git a/mm/fadvise.c b/mm/fadvise.c
index fbd58b0..b42bf5b 100644
--- a/mm/fadvise.c
+++ b/mm/fadvise.c
@@ -110,6 +110,7 @@ SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice)
nrpages);
break;
case POSIX_FADV_NOREUSE:
+ f.file->f_mode |= FMODE_NOREUSE;
break;
case POSIX_FADV_DONTNEED:
/* First and last FULL page! */
diff --git a/mm/filemap.c b/mm/filemap.c
index bcdcdbf..cba2f41 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1215,8 +1215,11 @@ page_ok:
* When a sequential read accesses a page several times,
* only mark it as accessed the first time.
*/
- if (prev_index != index || offset != prev_offset)
- mark_page_accessed(page);
+ if (prev_index != index || offset != prev_offset) {
+ if (filp->f_mode & FMODE_NOREUSE)
+ deactivate_page(page);
+ else mark_page_accessed(page);
+ }
prev_index = index;
/*
@@ -2378,7 +2381,9 @@ again:
pagefault_enable();
flush_dcache_page(page);
- mark_page_accessed(page);
+ if (file->f_mode & FMODE_NOREUSE)
+ deactivate_page(page);
+ else mark_page_accessed(page);
status = a_ops->write_end(file, mapping, pos, bytes, copied,
page, fsdata);
if (unlikely(status < 0))
--
1.8.1.2
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2013-02-23 22:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-22 19:57 POSIX_FADV_DONTNEED implemented wrong Phillip Susi
2013-02-22 20:29 ` Johannes Weiner
2013-02-22 21:52 ` Phillip Susi
2013-02-23 22:57 ` [PATCH 0/2] FADV_DONTNEED and FADV_NOREUSE Phillip Susi
2013-02-23 22:58 ` [PATCH 1/2] mm: fadvise: fix POSIX_FADV_DONTNEED Phillip Susi
2013-02-24 1:46 ` Dave Hansen
2013-02-24 3:37 ` Phillip Susi
2013-02-24 18:24 ` Dave Hansen
2013-02-24 20:40 ` Phillip Susi
2013-02-24 21:25 ` Dave Hansen
2013-02-24 22:38 ` Phillip Susi
2013-02-25 17:50 ` Dave Hansen
2013-02-24 3:58 ` Zheng Liu
2013-02-24 4:04 ` Phillip Susi
2013-02-26 4:21 ` Minchan Kim
2013-02-26 14:06 ` Andrea Righi
2013-02-26 15:39 ` Phillip Susi
2013-02-23 22:58 ` Phillip Susi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1361660281-22165-3-git-send-email-psusi@ubuntu.com \
--to=psusi@ubuntu.com \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox