(Take 2): tmem: Implement precache on top of tmem layer
Subsystems (4)
RFC PATCH 2/4 (Take 2): tmem: Implement precache on top of tmem layer
Tmem [PATCH 2/4] (Take 2): Implement precache on top of tmem layer
Hooks added to existing page cache, VFS, and FS (ext3 only for now) routines to:
1) create a tmem pool when filesystem is mounted and record its id
2) "put" clean pages that are being evicted
3) attempt to "get" pages prior to reading from a mounted FS and fallback to reading from the FS if "get" fails
4) "flush" as necessary to ensure coherency btwn page cache & precache
5) destroy the tmem pool when the FS is unmounted
Hooks for page cache and VFS placed by Chris Mason
fs/buffer.c | 5 fs/ext3/super.c | 2 fs/mpage.c | 8 + fs/super.c | 5 include/linux/fs.h | 7 + include/linux/precache.h | 50 +++++++ mm/Kconfig | 8 + mm/Makefile | 1 mm/filemap.c | 11 + mm/precache.c | 134 +++++++++++++++++++++ mm/truncate.c | 10 + 11 files changed, 241 insertions(+)
fs/super.c +5 -0
@@ -39,6 +39,7 @@#include <linux/mutex.h> #include <linux/file.h> #include <linux/async.h> +#include <linux/precache.h> #include <asm/uaccess.h> #include "internal.h"
@@ -110,6 +111,9 @@ static struct super_block *alloc_super(s s->s_qcop = sb_quotactl_ops; s->s_op = &default_op; s->s_time_gran =1000000000 ; +#ifdef CONFIG_PRECACHE + s->precache_poolid =-1 ; +#endif } out:return s;
@@ -200,6 +204,7 @@ void deactivate_super(struct super_blockvfs_dq_off (s,0 );down_write (&s->s_umount); fs->kill_sb (s); +precache_flush_filesystem (s);put_filesystem (fs);put_super (s); }
fs/ext3/super.c +2 -0
@@ -37,6 +37,7 @@#include <linux/quotaops.h> #include <linux/seq_file.h> #include <linux/log2.h> +#include <linux/precache.h> #include <asm/uaccess.h>
@@ -1306,6 +1307,7 @@ static int ext3_setup_super(struct super }else {printk ("internal journal\n" ); } +precache_init (sb);return res; }
include/linux/fs.h +7 -0
@@ -1377,6 +1377,13 @@ struct super_block {* storage for asynchronous operations */ struct list_head s_async_list; + +#ifdef CONFIG_PRECACHE +/* +* saved pool identifier for precache (-1 means none) +*/ +u32 precache_poolid; +#endif };extern struct timespec current_fs_time (struct super_block *sb);
fs/buffer.c +5 -0
@@ -41,6 +41,7 @@#include <linux/bitops.h> #include <linux/mpage.h> #include <linux/bit_spinlock.h> +#include <linux/precache.h> static int fsync_buffers_list (spinlock_t *lock,struct list_head *list);
@@ -271,6 +272,10 @@ void invalidate_bdev(struct block_deviceinvalidate_bh_lrus ();invalidate_mapping_pages (mapping,0 ,-1 ); +/* 99% of the time, we don't need to flush the precache on the bdev. +* But, for the strange corners, lets be cautious +*/ +precache_flush_inode (mapping); }/*
fs/mpage.c +8 -0
@@ -26,6 +26,7 @@#include <linux/writeback.h> #include <linux/backing-dev.h> #include <linux/pagevec.h> +#include <linux/precache.h> /* * I/O completion handler for multipage BIOs.
@@ -285,6 +286,13 @@ do_mpage_readpage(struct bio *bio, strucSetPageMappedToDisk (page); } +if (fully_mapped && + blocks_per_page ==1 && !PageUptodate (page) && +precache_get (page->mapping, page->index, page) ==1 ) { +SetPageUptodate (page); + goto confused; + } +/* * This page will go to BIO. Do we need to send this BIO off first? */
mm/truncate.c +10 -0
@@ -18,6 +18,7 @@#include <linux/task_io_accounting_ops.h> #include <linux/buffer_head.h> /* grr. try_to_release_page, do_invalidatepage */ +#include <linux/precache.h> #include "internal.h"
@@ -50,6 +51,7 @@ void do_invalidatepage(struct page *pagestatic inline void truncate_partial_page (struct page *page,unsigned partial) {zero_user_segment (page, partial,PAGE_CACHE_SIZE ); +precache_flush (page->mapping, page->index);if (page_has_private (page))do_invalidatepage (page, partial); }
@@ -107,6 +109,10 @@ truncate_complete_page(struct address_spclear_page_mlock (page);remove_from_page_cache (page);ClearPageMappedToDisk (page); +/* this must be after the remove_from_page_cache which +* calls precache_put +*/ +precache_flush (mapping, page->index);page_cache_release (page);/* pagecache ref */ }
@@ -168,6 +174,7 @@ void truncate_inode_pages_range(struct apgoff_t next;int i; +precache_flush_inode (mapping);if (mapping->nrpages ==0 )return ;
@@ -251,6 +258,7 @@ void truncate_inode_pages_range(struct a }pagevec_release (&pvec); } +precache_flush_inode (mapping); }EXPORT_SYMBOL (truncate_inode_pages_range);
@@ -398,6 +406,7 @@ int invalidate_inode_pages2_range(structint did_range_unmap =0 ;int wrapped =0 ; +precache_flush_inode (mapping);pagevec_init (&pvec,0 ); next = start; while (next <= end && !wrapped &&
@@ -454,6 +463,7 @@ int invalidate_inode_pages2_range(structpagevec_release (&pvec);cond_resched (); } +precache_flush_inode (mapping);return ret; }EXPORT_SYMBOL_GPL (invalidate_inode_pages2_range);
mm/filemap.c +11 -0
@@ -34,6 +34,7 @@#include <linux/hardirq.h> /* for BUG_ON(!in_atomic()) only */ #include <linux/memcontrol.h> #include <linux/mm_inline.h> /* for page_is_file_cache() */ +#include <linux/precache.h> #include "internal.h" /*
@@ -116,6 +117,16 @@ void __remove_from_page_cache(struct pag {struct address_space *mapping = page->mapping; +/* +* if we're uptodate, flush out into the precache, otherwise +* invalidate any existing precache entries. We can't leave +* stale data around in the precache once our page is gone +*/ +if (PageUptodate (page)) +precache_put (page->mapping, page->index, page); +else +precache_flush (page->mapping, page->index); +radix_tree_delete (&mapping->page_tree, page->index); page->mapping =NULL ; mapping->nrpages--;
include/linux/precache.h +50 -0
50 lines not on this page · raw message
mm/precache.c +134 -0
134 lines not on this page · raw message
mm/Kconfig +8 -0
@@ -263,3 +263,11 @@ config TMEM In a virtualized environment, allows unused and underutilized system physical memory to be made accessible through a narrow well-defined page-copy-based API. + +config PRECACHE + bool "Cache clean pages in transcendent memory" + depends on TMEM + help + Allows the transcendent memory pool to be used to store clean + page-cache pages which, under some circumstances, will greatly + reduce paging and thus improve performance.
mm/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_PROC_PAGE_MONITOR) += pagew obj-$(CONFIG_BOUNCE) += bounce.o obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o thrash.o obj-$(CONFIG_TMEM) += tmem.o +obj-$(CONFIG_PRECACHE) += precache.o obj-$(CONFIG_HAS_DMA) += dmapool.o obj-$(CONFIG_HUGETLBFS) += hugetlb.o obj-$(CONFIG_NUMA) += mempolicy.o
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>