The patch titled nommu: ramfs: pages allocated to an inode's pagecache may get wrongly discarded has been added to the -mm tree. Its filename is nommu-ramfs-pages-allocated-to-an-inodes-pagecache-may-get-wrongly-discarded.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 *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: nommu: ramfs: pages allocated to an inode's pagecache may get wrongly discarded From: Enrik Berkhan <Enrik.Berkhan@xxxxxx> The pages attached to a ramfs inode's pagecache by truncation from nothing - as done by SYSV SHM for example - may get discarded under memory pressure. The problem is that the pages are not marked dirty. Anything that creates data in an MMU-based ramfs will cause the pages holding that data will cause the set_page_dirty() aop to be called. For the NOMMU-based mmap, set_page_dirty() may be called by write(), but it won't be called by page-writing faults on writable mmaps, and it isn't called by ramfs_nommu_expand_for_mapping() when a file is being truncated from nothing to allocate a contiguous run. The solution is to mark the pages dirty at the point of allocation by the truncation code. Signed-off-by: Enrik Berkhan <Enrik.Berkhan@xxxxxx> Signed-off-by: David Howells <dhowells@xxxxxxxxxx> Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx> Cc: Nick Piggin <nickpiggin@xxxxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/ramfs/file-nommu.c | 3 +++ 1 file changed, 3 insertions(+) diff -puN fs/ramfs/file-nommu.c~nommu-ramfs-pages-allocated-to-an-inodes-pagecache-may-get-wrongly-discarded fs/ramfs/file-nommu.c --- a/fs/ramfs/file-nommu.c~nommu-ramfs-pages-allocated-to-an-inodes-pagecache-may-get-wrongly-discarded +++ a/fs/ramfs/file-nommu.c @@ -113,6 +113,9 @@ int ramfs_nommu_expand_for_mapping(struc if (!pagevec_add(&lru_pvec, page)) __pagevec_lru_add_file(&lru_pvec); + /* prevent the page from being discarded on memory pressure */ + SetPageDirty(page); + unlock_page(page); } _ Patches currently in -mm which might be from Enrik.Berkhan@xxxxxx are origin.patch nommu-ramfs-pages-allocated-to-an-inodes-pagecache-may-get-wrongly-discarded.patch nommu-ramfs-pages-allocated-to-an-inodes-pagecache-may-get-wrongly-discarded-fix.patch nommu-ramfs-dont-leak-pages-when-adding-to-page-cache-fails.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html