* [PATCH] mm: shmem: fix minor off-by-one in shrinkable calculation
@ 2024-08-25 22:42 Hugh Dickins
2024-08-26 6:48 ` David Hildenbrand
2024-08-27 7:14 ` Baolin Wang
0 siblings, 2 replies; 3+ messages in thread
From: Hugh Dickins @ 2024-08-25 22:42 UTC (permalink / raw)
To: Andrew Morton
Cc: Kirill A. Shutemov, Baolin Wang, Hugh Dickins, linux-kernel,
linux-mm
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.
Fixes: 779750d20b93 ("shmem: split huge pages beyond i_size under memory pressure")
Signed-off-by: Hugh Dickins <hughd@google.com>
---
mm/shmem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index 85e3bd3e709e..37c300f69baf 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2326,7 +2326,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);
/*
--
2.35.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mm: shmem: fix minor off-by-one in shrinkable calculation
2024-08-25 22:42 [PATCH] mm: shmem: fix minor off-by-one in shrinkable calculation Hugh Dickins
@ 2024-08-26 6:48 ` David Hildenbrand
2024-08-27 7:14 ` Baolin Wang
1 sibling, 0 replies; 3+ messages in thread
From: David Hildenbrand @ 2024-08-26 6:48 UTC (permalink / raw)
To: Hugh Dickins, Andrew Morton
Cc: Kirill A. Shutemov, Baolin Wang, linux-kernel, linux-mm
On 26.08.24 00:42, Hugh Dickins wrote:
> 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.
>
> Fixes: 779750d20b93 ("shmem: split huge pages beyond i_size under memory pressure")
> Signed-off-by: Hugh Dickins <hughd@google.com>
> ---
> mm/shmem.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 85e3bd3e709e..37c300f69baf 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -2326,7 +2326,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);
> /*
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm: shmem: fix minor off-by-one in shrinkable calculation
2024-08-25 22:42 [PATCH] mm: shmem: fix minor off-by-one in shrinkable calculation Hugh Dickins
2024-08-26 6:48 ` David Hildenbrand
@ 2024-08-27 7:14 ` Baolin Wang
1 sibling, 0 replies; 3+ messages in thread
From: Baolin Wang @ 2024-08-27 7:14 UTC (permalink / raw)
To: Hugh Dickins, Andrew Morton; +Cc: Kirill A. Shutemov, linux-kernel, linux-mm
On 2024/8/26 06:42, Hugh Dickins wrote:
> 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.
>
> Fixes: 779750d20b93 ("shmem: split huge pages beyond i_size under memory pressure")
> Signed-off-by: Hugh Dickins <hughd@google.com>
LGTM. Feel free to add:
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> ---
> mm/shmem.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 85e3bd3e709e..37c300f69baf 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -2326,7 +2326,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);
> /*
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-27 7:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-25 22:42 [PATCH] mm: shmem: fix minor off-by-one in shrinkable calculation Hugh Dickins
2024-08-26 6:48 ` David Hildenbrand
2024-08-27 7:14 ` Baolin Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).