mbox series

[SRU,X,0/1] Fix LP: #1793430 - cachefiles page leak

Message ID 20180920055133.3402-1-daniel.axtens@canonical.com
Headers show
Series Fix LP: #1793430 - cachefiles page leak | expand

Message

Daniel Axtens Sept. 20, 2018, 5:51 a.m. UTC
From: Daniel Axtens <dja@axtens.net>

SRU Justification
-----------------

[Description]

In a heavily loaded system where the system pagecache is nearing
memory limits and fscache is enabled, pages can be leaked by fscache
while trying read pages from cachefiles backend. This can happen
because two applications can be reading same page from a single mount,
two threads can be trying to read the backing page at same time. This
results in one of the thread finding that a page for the backing file
or netfs file is already in the radix tree. During the error handling
cachefiles does not cleanup the reference on backing page, leading to
page leak.

[Fix]
The fix is straightforward, to decrement the reference when error is encounterd.

[Testing]
A user has tested the fix using following method for 12+ hrs.

    1) mkdir -p /mnt/nfs ; mount -o vers=3,fsc <server_ip>:/export /mnt/nfs
    2) create 10000 files of 2.8MB in a NFS mount.
    3) start a thread to simulate heavy VM presssure
       (while true ; do echo 3 > /proc/sys/vm/drop_caches ; sleep 1 ; done)&
    4) start multiple parallel reader for data set at same time
       find /mnt/nfs -type f | xargs -P 80 cat > /dev/null &
       find /mnt/nfs -type f | xargs -P 80 cat > /dev/null &
       find /mnt/nfs -type f | xargs -P 80 cat > /dev/null &
       ..
       ..
       find /mnt/nfs -type f | xargs -P 80 cat > /dev/null &
       find /mnt/nfs -type f | xargs -P 80 cat > /dev/null &
    5) finally check using cat /proc/fs/fscache/stats | grep -i pages ;
       free -h , cat /proc/meminfo and page-types -r -b lru
       to ensure all pages are freed.

[Regression Potential]
Limited to cachefiles.

Kiran Kumar Modukuri (1):
  UBUNTU: SAUCE: cachefiles: Page leaking in
    cachefiles_read_backing_file while vmscan is active

 fs/cachefiles/rdwr.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Kleber Sacilotto de Souza Sept. 27, 2018, 3:02 p.m. UTC | #1
On 09/20/18 07:51, Daniel Axtens wrote:
> From: Daniel Axtens <dja@axtens.net>
> 
> SRU Justification
> -----------------
> 
> [Description]
> 
> In a heavily loaded system where the system pagecache is nearing
> memory limits and fscache is enabled, pages can be leaked by fscache
> while trying read pages from cachefiles backend. This can happen
> because two applications can be reading same page from a single mount,
> two threads can be trying to read the backing page at same time. This
> results in one of the thread finding that a page for the backing file
> or netfs file is already in the radix tree. During the error handling
> cachefiles does not cleanup the reference on backing page, leading to
> page leak.
> 
> [Fix]
> The fix is straightforward, to decrement the reference when error is encounterd.
> 
> [Testing]
> A user has tested the fix using following method for 12+ hrs.
> 
>     1) mkdir -p /mnt/nfs ; mount -o vers=3,fsc <server_ip>:/export /mnt/nfs
>     2) create 10000 files of 2.8MB in a NFS mount.
>     3) start a thread to simulate heavy VM presssure
>        (while true ; do echo 3 > /proc/sys/vm/drop_caches ; sleep 1 ; done)&
>     4) start multiple parallel reader for data set at same time
>        find /mnt/nfs -type f | xargs -P 80 cat > /dev/null &
>        find /mnt/nfs -type f | xargs -P 80 cat > /dev/null &
>        find /mnt/nfs -type f | xargs -P 80 cat > /dev/null &
>        ..
>        ..
>        find /mnt/nfs -type f | xargs -P 80 cat > /dev/null &
>        find /mnt/nfs -type f | xargs -P 80 cat > /dev/null &
>     5) finally check using cat /proc/fs/fscache/stats | grep -i pages ;
>        free -h , cat /proc/meminfo and page-types -r -b lru
>        to ensure all pages are freed.
> 
> [Regression Potential]
> Limited to cachefiles.
> 
> Kiran Kumar Modukuri (1):
>   UBUNTU: SAUCE: cachefiles: Page leaking in
>     cachefiles_read_backing_file while vmscan is active
> 
>  fs/cachefiles/rdwr.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 

A v2 of this patch has been sent to the mailing-list, so this one can be
ignored.

Thanks,
Kleber