+ mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees.patch added to -mm tree
Subsystems (6)
[email protected]
maintainerSubject: + mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Tue, 04 Feb 2014 15:14:48 -0800
The patch titled
Subject: mm + fs: prepare for non-page entries in page cache radix trees
has been added to the -mm tree. Its filename is
mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Johannes Weiner <[email protected]>
Subject: mm + fs: prepare for non-page entries in page cache radix trees
shmem mappings already contain exceptional entries where swap slot information is remembered.
To be able to store eviction information for regular page cache, prepare every site dealing with the radix trees directly to handle entries other than pages.
The common lookup functions will filter out non-page entries and return NULL for page cache holes, just as before. But provide a raw version of the API which returns non-page entries as well, and switch shmem over to use it.
---
fs/btrfs/compression.c | 2 include/linux/mm.h | 8 + include/linux/pagemap.h | 15 +- include/linux/pagevec.h | 3 include/linux/shmem_fs.h | 1 mm/filemap.c | 197 ++++++++++++++++++++++++++++++++----- mm/mincore.c | 20 ++- mm/readahead.c | 2 mm/shmem.c | 97 +++--------------- mm/swap.c | 48 +++++++++ mm/truncate.c | 73 +++++++++++-- 11 files changed, 338 insertions(+), 128 deletions(-)
fs/btrfs/compression.c renamed from fs/btrfs/compression.c~mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees +1 -1
@@ -472,7 +472,7 @@ static noinline int add_ra_bio_pages(strrcu_read_lock (); page =radix_tree_lookup (&mapping->page_tree, pg_index);rcu_read_unlock (); -if (page) { +if (page && !radix_tree_exceptional_entry (page)) { misses++;if (misses >4 )break ;
include/linux/mm.h renamed from include/linux/mm.h~mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees +8 -0
@@ -1031,6 +1031,14 @@ extern void show_free_areas(unsigned intextern bool skip_free_areas_node (unsigned int flags,int nid);int shmem_zero_setup (struct vm_area_struct *); +#ifdef CONFIG_SHMEM +bool shmem_mapping (struct address_space *mapping); +#else +static inline bool shmem_mapping (struct address_space *mapping) +{ +return false; +} +#endif extern int can_do_mlock (void );extern int user_shm_lock (size_t ,struct user_struct *);
include/linux/pagemap.h renamed from include/linux/pagemap.h~mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees +9 -6
@@ -248,12 +248,15 @@ pgoff_t page_cache_next_hole(struct addrpgoff_t page_cache_prev_hole (struct address_space *mapping,pgoff_t index,unsigned long max_scan); -extern struct page *find_get_page (struct address_space *mapping, -pgoff_t index); -extern struct page *find_lock_page (struct address_space *mapping, -pgoff_t index); -extern struct page *find_or_create_page (struct address_space *mapping, -pgoff_t index,gfp_t gfp_mask); +struct page *__find_get_page (struct address_space *mapping,pgoff_t offset); +struct page *find_get_page (struct address_space *mapping,pgoff_t offset); +struct page *__find_lock_page (struct address_space *mapping,pgoff_t offset); +struct page *find_lock_page (struct address_space *mapping,pgoff_t offset); +struct page *find_or_create_page (struct address_space *mapping,pgoff_t index, +gfp_t gfp_mask); +unsigned __find_get_pages (struct address_space *mapping,pgoff_t start, +unsigned int nr_pages,struct page **pages, +pgoff_t *indices);unsigned find_get_pages (struct address_space *mapping,pgoff_t start,unsigned int nr_pages,struct page **pages); unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t start,
include/linux/pagevec.h renamed from include/linux/pagevec.h~mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees +3 -0
@@ -22,6 +22,9 @@ struct pagevec {void __pagevec_release (struct pagevec *pvec);void __pagevec_lru_add (struct pagevec *pvec); +unsigned __pagevec_lookup (struct pagevec *pvec,struct address_space *mapping, +pgoff_t start,unsigned nr_pages,pgoff_t *indices); +void pagevec_remove_exceptionals (struct pagevec *pvec);unsigned pagevec_lookup (struct pagevec *pvec,struct address_space *mapping,pgoff_t start,unsigned nr_pages); unsigned pagevec_lookup_tag(struct pagevec *pvec,
include/linux/shmem_fs.h renamed from include/linux/shmem_fs.h~mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees +1 -0
@@ -51,6 +51,7 @@ extern struct file *shmem_kernel_file_se unsigned long flags);extern int shmem_zero_setup (struct vm_area_struct *);extern int shmem_lock (struct file *file,int lock,struct user_struct *user); +extern bool shmem_mapping (struct address_space *mapping);extern void shmem_unlock_mapping (struct address_space *mapping);extern struct page *shmem_read_mapping_page_gfp (struct address_space *mapping,pgoff_t index,gfp_t gfp_mask);
mm/filemap.c renamed from mm/filemap.c~mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees +174 -23
271 lines not on this page · raw message
mm/mincore.c renamed from mm/mincore.c~mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees +14 -6
@@ -70,13 +70,21 @@ static unsigned char mincore_page(struct* any other file mapping (ie. marked !present and faulted in with * tmpfs's .fault). So swapped out tmpfs mappings are tested here. */ - page =find_get_page (mapping, pgoff);#ifdef CONFIG_SWAP -/* shmem/tmpfs may return swap: account for swapcache page too. */ -if (radix_tree_exceptional_entry (page)) { -swp_entry_t swap =radix_to_swp_entry (page); - page =find_get_page (swap_address_space (swap), swap.val); - } +if (shmem_mapping (mapping)) { + page =__find_get_page (mapping, pgoff); +/* +* shmem/tmpfs may return swap: account for swapcache +* page too. +*/ +if (radix_tree_exceptional_entry (page)) { +swp_entry_t swp =radix_to_swp_entry (page); + page =find_get_page (swap_address_space (swp), swp.val); + } + }else + page =find_get_page (mapping, pgoff); +#else + page =find_get_page (mapping, pgoff);#endif if (page) { present =PageUptodate (page);
mm/readahead.c renamed from mm/readahead.c~mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees +1 -1
@@ -179,7 +179,7 @@ __do_page_cache_readahead(struct addressrcu_read_lock (); page =radix_tree_lookup (&mapping->page_tree, page_offset);rcu_read_unlock (); -if (page) +if (page && !radix_tree_exceptional_entry (page))continue ; page =page_cache_alloc_readahead (mapping);
mm/shmem.c renamed from mm/shmem.c~mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees +19 -78
174 lines not on this page · raw message
mm/swap.c renamed from mm/swap.c~mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees +48 -0
54 lines not on this page · raw message
mm/truncate.c renamed from mm/truncate.c~mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees +60 -13
183 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are
mm-vmscan-respect-numa-policy-mask-when-shrinking-slab-on-direct-reclaim.patch mm-vmscan-move-call-to-shrink_slab-to-shrink_zones.patch mm-vmscan-remove-shrink_control-arg-from-do_try_to_free_pages.patch mm-vmstat-fix-up-zone-state-accounting.patch fs-cachefiles-use-add_to_page_cache_lru.patch lib-radix-tree-radix_tree_delete_item.patch mm-shmem-save-one-radix-tree-lookup-when-truncating-swapped-pages.patch mm-filemap-move-radix-tree-hole-searching-here.patch mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees.patch mm-fs-store-shadow-entries-in-page-cache.patch mm-thrash-detection-based-file-cache-sizing.patch lib-radix_tree-tree-node-interface.patch mm-keep-page-cache-radix-tree-nodes-in-check.patch linux-next.patch
debugging-keep-track-of-page-owners.patch
Quoted 9 lines · On Tue, Feb 04, 2014 at 03:14:49PM -0800, [email protected] wrote:
(quoted diff) +3
-2@@ -307,14 +331,15 @@ void truncate_inode_pages_range(struct a index = start; for ( ; ; ) { cond_resched(); - if (!pagevec_lookup(&pvec, mapping, index, - min(end - index, (pgoff_t)PAGEVEC_SIZE))) { + if (!__pagevec_lookup(&pvec, mapping, index, + min(end - index, (pgoff_t)PAGEVEC_SIZE), + indices)) {
Review void truncate_inode_pages_range(struct a · line 345
Quoted 10 lines
(quoted diff) +1
-1if (index == start) break; index = start; continue; } - if (index == start && pvec.pages[0]->index >= end) { + if (index == start && indices[0] >= end) { pagevec_release(&pvec); break; }
There is a missing pagevec_remove_exceptionals(), which can crash the kernel when pagevec_release() passes the non-page pointers to the page allocator.
Andrew, could you please include this incremental fix?
---
From: Johannes Weiner <[email protected]>
Subject: [patch] mm + fs: prepare for non-page entries in page cache radix
trees fix
__pagevec_lookup() stores exceptional entries in the pagevec. They must be pruned before passing the pagevec along to pagevec_release() or the kernel crashes when these non-page pointers reach the page allocator.
Add a missing pagevec_remove_exceptionals() in the truncate path.
--- mm/truncate.c | 1 + 1 file changed, 1 insertion(+)
mm/truncate.c +1 -0
@@ -340,6 +340,7 @@ void truncate_inode_pages_range(struct address_space *mapping,continue ; }if (index == start && indices[0 ] >= end) { +pagevec_remove_exceptionals (&pvec);pagevec_release (&pvec);break ; }
Signature · 1 line
1.9.0