]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
mm: shmem: fix the update of 'shmem_falloc->nr_unswapped'
authorBaolin Wang <baolin.wang@linux.alibaba.com>
Thu, 19 Dec 2024 07:30:09 +0000 (15:30 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 31 Dec 2024 01:59:10 +0000 (17:59 -0800)
The 'shmem_falloc->nr_unswapped' is used to record how many writepage
refused to swap out because fallocate() is allocating, but after shmem
supports large folio swap out, the update of 'shmem_falloc->nr_unswapped'
does not use the correct number of pages in the large folio, which may
lead to fallocate() not exiting as soon as possible.

Anyway, this is found through code inspection, and I am not sure whether
it would actually cause serious issues.

Link: https://lkml.kernel.org/r/f66a0119d0564c2c37c84f045835b870d1b2196f.1734593154.git.baolin.wang@linux.alibaba.com
Fixes: 809bc86517cc ("mm: shmem: support large folio swap out")
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/shmem.c

index dec659e84562e56645afb55552d8adb1756b3b30..ac58d4fb2e6f5a617c85cd49de99e3c5f97209e6 100644 (file)
@@ -1535,7 +1535,7 @@ try_split:
                            !shmem_falloc->waitq &&
                            index >= shmem_falloc->start &&
                            index < shmem_falloc->next)
-                               shmem_falloc->nr_unswapped++;
+                               shmem_falloc->nr_unswapped += nr_pages;
                        else
                                shmem_falloc = NULL;
                        spin_unlock(&inode->i_lock);