From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,zhangpeng362@huawei.com,yi.zhang@huawei.com,
willy@infradead.org,wangkefeng.wang@huawei.com,tytso@mit.edu,
stable@vger.kernel.org,ojaswin@linux.ibm.com,mcgrof@kernel.org,
libaokun1@huawei.com,john.garry@linux.dev,jack@suse.cz,
huang.ying.caritas@gmail.com,hare@suse.de,david@kernel.org,
brauner@kernel.org,mason@kernel.org,akpm@linux-foundation.org
Subject: + mm-filemap-update-the-folio-order-range-atomically.patch added to mm-new branch
Date: Mon, 30 Nov 2026 16:57:27 -0800 [thread overview]
Message-ID: <20261201005728.3E8FD1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20261129-filemap_fixes-v1-2-1546675e3c97@kernel.org>
The patch titled
Subject: mm/filemap: update the folio order range atomically
has been added to the -mm mm-new branch. Its filename is
mm-filemap-update-the-folio-order-range-atomically.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-filemap-update-the-folio-order-range-atomically.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: Chris Mason <mason@kernel.org>
Subject: mm/filemap: update the folio order range atomically
Date: Sun, 29 Nov 2026 10:05:10 +0100
mapping_set_folio_order_range() updates mapping->flags with a plain load
and store, assuming that nobody can modify the flags concurrently.
However, set_blocksize() and ext4_change_inode_journal_flag() call it on
active inodes, and none of their locks protects from concurrent
mm_take_all_locks():
set_blocksize() mm_take_all_locks()
=============== ===================
load mapping->flags
test_and_set_bit(AS_MM_ALL_LOCKS)
down_write(i_mmap_rwsem)
store mapping->flags
mm_drop_all_locks()
bit is clear, no up_write()
Consequently, we can lose concurrent setting/clearing of AS_MM_ALL_LOCKS,
resulting in i_mmap_rwsem staying write-locked forever or being released
by another task.
Let's fix it by updating the order bits atomically, and document what
callers on an active inode still have to ensure.
This has medium urgency, as an unsuspecting admin can trigger it,
leaving i_mmap_rwsem locked forever.
[david@kernel.org: adjust comment and description]
Link: https://patch.msgid.link/20261129-filemap_fixes-v1-2-1546675e3c97@kernel.org
Fixes: 3c20917120ce ("block/bdev: enable large folio support for large logical block sizes")
Fixes: 58fd191f99f3 ("ext4: make data=journal support large block size")
Signed-off-by: Chris Mason <mason@kernel.org>
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Ying Huang <huang.ying.caritas@gmail.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: ZhangPeng <zhangpeng362@huawei.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: John Garry <john.garry@linux.dev>
Cc: Zhang Yi <yi.zhang@huawei.com>
Cc: Baokun Li <libaokun1@huawei.com>
Cc: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: <stable@vger.kernel.org>
include/linux/pagemap.h | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
--- a/include/linux/pagemap.h~mm-filemap-update-the-folio-order-range-atomically
+++ a/include/linux/pagemap.h
@@ -411,8 +411,8 @@ static inline size_t mapping_max_folio_s
* something the core cannot know).
* Do not tune it based on, eg, i_size.
*
- * Context: This should not be called while the inode is active as it
- * is non-atomic.
+ * Context: Safe to be called while the inode is active. However, the page
+ * cache must be empty and must be kept empty while setting the order range.
*/
static inline void mapping_set_folio_order_range(struct address_space *mapping,
unsigned int min,
@@ -430,8 +430,8 @@ static inline void mapping_set_folio_ord
if (max < min)
max = min;
- mapping->flags = (mapping->flags & ~AS_FOLIO_ORDER_MASK) |
- (min << AS_FOLIO_ORDER_MIN) | (max << AS_FOLIO_ORDER_MAX);
+ set_mask_bits(&mapping->flags, AS_FOLIO_ORDER_MASK,
+ (min << AS_FOLIO_ORDER_MIN) | (max << AS_FOLIO_ORDER_MAX));
}
static inline void mapping_set_folio_min_order(struct address_space *mapping,
@@ -448,8 +448,7 @@ static inline void mapping_set_folio_min
* indicate that the VFS can use large folios to cache the contents of
* the file.
*
- * Context: This should not be called while the inode is active as it
- * is non-atomic.
+ * Context: See mapping_set_folio_order_range().
*/
static inline void mapping_set_large_folios(struct address_space *mapping)
{
_
Patches currently in -mm which might be from mason@kernel.org are
mm-swap-fix-large-swap-in-across-swap-file-extents.patch
hugetlbfs-do-not-grow-a-sealed-file-in-mmap.patch
mm-hugetlb-keep-surplus-folios-that-are-reserved.patch
mm-hugetlb-fix-reservation-leak-on-min_size=-mounts.patch
mm-cachestat-count-each-page-only-once.patch
mm-cachestat-restart-the-walk-after-each-entry.patch
percpu-queue-the-balance-work-on-an-unbound-workqueue.patch
mm-vma-fix-uncharge-after-failed-stack-relocation.patch
mm-mremap-apply-the-mmap-offset-limits-on-expansion.patch
mm-mremap-respect-guard-gaps-on-in-place-expansion.patch
mm-vma-make-brk-mappings-non-executable-under-mdwe.patch
mm-hmm-refuse-secretmem-vmas-in-hmm_range_fault.patch
mm-mglru-count-all-generations-as-evictable.patch
mm-mglru-test-pg_lru-before-taking-a-folio-reference.patch
mm-mglru-report-root-reclaim-to-memorypressure_level.patch
kfence-use-a-nofault-store-to-zero-the-guard-page.patch
mm-hugetlb-fix-truncated-copy-result-in-uffdio_copy.patch
hugetlbfs-fix-deadlock-between-hole-punching-and-memory-failure.patch
hugetlbfs-recheck-the-vma-range-after-the-lock-wait.patch
mm-hugetlb-dont-zap-non-present-entries-when-unmapping-a-folio.patch
mm-hugetlb-unshare-pmds-of-a-split-vma-if-allocating-its-lock-fails.patch
mm-hugetlb_cgroup-track-in-use-folios-per-cgroup.patch
hugetlbfs-seal-shm_hugetlb-files-against-growth.patch
mm-hugetlb-resolve-protnone-faults-without-a-uffd-bit.patch
mm-filemap-update-the-folio-order-range-atomically.patch
prev parent reply other threads:[~2026-12-01 0:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 9:05 [PATCH 0/2] mm/filemap: two smaller fixes David Hildenbrand (Arm)
2026-11-29 9:05 ` [PATCH 1/2] mm/filemap: avoid retrying faults on uffd-wp markers David Hildenbrand (Arm)
2026-12-01 0:57 ` + mm-filemap-avoid-retrying-faults-on-uffd-wp-markers.patch added to mm-new branch Andrew Morton
2026-11-29 9:05 ` [PATCH 2/2] mm/filemap: update the folio order range atomically David Hildenbrand (Arm)
2026-11-30 13:46 ` Jan Kara
2026-12-01 0:57 ` Andrew Morton [this message]
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=20261201005728.3E8FD1F00893@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=david@kernel.org \
--cc=hare@suse.de \
--cc=huang.ying.caritas@gmail.com \
--cc=jack@suse.cz \
--cc=john.garry@linux.dev \
--cc=libaokun1@huawei.com \
--cc=mason@kernel.org \
--cc=mcgrof@kernel.org \
--cc=mm-commits@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=stable@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=wangkefeng.wang@huawei.com \
--cc=willy@infradead.org \
--cc=yi.zhang@huawei.com \
--cc=zhangpeng362@huawei.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox