]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: shmem: fix minor off-by-one in shrinkable calculation
authorHugh Dickins <hughd@google.com>
Sun, 25 Aug 2024 22:42:45 +0000 (15:42 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 9 Sep 2024 23:39:02 +0000 (16:39 -0700)
There has been a long-standing and very minor off-by-one, where
shmem_get_folio_gfp() decides if a large folio extends beyond i_size far
enough to leave a page or more for freeing later under pressure.

This is not something needed for stable: but it will be proportionately
more significant as support for smaller large folios is added, and is best
fixed before duplicating the check in other places.

Link: https://lkml.kernel.org/r/d8e75079-af2d-8519-56df-6be1dccc247a@google.com
Fixes: 779750d20b93 ("shmem: split huge pages beyond i_size under memory pressure")
Signed-off-by: Hugh Dickins <hughd@google.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/shmem.c

index 800cec9dc534e515d32469ada52744d1adefe306..bf50ecb906ce2c0111fe15c1e1b656d4ce552975 100644 (file)
@@ -2348,7 +2348,7 @@ alloced:
        alloced = true;
        if (folio_test_large(folio) &&
            DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE) <
-                                       folio_next_index(folio) - 1) {
+                                       folio_next_index(folio)) {
                struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
                struct shmem_inode_info *info = SHMEM_I(inode);
                /*