lkml.org 
[lkml]   [2012]   [Feb]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v5 2/3] mm: filemap: introduce mark_page_usedonce
Date
Introduce a helper function to drop a page from the page cache if it is
evictable, inactive and unreferenced.

This can be used to drop used-once pages from the file cache with
POSIX_FADV_NOREUSE.

Signed-off-by: Andrea Righi <andrea@betterlinux.com>
---
include/linux/swap.h | 1 +
mm/swap.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 3e60228..2e5d1b8 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -222,6 +222,7 @@ extern void lru_add_page_tail(struct zone* zone,
struct page *page, struct page *page_tail);
extern void activate_page(struct page *);
extern void mark_page_accessed(struct page *);
+extern void mark_page_usedonce(struct page *page);
extern void lru_add_drain(void);
extern int lru_add_drain_all(void);
extern void rotate_reclaimable_page(struct page *page);
diff --git a/mm/swap.c b/mm/swap.c
index fff1ff7..2c19c92 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -352,6 +352,30 @@ void activate_page(struct page *page)
}
#endif

+/**
+ * mark_page_usedonce - handle used-once pages
+ * @page: the page set as used-once
+ *
+ * Drop a page from the page cache if it is evictable, inactive and
+ * unreferenced.
+ */
+void mark_page_usedonce(struct page *page)
+{
+ int ret;
+
+ if (!PageLRU(page))
+ return;
+ if (PageActive(page) || PageUnevictable(page) || PageReferenced(page))
+ return;
+ if (lock_page_killable(page))
+ return;
+ ret = invalidate_inode_page(page);
+ unlock_page(page);
+ if (!ret)
+ deactivate_page(page);
+}
+EXPORT_SYMBOL(mark_page_usedonce);
+
/*
* Mark a page as having seen activity.
*
--
1.7.5.4


\
 
 \ /
  Last update: 2012-02-12 01:25    [from the cache]
©2003-2011 Jasper Spaans