mm: abort inode pruning if it has active pages
Subsystems (3)
RFC PATCH 1/1 mm: abort inode pruning if it has active pages
Inode cache pruning can throw out some usefull data from page cache. This patch aborts inode invalidation and keep inode alive if it still has active pages. It improves interaction between inode cache and page cache.
--- fs/inode.c | 4 ++-- include/linux/fs.h | 2 ++ mm/truncate.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-)
fs/inode.c +2 -2
@@ -663,8 +663,8 @@ void prune_icache_sb(struct super_block *sb, int nr_to_scan)spin_unlock (&inode->i_lock);spin_unlock (&sb->s_inode_lru_lock);if (remove_inode_buffers (inode)) - reap +=invalidate_mapping_pages (&inode->i_data, -0 ,-1 ); + reap +=invalidate_inode_inactive_pages ( + &inode->i_data,0 ,-1 );iput (inode);spin_lock (&sb->s_inode_lru_lock);
include/linux/fs.h +2 -0
@@ -2211,6 +2211,8 @@ extern int invalidate_partition(struct gendisk *, int);#endif unsigned long invalidate_mapping_pages (struct address_space *mapping,pgoff_t start,pgoff_t end); +unsigned long invalidate_inode_inactive_pages (struct address_space *mapping, +pgoff_t start,pgoff_t end);static inline void invalidate_remote_inode (struct inode *inode) {
mm/truncate.c +46 -0
52 lines not on this page · raw message
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 4 lines · On Wed, 16 Nov 2011 17:47:47 +0300 Konstantin Khlebnikov…
Inode cache pruning can throw out some usefull data from page cache. This patch aborts inode invalidation and keep inode alive if it still has active pages.
hm, I suppose so.
I also suppose there are various risks related to failing to reclaim inodes due to ongoing userspace activity and then running out of lowmem pages.
Quoted 1 line
It improves interaction between inode cache and page cache.
Well, this is the key part of the patch and it is the thing which we are most interested in. But you didn't tell us anything about it!
So please, provide us with much more detailed information on the observed benefits.
Quoted 71 lines
fs/inode.c +2
-2@@ -663,8 +663,8 @@ void prune_icache_sb(struct super_block *sb, int nr_to_scan)spin_unlock (&inode->i_lock);spin_unlock (&sb->s_inode_lru_lock);if (remove_inode_buffers (inode)) - reap +=invalidate_mapping_pages (&inode->i_data, -0 ,-1 ); + reap +=invalidate_inode_inactive_pages ( + &inode->i_data,0 ,-1 );iput (inode);spin_lock (&sb->s_inode_lru_lock);include/linux/fs.h +2
-0@@ -2211,6 +2211,8 @@ extern int invalidate_partition(struct gendisk *, int);#endif unsigned long invalidate_mapping_pages (struct address_space *mapping,pgoff_t start,pgoff_t end); +unsigned long invalidate_inode_inactive_pages (struct address_space *mapping, +pgoff_t start,pgoff_t end);static inline void invalidate_remote_inode (struct inode *inode) {mm/truncate.c +34
-0@@ -379,6 +379,52 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,EXPORT_SYMBOL (invalidate_mapping_pages);/* +* This is like invalidate_mapping_pages(), +* except it aborts invalidation at the first active page. +*/ +unsigned long invalidate_inode_inactive_pages (struct address_space *mapping, +pgoff_t start,pgoff_t end) +{ +struct pagevec pvec; +pgoff_t index = start; +unsigned long ret; +unsigned long count =0 ; +int i; + +pagevec_init (&pvec,0 ); +while (index <= end &&pagevec_lookup (&pvec, mapping, index, +min (end - index, (pgoff_t )PAGEVEC_SIZE -1 ) +1 )) { + +mem_cgroup_uncharge_start (); +for (i =0 ; i <pagevec_count (&pvec); i++) { +struct page *page = pvec.pages[i]; + +if (PageActive (page)) { + index = end; +break ; + } + +/* We rely upon deletion not changing page->index */ + index = page->index; +if (index > end) +break ; + +if (!trylock_page (page)) +continue ; +WARN_ON (page->index != index); + ret =invalidate_inode_page (page);
mm/truncate.c unsigned long invalidate_mapping_pages(struct address_space *mapping, · line 425
Quoted 10 lines
mm/truncate.c +10
-0+unlock_page (page); + count += ret; + } +pagevec_release (&pvec); +mem_cgroup_uncharge_end (); +cond_resched (); + index++; + } +return count; +}
We shouldn't just copy-n-paste invalidate_mapping_pages() like this. Can't we share the function by passing in a pointer to a callback function (invalidate_inode_page or a new invalidate_inode_page_unless_it_is_active).
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · Andrew Morton
Quoted 4 lines · On Wed, 16 Nov 2011 17:47:47 +0300 Konstantin…
Inode cache pruning can throw out some usefull data from page cache. This patch aborts inode invalidation and keep inode alive if it still has active pages.
Quoted 5 lines
hm, I suppose so.
I also suppose there are various risks related to failing to reclaim inodes due to ongoing userspace activity and then running out of lowmem pages.
Ok, I think we can bypass active-page protection if CONFIG_HIGHMEM=y and there is no __GFP_HIGHMEM in gfp_mask.
Quoted 8 lines
Quoted 2 lines
It improves interaction between inode cache and page cache.
Well, this is the key part of the patch and it is the thing which we are most interested in. But you didn't tell us anything about it!
So please, provide us with much more detailed information on the observed benefits.
Currently this is based only on thought experiment.
I think rising pginodesteal and kswapd_inodesteal in /proc/vstat is sign of inefficient memory reclaiming, because page-cache lru has a much more detailed information about memory activity.
I plan to run some containers related tests/benchmarks, something like multiple heavy-loaded web-servers.
Quoted 79 lines
Quoted 79 lines
fs/inode.c +2
-2@@ -663,8 +663,8 @@ void prune_icache_sb(struct super_block *sb, int nr_to_scan)spin_unlock (&inode->i_lock);spin_unlock (&sb->s_inode_lru_lock);if (remove_inode_buffers (inode)) - reap +=invalidate_mapping_pages (&inode->i_data, -0 ,-1 ); + reap +=invalidate_inode_inactive_pages ( + &inode->i_data,0 ,-1 );iput (inode);spin_lock (&sb->s_inode_lru_lock);include/linux/fs.h +2
-0@@ -2211,6 +2211,8 @@ extern int invalidate_partition(struct gendisk *, int);#endif unsigned long invalidate_mapping_pages (struct address_space *mapping,pgoff_t start,pgoff_t end); +unsigned long invalidate_inode_inactive_pages (struct address_space *mapping, +pgoff_t start,pgoff_t end);static inline void invalidate_remote_inode (struct inode *inode) {mm/truncate.c +41
-0@@ -379,6 +379,52 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,EXPORT_SYMBOL (invalidate_mapping_pages);/* +* This is like invalidate_mapping_pages(), +* except it aborts invalidation at the first active page. +*/ +unsigned long invalidate_inode_inactive_pages (struct address_space *mapping, +pgoff_t start,pgoff_t end) +{ +struct pagevec pvec; +pgoff_t index = start; +unsigned long ret; +unsigned long count =0 ; +int i; + +pagevec_init (&pvec,0 ); +while (index<= end&&pagevec_lookup (&pvec, mapping, index, +min (end - index, (pgoff_t )PAGEVEC_SIZE -1 ) +1 )) { + +mem_cgroup_uncharge_start (); +for (i =0 ; i<pagevec_count (&pvec); i++) { +struct page *page = pvec.pages[i]; + +if (PageActive (page)) { + index = end; +break ; + } + +/* We rely upon deletion not changing page->index */ + index = page->index; +if (index> end) +break ; + +if (!trylock_page (page)) +continue ; +WARN_ON (page->index != index); + ret =invalidate_inode_page (page); +unlock_page (page); + count += ret; + } +pagevec_release (&pvec); +mem_cgroup_uncharge_end (); +cond_resched (); + index++;
Quoted 9 lines
mm/truncate.c unsigned long invalidate_mapping_pages(struct address_space *mapping, · line 425
Quoted 3 lines
mm/truncate.c +3
-0+ } +return count; +}We shouldn't just copy-n-paste
invalidate_mapping_pages()like this. Can't we share the function by passing in a pointer to a callback function (invalidate_inode_pageor a newinvalidate_inode_page_unless_it_is_active).
Ok, I'll think how to implement this more accurate.