Skip to content

Commit 6fea5fa

Browse files
committed
Merge tag 'mm-hotfixes-stable-2025-04-19-21-24' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull misc hotfixes from Andrew Morton: "16 hotfixes. 2 are cc:stable and the remainder address post-6.14 issues or aren't considered necessary for -stable kernels. All patches are basically for MM although five are alterations to MAINTAINERS" [ Basic counting skills are clearly not a strictly necessary requirement for kernel maintainers. - Linus ] * tag 'mm-hotfixes-stable-2025-04-19-21-24' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: MAINTAINERS: add section for locking of mm's and VMAs mm: vmscan: fix kswapd exit condition in defrag_mode mm: vmscan: restore high-cpu watermark safety in kswapd MAINTAINERS: add Pedro as reviewer to the MEMORY MAPPING section mm/memory: move sanity checks in do_wp_page() after mapcount vs. refcount stabilization mm, hugetlb: increment the number of pages to be reset on HVO writeback: fix false warning in inode_to_wb() docs: ABI: replace [email protected] with new Meta address mm/gup: fix wrongly calculated returned value in fault_in_safe_writeable() MAINTAINERS: add memory advice section MAINTAINERS: add mmap trace events to MEMORY MAPPING mm: memcontrol: fix swap counter leak from offline cgroup MAINTAINERS: add MM subsection for the page allocator MAINTAINERS: update SLAB ALLOCATOR maintainers fs/dax: fix folio splitting issue by resetting old folio order + _nr_pages mm/page_alloc: fix deadlock on cpu_hotplug_lock in __accept_page()
2 parents 119009d + ea21641 commit 6fea5fa

16 files changed

+141
-35
lines changed

CREDITS

+4
Original file line numberDiff line numberDiff line change
@@ -2071,6 +2071,10 @@ S: 660 Harvard Ave. #7
20712071
S: Santa Clara, CA 95051
20722072
S: USA
20732073

2074+
N: Joonsoo Kim
2075+
2076+
D: Slab allocators
2077+
20742078
N: Kukjin Kim
20752079
20762080
D: Samsung S3C, S5P and Exynos ARM architectures

Documentation/ABI/stable/sysfs-block

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Description:
7777

7878
What: /sys/block/<disk>/diskseq
7979
Date: February 2021
80-
Contact: Matteo Croce <mcroce@microsoft.com>
80+
Contact: Matteo Croce <teknoraver@meta.com>
8181
Description:
8282
The /sys/block/<disk>/diskseq files reports the disk
8383
sequence number, which is a monotonically increasing

Documentation/ABI/testing/sysfs-kernel-reboot

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
What: /sys/kernel/reboot
22
Date: November 2020
33
KernelVersion: 5.11
4-
Contact: Matteo Croce <mcroce@microsoft.com>
4+
Contact: Matteo Croce <teknoraver@meta.com>
55
Description: Interface to set the kernel reboot behavior, similarly to
66
what can be done via the reboot= cmdline option.
77
(see Documentation/admin-guide/kernel-parameters.txt)
88

99
What: /sys/kernel/reboot/mode
1010
Date: November 2020
1111
KernelVersion: 5.11
12-
Contact: Matteo Croce <mcroce@microsoft.com>
12+
Contact: Matteo Croce <teknoraver@meta.com>
1313
Description: Reboot mode. Valid values are: cold warm hard soft gpio
1414

1515
What: /sys/kernel/reboot/type
1616
Date: November 2020
1717
KernelVersion: 5.11
18-
Contact: Matteo Croce <mcroce@microsoft.com>
18+
Contact: Matteo Croce <teknoraver@meta.com>
1919
Description: Reboot type. Valid values are: bios acpi kbd triple efi pci
2020

2121
What: /sys/kernel/reboot/cpu
2222
Date: November 2020
2323
KernelVersion: 5.11
24-
Contact: Matteo Croce <mcroce@microsoft.com>
24+
Contact: Matteo Croce <teknoraver@meta.com>
2525
Description: CPU number to use to reboot.
2626

2727
What: /sys/kernel/reboot/force
2828
Date: November 2020
2929
KernelVersion: 5.11
30-
Contact: Matteo Croce <mcroce@microsoft.com>
30+
Contact: Matteo Croce <teknoraver@meta.com>
3131
Description: Don't wait for any other CPUs on reboot and
3232
avoid anything that could hang.
3333

MAINTAINERS

+47-2
Original file line numberDiff line numberDiff line change
@@ -15517,6 +15517,21 @@ F: mm/numa.c
1551715517
F: mm/numa_emulation.c
1551815518
F: mm/numa_memblks.c
1551915519

15520+
MEMORY MANAGEMENT - PAGE ALLOCATOR
15521+
M: Andrew Morton <[email protected]>
15522+
R: Vlastimil Babka <[email protected]>
15523+
R: Suren Baghdasaryan <[email protected]>
15524+
R: Michal Hocko <[email protected]>
15525+
R: Brendan Jackman <[email protected]>
15526+
R: Johannes Weiner <[email protected]>
15527+
R: Zi Yan <[email protected]>
15528+
15529+
S: Maintained
15530+
F: mm/compaction.c
15531+
F: mm/page_alloc.c
15532+
F: include/linux/gfp.h
15533+
F: include/linux/compaction.h
15534+
1552015535
MEMORY MANAGEMENT - SECRETMEM
1552115536
M: Andrew Morton <[email protected]>
1552215537
M: Mike Rapoport <[email protected]>
@@ -15544,10 +15559,12 @@ M: Liam R. Howlett <[email protected]>
1554415559
M: Lorenzo Stoakes <[email protected]>
1554515560
R: Vlastimil Babka <[email protected]>
1554615561
R: Jann Horn <[email protected]>
15562+
R: Pedro Falcato <[email protected]>
1554715563
1554815564
S: Maintained
1554915565
W: http://www.linux-mm.org
1555015566
T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
15567+
F: include/trace/events/mmap.h
1555115568
F: mm/mlock.c
1555215569
F: mm/mmap.c
1555315570
F: mm/mprotect.c
@@ -15558,6 +15575,36 @@ F: mm/vma.h
1555815575
F: mm/vma_internal.h
1555915576
F: tools/testing/vma/
1556015577

15578+
MEMORY MAPPING - LOCKING
15579+
M: Andrew Morton <[email protected]>
15580+
M: Suren Baghdasaryan <[email protected]>
15581+
M: Liam R. Howlett <[email protected]>
15582+
M: Lorenzo Stoakes <[email protected]>
15583+
R: Vlastimil Babka <[email protected]>
15584+
R: Shakeel Butt <[email protected]>
15585+
15586+
S: Maintained
15587+
W: http://www.linux-mm.org
15588+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
15589+
F: Documentation/mm/process_addrs.rst
15590+
F: include/linux/mmap_lock.h
15591+
F: include/trace/events/mmap_lock.h
15592+
F: mm/mmap_lock.c
15593+
15594+
MEMORY MAPPING - MADVISE (MEMORY ADVICE)
15595+
M: Andrew Morton <[email protected]>
15596+
M: Liam R. Howlett <[email protected]>
15597+
M: Lorenzo Stoakes <[email protected]>
15598+
M: David Hildenbrand <[email protected]>
15599+
R: Vlastimil Babka <[email protected]>
15600+
R: Jann Horn <[email protected]>
15601+
15602+
S: Maintained
15603+
W: http://www.linux-mm.org
15604+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
15605+
F: include/uapi/asm-generic/mman-common.h
15606+
F: mm/madvise.c
15607+
1556115608
MEMORY TECHNOLOGY DEVICES (MTD)
1556215609
M: Miquel Raynal <[email protected]>
1556315610
M: Richard Weinberger <[email protected]>
@@ -22250,9 +22297,7 @@ F: drivers/nvmem/layouts/sl28vpd.c
2225022297

2225122298
SLAB ALLOCATOR
2225222299
M: Christoph Lameter <[email protected]>
22253-
M: Pekka Enberg <[email protected]>
2225422300
M: David Rientjes <[email protected]>
22255-
M: Joonsoo Kim <[email protected]>
2225622301
M: Andrew Morton <[email protected]>
2225722302
M: Vlastimil Babka <[email protected]>
2225822303
R: Roman Gushchin <[email protected]>

fs/dax.c

+1
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ static inline unsigned long dax_folio_put(struct folio *folio)
396396
order = folio_order(folio);
397397
if (!order)
398398
return 0;
399+
folio_reset_order(folio);
399400

400401
for (i = 0; i < (1UL << order); i++) {
401402
struct dev_pagemap *pgmap = page_pgmap(&folio->page);

include/linux/backing-dev.h

+1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ static inline struct bdi_writeback *inode_to_wb(const struct inode *inode)
249249
{
250250
#ifdef CONFIG_LOCKDEP
251251
WARN_ON_ONCE(debug_locks &&
252+
(inode->i_sb->s_iflags & SB_I_CGROUPWB) &&
252253
(!lockdep_is_held(&inode->i_lock) &&
253254
!lockdep_is_held(&inode->i_mapping->i_pages.xa_lock) &&
254255
!lockdep_is_held(&inode->i_wb->list_lock)));

include/linux/mm.h

+17
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,23 @@ static inline unsigned int folio_order(const struct folio *folio)
12181218
return folio_large_order(folio);
12191219
}
12201220

1221+
/**
1222+
* folio_reset_order - Reset the folio order and derived _nr_pages
1223+
* @folio: The folio.
1224+
*
1225+
* Reset the order and derived _nr_pages to 0. Must only be used in the
1226+
* process of splitting large folios.
1227+
*/
1228+
static inline void folio_reset_order(struct folio *folio)
1229+
{
1230+
if (WARN_ON_ONCE(!folio_test_large(folio)))
1231+
return;
1232+
folio->_flags_1 &= ~0xffUL;
1233+
#ifdef NR_PAGES_IN_LARGE_FOLIO
1234+
folio->_nr_pages = 0;
1235+
#endif
1236+
}
1237+
12211238
#include <linux/huge_mm.h>
12221239

12231240
/*

include/linux/mmzone.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,9 @@ struct zone {
967967
#ifdef CONFIG_UNACCEPTED_MEMORY
968968
/* Pages to be accepted. All pages on the list are MAX_PAGE_ORDER */
969969
struct list_head unaccepted_pages;
970+
971+
/* To be called once the last page in the zone is accepted */
972+
struct work_struct unaccepted_cleanup;
970973
#endif
971974

972975
/* zone flags, see below */
@@ -1499,8 +1502,6 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,
14991502
bool zone_watermark_ok(struct zone *z, unsigned int order,
15001503
unsigned long mark, int highest_zoneidx,
15011504
unsigned int alloc_flags);
1502-
bool zone_watermark_ok_safe(struct zone *z, unsigned int order,
1503-
unsigned long mark, int highest_zoneidx);
15041505
/*
15051506
* Memory initialization context, use to differentiate memory added by
15061507
* the platform statically or via memory hotplug interface.

mm/gup.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2207,8 +2207,8 @@ size_t fault_in_safe_writeable(const char __user *uaddr, size_t size)
22072207
} while (start != end);
22082208
mmap_read_unlock(mm);
22092209

2210-
if (size > (unsigned long)uaddr - start)
2211-
return size - ((unsigned long)uaddr - start);
2210+
if (size > start - (unsigned long)uaddr)
2211+
return size - (start - (unsigned long)uaddr);
22122212
return 0;
22132213
}
22142214
EXPORT_SYMBOL(fault_in_safe_writeable);

mm/hugetlb_vmemmap.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,11 @@ static void vmemmap_remap_pte(pte_t *pte, unsigned long addr,
238238
* struct page, the special metadata (e.g. page->flags or page->mapping)
239239
* cannot copy to the tail struct page structs. The invalid value will be
240240
* checked in the free_tail_page_prepare(). In order to avoid the message
241-
* of "corrupted mapping in tail page". We need to reset at least 3 (one
242-
* head struct page struct and two tail struct page structs) struct page
241+
* of "corrupted mapping in tail page". We need to reset at least 4 (one
242+
* head struct page struct and three tail struct page structs) struct page
243243
* structs.
244244
*/
245-
#define NR_RESET_STRUCT_PAGE 3
245+
#define NR_RESET_STRUCT_PAGE 4
246246

247247
static inline void reset_struct_pages(struct page *start)
248248
{

mm/internal.h

+1
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,7 @@ unsigned long move_page_tables(struct pagetable_move_control *pmc);
15951595

15961596
#ifdef CONFIG_UNACCEPTED_MEMORY
15971597
void accept_page(struct page *page);
1598+
void unaccepted_cleanup_work(struct work_struct *work);
15981599
#else /* CONFIG_UNACCEPTED_MEMORY */
15991600
static inline void accept_page(struct page *page)
16001601
{

mm/memcontrol-v1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ void memcg1_swapout(struct folio *folio, swp_entry_t entry)
620620
mem_cgroup_id_get_many(swap_memcg, nr_entries - 1);
621621
mod_memcg_state(swap_memcg, MEMCG_SWAP, nr_entries);
622622

623-
swap_cgroup_record(folio, mem_cgroup_id(memcg), entry);
623+
swap_cgroup_record(folio, mem_cgroup_id(swap_memcg), entry);
624624

625625
folio_unqueue_deferred_split(folio);
626626
folio->memcg_data = 0;

mm/memory.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3734,8 +3734,6 @@ static bool __wp_can_reuse_large_anon_folio(struct folio *folio,
37343734
return false;
37353735

37363736
VM_WARN_ON_ONCE(folio_test_ksm(folio));
3737-
VM_WARN_ON_ONCE(folio_mapcount(folio) > folio_nr_pages(folio));
3738-
VM_WARN_ON_ONCE(folio_entire_mapcount(folio));
37393737

37403738
if (unlikely(folio_test_swapcache(folio))) {
37413739
/*
@@ -3760,6 +3758,8 @@ static bool __wp_can_reuse_large_anon_folio(struct folio *folio,
37603758
if (folio_large_mapcount(folio) != folio_ref_count(folio))
37613759
goto unlock;
37623760

3761+
VM_WARN_ON_ONCE_FOLIO(folio_large_mapcount(folio) > folio_nr_pages(folio), folio);
3762+
VM_WARN_ON_ONCE_FOLIO(folio_entire_mapcount(folio), folio);
37633763
VM_WARN_ON_ONCE(folio_mm_id(folio, 0) != vma->vm_mm->mm_id &&
37643764
folio_mm_id(folio, 1) != vma->vm_mm->mm_id);
37653765

mm/mm_init.c

+1
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,7 @@ static void __meminit zone_init_free_lists(struct zone *zone)
14411441

14421442
#ifdef CONFIG_UNACCEPTED_MEMORY
14431443
INIT_LIST_HEAD(&zone->unaccepted_pages);
1444+
INIT_WORK(&zone->unaccepted_cleanup, unaccepted_cleanup_work);
14441445
#endif
14451446
}
14461447

mm/page_alloc.c

+26-14
Original file line numberDiff line numberDiff line change
@@ -3470,18 +3470,6 @@ static inline bool zone_watermark_fast(struct zone *z, unsigned int order,
34703470
return false;
34713471
}
34723472

3473-
bool zone_watermark_ok_safe(struct zone *z, unsigned int order,
3474-
unsigned long mark, int highest_zoneidx)
3475-
{
3476-
long free_pages = zone_page_state(z, NR_FREE_PAGES);
3477-
3478-
if (z->percpu_drift_mark && free_pages < z->percpu_drift_mark)
3479-
free_pages = zone_page_state_snapshot(z, NR_FREE_PAGES);
3480-
3481-
return __zone_watermark_ok(z, order, mark, highest_zoneidx, 0,
3482-
free_pages);
3483-
}
3484-
34853473
#ifdef CONFIG_NUMA
34863474
int __read_mostly node_reclaim_distance = RECLAIM_DISTANCE;
34873475

@@ -7191,6 +7179,11 @@ static DEFINE_STATIC_KEY_FALSE(zones_with_unaccepted_pages);
71917179

71927180
static bool lazy_accept = true;
71937181

7182+
void unaccepted_cleanup_work(struct work_struct *work)
7183+
{
7184+
static_branch_dec(&zones_with_unaccepted_pages);
7185+
}
7186+
71947187
static int __init accept_memory_parse(char *p)
71957188
{
71967189
if (!strcmp(p, "lazy")) {
@@ -7229,8 +7222,27 @@ static void __accept_page(struct zone *zone, unsigned long *flags,
72297222

72307223
__free_pages_ok(page, MAX_PAGE_ORDER, FPI_TO_TAIL);
72317224

7232-
if (last)
7233-
static_branch_dec(&zones_with_unaccepted_pages);
7225+
if (last) {
7226+
/*
7227+
* There are two corner cases:
7228+
*
7229+
* - If allocation occurs during the CPU bring up,
7230+
* static_branch_dec() cannot be used directly as
7231+
* it causes a deadlock on cpu_hotplug_lock.
7232+
*
7233+
* Instead, use schedule_work() to prevent deadlock.
7234+
*
7235+
* - If allocation occurs before workqueues are initialized,
7236+
* static_branch_dec() should be called directly.
7237+
*
7238+
* Workqueues are initialized before CPU bring up, so this
7239+
* will not conflict with the first scenario.
7240+
*/
7241+
if (system_wq)
7242+
schedule_work(&zone->unaccepted_cleanup);
7243+
else
7244+
unaccepted_cleanup_work(&zone->unaccepted_cleanup);
7245+
}
72347246
}
72357247

72367248
void accept_page(struct page *page)

mm/vmscan.c

+26-3
Original file line numberDiff line numberDiff line change
@@ -6736,6 +6736,7 @@ static bool pgdat_balanced(pg_data_t *pgdat, int order, int highest_zoneidx)
67366736
* meet watermarks.
67376737
*/
67386738
for_each_managed_zone_pgdat(zone, pgdat, i, highest_zoneidx) {
6739+
enum zone_stat_item item;
67396740
unsigned long free_pages;
67406741

67416742
if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING)
@@ -6746,11 +6747,33 @@ static bool pgdat_balanced(pg_data_t *pgdat, int order, int highest_zoneidx)
67466747
/*
67476748
* In defrag_mode, watermarks must be met in whole
67486749
* blocks to avoid polluting allocator fallbacks.
6750+
*
6751+
* However, kswapd usually cannot accomplish this on
6752+
* its own and needs kcompactd support. Once it's
6753+
* reclaimed a compaction gap, and kswapd_shrink_node
6754+
* has dropped order, simply ensure there are enough
6755+
* base pages for compaction, wake kcompactd & sleep.
67496756
*/
6750-
if (defrag_mode)
6751-
free_pages = zone_page_state(zone, NR_FREE_PAGES_BLOCKS);
6757+
if (defrag_mode && order)
6758+
item = NR_FREE_PAGES_BLOCKS;
67526759
else
6753-
free_pages = zone_page_state(zone, NR_FREE_PAGES);
6760+
item = NR_FREE_PAGES;
6761+
6762+
/*
6763+
* When there is a high number of CPUs in the system,
6764+
* the cumulative error from the vmstat per-cpu cache
6765+
* can blur the line between the watermarks. In that
6766+
* case, be safe and get an accurate snapshot.
6767+
*
6768+
* TODO: NR_FREE_PAGES_BLOCKS moves in steps of
6769+
* pageblock_nr_pages, while the vmstat pcp threshold
6770+
* is limited to 125. On many configurations that
6771+
* counter won't actually be per-cpu cached. But keep
6772+
* things simple for now; revisit when somebody cares.
6773+
*/
6774+
free_pages = zone_page_state(zone, item);
6775+
if (zone->percpu_drift_mark && free_pages < zone->percpu_drift_mark)
6776+
free_pages = zone_page_state_snapshot(zone, item);
67546777

67556778
if (__zone_watermark_ok(zone, order, mark, highest_zoneidx,
67566779
0, free_pages))

0 commit comments

Comments
 (0)