+ hugetlbfs-dirty-pages-as-they-are-added-to-pagecache.patch tentatively added to -mm tree
Subsystems (4)
[email protected]
maintainerThe patch titled
Subject: hugetlbfs: dirty pages as they are added to pagecache
has been added to the -mm tree. Its filename is
hugetlbfs-dirty-pages-as-they-are-added-to-pagecache.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/hugetlbfs-dirty-pages-as-they-are-added-to-pagecache.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/hugetlbfs-dirty-pages-as-they-are-added-to-pagecache.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/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Mike Kravetz <[email protected]>
Subject: hugetlbfs: dirty pages as they are added to pagecache
Some test systems were experiencing negative huge page reserve counts and incorrect file block counts. This was traced to /proc/sys/vm/drop_caches removing clean pages from hugetlbfs file pagecaches. When non-hugetlbfs explicit code removes the pages, the appropriate accounting is not performed.
This can be recreated as follows:
fallocate -l 2M /dev/hugepages/foo
echo 1 > /proc/sys/vm/drop_caches
fallocate -l 2M /dev/hugepages/foo
grep -i huge /proc/meminfo
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
HugePages_Total: 2048
HugePages_Free: 2047
HugePages_Rsvd: 18446744073709551615
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 4194304 kB
ls -lsh /dev/hugepages/foo
4.0M -rw-r--r--. 1 root root 2.0M Oct 17 20:05 /dev/hugepages/foo
To address this issue, dirty pages as they are added to pagecache. This can easily be reproduced with fallocate as shown above. Read faulted pages will eventually end up being marked dirty. But there is a window where they are clean and could be impacted by code such as drop_caches. So, just dirty them all as they are added to the pagecache.
In addition, it makes little sense to even try to drop hugetlbfs pagecache pages, so disable calls to these filesystems in drop_caches code.
---
fs/drop_caches.c renamed from fs/drop_caches.c~hugetlbfs-dirty-pages-as-they-are-added-to-pagecache +7 -0
@@ -9,6 +9,7 @@#include <linux/writeback.h> #include <linux/sysctl.h> #include <linux/gfp.h> +#include <linux/magic.h> #include "internal.h" /* A global variable is a bit ugly, but it keeps the code simple */
@@ -18,6 +19,12 @@ static void drop_pagecache_sb(struct sup {struct inode *inode, *toput_inode =NULL ; +/* +* It makes no sense to try and drop hugetlbfs page cache pages. +*/ +if (sb->s_magic ==HUGETLBFS_MAGIC ) +return ; +spin_lock (&sb->s_inode_list_lock);list_for_each_entry (inode, &sb->s_inodes, i_sb_list) {spin_lock (&inode->i_lock);
mm/hugetlb.c renamed from mm/hugetlb.c~hugetlbfs-dirty-pages-as-they-are-added-to-pagecache +6 -0
@@ -3690,6 +3690,12 @@ int huge_add_to_page_cache(struct page *return err;ClearPagePrivate (page); +/* +* set page dirty so that it will not be removed from cache/file +* by non-hugetlbfs specific code paths. +*/ +set_page_dirty (page); +spin_lock (&inode->i_lock); inode->i_blocks +=blocks_per_huge_page (h);spin_unlock (&inode->i_lock);
_
Patches currently in -mm which might be from [email protected] are
hugetlbfs-dirty-pages-as-they-are-added-to-pagecache.patch