From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,willy@infradead.org,tytso@mit.edu,
lczerner@redhat.com,jack@suse.cz,hughd@google.com,dennylin0707@gmail.com,
akpm@linux-foundation.org
Subject: + mm-skip-empty-finite-ranges-in-truncate_pagecache_range.patch added to mm-new branch
Date: Mon, 09 Nov 2026 13:59:27 -0800 [thread overview]
Message-ID: <20261109215928.3FC601F0089F@smtp.kernel.org> (raw)
The patch titled
Subject: mm: skip empty finite ranges in truncate_pagecache_range
has been added to the -mm mm-new branch. Its filename is
mm-skip-empty-finite-ranges-in-truncate_pagecache_range.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-skip-empty-finite-ranges-in-truncate_pagecache_range.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Hungyu Lin <dennylin0707@gmail.com>
Subject: mm: skip empty finite ranges in truncate_pagecache_range
Date: Wed, 4 Nov 2026 18:27:00 +0000
For a finite range ending before the first page boundary,
truncate_pagecache_range() calculates unmap_end as -1. The unsigned
comparison then treats the empty full-page interval as nonempty.
For example, lstart == 0 and lend == 0 cause unmap_mapping_range() to be
called with a zero length, meaning unmap to EOF. Punching one byte at
offset zero in a mapped FUSE file can therefore remove mappings outside
the hole, causing unnecessary page-table work and subsequent faults.
Set unmap_end to zero for these small finite ranges so that the existing
unsigned comparison skips the empty interval. Explicitly handle lend ==
-1 and lend == LLONG_MAX with LLONG_MAX, preserving EOF handling and
avoiding wrapping in the endpoint calculation at the largest inclusive
end.
Link: https://lore.kernel.org/20261104182700.88789-1-dennylin0707@gmail.com
Link: https://lore.kernel.org/r/20261027211505.22044-1-dennylin0707@gmail.com
Fixes: 5a7203947a1d ("mm: teach truncate_inode_pages_range() to handle non page aligned ranges")
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Jan Kara <jack@suse.cz>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Lukas Czerner <lczerner@redhat.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Hugh Dickins <hughd@google.com>
---
mm/truncate.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
--- a/mm/truncate.c~mm-skip-empty-finite-ranges-in-truncate_pagecache_range
+++ a/mm/truncate.c
@@ -954,7 +954,15 @@ void truncate_pagecache_range(struct ino
{
struct address_space *mapping = inode->i_mapping;
loff_t unmap_start = round_up(lstart, PAGE_SIZE);
- loff_t unmap_end = round_down(1 + lend, PAGE_SIZE) - 1;
+ loff_t unmap_end;
+
+ if (lend == -1 || lend == LLONG_MAX)
+ unmap_end = LLONG_MAX;
+ else if (lend < PAGE_SIZE - 1)
+ unmap_end = 0;
+ else
+ unmap_end = round_down(1 + lend, PAGE_SIZE) - 1;
+
/*
* This rounding is currently just for example: unmap_mapping_range
* expands its hole outwards, whereas we want it to contract the hole
_
Patches currently in -mm which might be from dennylin0707@gmail.com are
mm-page-writeback-avoid-overflow-when-reporting-bdi-byte-limits.patch
mm-skip-empty-finite-ranges-in-truncate_pagecache_range.patch
delayacct-preserve-delay-extrema-when-aggregating-taskstats.patch
shmem-clamp-negative-used-block-samples-in-statfs.patch
reply other threads:[~2026-11-09 21:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261109215928.3FC601F0089F@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=dennylin0707@gmail.com \
--cc=hughd@google.com \
--cc=jack@suse.cz \
--cc=lczerner@redhat.com \
--cc=mm-commits@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.