Commit bf5cb2bf authored by Hugh Dickins's avatar Hugh Dickins Committed by Euler
Browse files

mm: shmem: fix minor off-by-one in shrinkable calculation

mainline inclusion
from mainline-v6.12-rc1
commit de5b85262e2038a5ae5d281ddf43d35acb2bfa60
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBGFBA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=de5b85262e2038a5ae5d281ddf43d35acb2bfa60

--------------------------------

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: 779750d2 ("shmem: split huge pages beyond i_size under memory pressure")
Signed-off-by: default avatarHugh Dickins <hughd@google.com>
Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
Reviewed-by: default avatarBaolin Wang <baolin.wang@linux.alibaba.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarWang Lian <dev01404@linx-info.com>
---
parent 13564f7b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2370,7 +2370,7 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index,
	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);
		/*