Skip to content

Commit 8291eaa

Browse files
committed
Merge tag 'mm-stable-2022-05-27' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull more MM updates from Andrew Morton: - Two follow-on fixes for the post-5.19 series "Use pageblock_order for cma and alloc_contig_range alignment", from Zi Yan. - A series of z3fold cleanups and fixes from Miaohe Lin. - Some memcg selftests work from Michal Koutný <mkoutny@suse.com> - Some swap fixes and cleanups from Miaohe Lin - Several individual minor fixups * tag 'mm-stable-2022-05-27' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (25 commits) mm/shmem.c: suppress shift warning mm: Kconfig: reorganize misplaced mm options mm: kasan: fix input of vmalloc_to_page() mm: fix is_pinnable_page against a cma page mm: filter out swapin error entry in shmem mapping mm/shmem: fix infinite loop when swap in shmem error at swapoff time mm/madvise: free hwpoison and swapin error entry in madvise_free_pte_range mm/swapfile: fix lost swap bits in unuse_pte() mm/swapfile: unuse_pte can map random data if swap read fails selftests: memcg: factor out common parts of memory.{low,min} tests selftests: memcg: remove protection from top level memcg selftests: memcg: adjust expected reclaim values of protected cgroups selftests: memcg: expect no low events in unprotected sibling selftests: memcg: fix compilation mm/z3fold: fix z3fold_page_migrate races with z3fold_map mm/z3fold: fix z3fold_reclaim_page races with z3fold_free mm/z3fold: always clear PAGE_CLAIMED under z3fold page lock mm/z3fold: put z3fold page back into unbuddied list when reclaim or migration fails revert "mm/z3fold.c: allow __GFP_HIGHMEM in z3fold_alloc" mm/z3fold: throw warning on failure of trylock_page in z3fold_alloc ...
2 parents 77fb622 + fa020a2 commit 8291eaa

20 files changed

Lines changed: 436 additions & 364 deletions

File tree

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5062,6 +5062,7 @@ L: linux-mm@kvack.org
50625062
S: Maintained
50635063
F: mm/memcontrol.c
50645064
F: mm/swap_cgroup.c
5065+
F: tools/testing/selftests/cgroup/memcg_protection.m
50655066
F: tools/testing/selftests/cgroup/test_kmem.c
50665067
F: tools/testing/selftests/cgroup/test_memcontrol.c
50675068

include/linux/mm.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,8 +1594,13 @@ static inline bool page_needs_cow_for_dma(struct vm_area_struct *vma,
15941594
#ifdef CONFIG_MIGRATION
15951595
static inline bool is_pinnable_page(struct page *page)
15961596
{
1597-
return !(is_zone_movable_page(page) || is_migrate_cma_page(page)) ||
1598-
is_zero_pfn(page_to_pfn(page));
1597+
#ifdef CONFIG_CMA
1598+
int mt = get_pageblock_migratetype(page);
1599+
1600+
if (mt == MIGRATE_CMA || mt == MIGRATE_ISOLATE)
1601+
return false;
1602+
#endif
1603+
return !(is_zone_movable_page(page) || is_zero_pfn(page_to_pfn(page)));
15991604
}
16001605
#else
16011606
static inline bool is_pinnable_page(struct page *page)

include/linux/swap.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ static inline int current_is_kswapd(void)
5555
* actions on faults.
5656
*/
5757

58+
#define SWP_SWAPIN_ERROR_NUM 1
59+
#define SWP_SWAPIN_ERROR (MAX_SWAPFILES + SWP_HWPOISON_NUM + \
60+
SWP_MIGRATION_NUM + SWP_DEVICE_NUM + \
61+
SWP_PTE_MARKER_NUM)
5862
/*
5963
* PTE markers are used to persist information onto PTEs that are mapped with
6064
* file-backed memories. As its name "PTE" hints, it should only be applied to
@@ -120,7 +124,8 @@ static inline int current_is_kswapd(void)
120124

121125
#define MAX_SWAPFILES \
122126
((1 << MAX_SWAPFILES_SHIFT) - SWP_DEVICE_NUM - \
123-
SWP_MIGRATION_NUM - SWP_HWPOISON_NUM - SWP_PTE_MARKER_NUM)
127+
SWP_MIGRATION_NUM - SWP_HWPOISON_NUM - \
128+
SWP_PTE_MARKER_NUM - SWP_SWAPIN_ERROR_NUM)
124129

125130
/*
126131
* Magic header for a swap area. The first part of the union is

include/linux/swapops.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ static inline void *swp_to_radix_entry(swp_entry_t entry)
108108
return xa_mk_value(entry.val);
109109
}
110110

111+
static inline swp_entry_t make_swapin_error_entry(struct page *page)
112+
{
113+
return swp_entry(SWP_SWAPIN_ERROR, page_to_pfn(page));
114+
}
115+
116+
static inline int is_swapin_error_entry(swp_entry_t entry)
117+
{
118+
return swp_type(entry) == SWP_SWAPIN_ERROR;
119+
}
120+
111121
#if IS_ENABLED(CONFIG_DEVICE_PRIVATE)
112122
static inline swp_entry_t make_readable_device_private_entry(pgoff_t offset)
113123
{

init/Kconfig

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,60 +1842,6 @@ config DEBUG_PERF_USE_VMALLOC
18421842

18431843
endmenu
18441844

1845-
config VM_EVENT_COUNTERS
1846-
default y
1847-
bool "Enable VM event counters for /proc/vmstat" if EXPERT
1848-
help
1849-
VM event counters are needed for event counts to be shown.
1850-
This option allows the disabling of the VM event counters
1851-
on EXPERT systems. /proc/vmstat will only show page counts
1852-
if VM event counters are disabled.
1853-
1854-
config SLUB_DEBUG
1855-
default y
1856-
bool "Enable SLUB debugging support" if EXPERT
1857-
depends on SLUB && SYSFS
1858-
select STACKDEPOT if STACKTRACE_SUPPORT
1859-
help
1860-
SLUB has extensive debug support features. Disabling these can
1861-
result in significant savings in code size. This also disables
1862-
SLUB sysfs support. /sys/slab will not exist and there will be
1863-
no support for cache validation etc.
1864-
1865-
config COMPAT_BRK
1866-
bool "Disable heap randomization"
1867-
default y
1868-
help
1869-
Randomizing heap placement makes heap exploits harder, but it
1870-
also breaks ancient binaries (including anything libc5 based).
1871-
This option changes the bootup default to heap randomization
1872-
disabled, and can be overridden at runtime by setting
1873-
/proc/sys/kernel/randomize_va_space to 2.
1874-
1875-
On non-ancient distros (post-2000 ones) N is usually a safe choice.
1876-
1877-
config MMAP_ALLOW_UNINITIALIZED
1878-
bool "Allow mmapped anonymous memory to be uninitialized"
1879-
depends on EXPERT && !MMU
1880-
default n
1881-
help
1882-
Normally, and according to the Linux spec, anonymous memory obtained
1883-
from mmap() has its contents cleared before it is passed to
1884-
userspace. Enabling this config option allows you to request that
1885-
mmap() skip that if it is given an MAP_UNINITIALIZED flag, thus
1886-
providing a huge performance boost. If this option is not enabled,
1887-
then the flag will be ignored.
1888-
1889-
This is taken advantage of by uClibc's malloc(), and also by
1890-
ELF-FDPIC binfmt's brk and stack allocator.
1891-
1892-
Because of the obvious security issues, this option should only be
1893-
enabled on embedded devices where you control what is run in
1894-
userspace. Since that isn't generally a problem on no-MMU systems,
1895-
it is normally safe to say Y here.
1896-
1897-
See Documentation/admin-guide/mm/nommu-mmap.rst for more information.
1898-
18991845
config SYSTEM_DATA_VERIFICATION
19001846
def_bool n
19011847
select SYSTEM_TRUSTED_KEYRING

lib/Kconfig.debug

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -699,41 +699,6 @@ config DEBUG_OBJECTS_ENABLE_DEFAULT
699699
help
700700
Debug objects boot parameter default value
701701

702-
config DEBUG_SLAB
703-
bool "Debug slab memory allocations"
704-
depends on DEBUG_KERNEL && SLAB
705-
help
706-
Say Y here to have the kernel do limited verification on memory
707-
allocation as well as poisoning memory on free to catch use of freed
708-
memory. This can make kmalloc/kfree-intensive workloads much slower.
709-
710-
config SLUB_DEBUG_ON
711-
bool "SLUB debugging on by default"
712-
depends on SLUB && SLUB_DEBUG
713-
select STACKDEPOT_ALWAYS_INIT if STACKTRACE_SUPPORT
714-
default n
715-
help
716-
Boot with debugging on by default. SLUB boots by default with
717-
the runtime debug capabilities switched off. Enabling this is
718-
equivalent to specifying the "slub_debug" parameter on boot.
719-
There is no support for more fine grained debug control like
720-
possible with slub_debug=xxx. SLUB debugging may be switched
721-
off in a kernel built with CONFIG_SLUB_DEBUG_ON by specifying
722-
"slub_debug=-".
723-
724-
config SLUB_STATS
725-
default n
726-
bool "Enable SLUB performance statistics"
727-
depends on SLUB && SYSFS
728-
help
729-
SLUB statistics are useful to debug SLUBs allocation behavior in
730-
order find ways to optimize the allocator. This should never be
731-
enabled for production use since keeping statistics slows down
732-
the allocator by a few percentage points. The slabinfo command
733-
supports the determination of the most active slabs to figure
734-
out which slabs are relevant to a particular load.
735-
Try running: slabinfo -DA
736-
737702
config HAVE_DEBUG_KMEMLEAK
738703
bool
739704

mm/Kconfig

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,19 @@ config SLAB_FREELIST_HARDENED
270270
sanity-checking than others. This option is most effective with
271271
CONFIG_SLUB.
272272

273+
config SLUB_STATS
274+
default n
275+
bool "Enable SLUB performance statistics"
276+
depends on SLUB && SYSFS
277+
help
278+
SLUB statistics are useful to debug SLUBs allocation behavior in
279+
order find ways to optimize the allocator. This should never be
280+
enabled for production use since keeping statistics slows down
281+
the allocator by a few percentage points. The slabinfo command
282+
supports the determination of the most active slabs to figure
283+
out which slabs are relevant to a particular load.
284+
Try running: slabinfo -DA
285+
273286
config SLUB_CPU_PARTIAL
274287
default y
275288
depends on SLUB && SMP
@@ -307,6 +320,40 @@ config SHUFFLE_PAGE_ALLOCATOR
307320

308321
Say Y if unsure.
309322

323+
config COMPAT_BRK
324+
bool "Disable heap randomization"
325+
default y
326+
help
327+
Randomizing heap placement makes heap exploits harder, but it
328+
also breaks ancient binaries (including anything libc5 based).
329+
This option changes the bootup default to heap randomization
330+
disabled, and can be overridden at runtime by setting
331+
/proc/sys/kernel/randomize_va_space to 2.
332+
333+
On non-ancient distros (post-2000 ones) N is usually a safe choice.
334+
335+
config MMAP_ALLOW_UNINITIALIZED
336+
bool "Allow mmapped anonymous memory to be uninitialized"
337+
depends on EXPERT && !MMU
338+
default n
339+
help
340+
Normally, and according to the Linux spec, anonymous memory obtained
341+
from mmap() has its contents cleared before it is passed to
342+
userspace. Enabling this config option allows you to request that
343+
mmap() skip that if it is given an MAP_UNINITIALIZED flag, thus
344+
providing a huge performance boost. If this option is not enabled,
345+
then the flag will be ignored.
346+
347+
This is taken advantage of by uClibc's malloc(), and also by
348+
ELF-FDPIC binfmt's brk and stack allocator.
349+
350+
Because of the obvious security issues, this option should only be
351+
enabled on embedded devices where you control what is run in
352+
userspace. Since that isn't generally a problem on no-MMU systems,
353+
it is normally safe to say Y here.
354+
355+
See Documentation/admin-guide/mm/nommu-mmap.rst for more information.
356+
310357
config SELECT_MEMORY_MODEL
311358
def_bool y
312359
depends on ARCH_SELECT_MEMORY_MODEL
@@ -964,6 +1011,15 @@ config ARCH_USES_HIGH_VMA_FLAGS
9641011
config ARCH_HAS_PKEYS
9651012
bool
9661013

1014+
config VM_EVENT_COUNTERS
1015+
default y
1016+
bool "Enable VM event counters for /proc/vmstat" if EXPERT
1017+
help
1018+
VM event counters are needed for event counts to be shown.
1019+
This option allows the disabling of the VM event counters
1020+
on EXPERT systems. /proc/vmstat will only show page counts
1021+
if VM event counters are disabled.
1022+
9671023
config PERCPU_STATS
9681024
bool "Collect percpu memory statistics"
9691025
help

mm/Kconfig.debug

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,39 @@ config DEBUG_PAGEALLOC_ENABLE_DEFAULT
4545
Enable debug page memory allocations by default? This value
4646
can be overridden by debug_pagealloc=off|on.
4747

48+
config DEBUG_SLAB
49+
bool "Debug slab memory allocations"
50+
depends on DEBUG_KERNEL && SLAB
51+
help
52+
Say Y here to have the kernel do limited verification on memory
53+
allocation as well as poisoning memory on free to catch use of freed
54+
memory. This can make kmalloc/kfree-intensive workloads much slower.
55+
56+
config SLUB_DEBUG
57+
default y
58+
bool "Enable SLUB debugging support" if EXPERT
59+
depends on SLUB && SYSFS
60+
select STACKDEPOT if STACKTRACE_SUPPORT
61+
help
62+
SLUB has extensive debug support features. Disabling these can
63+
result in significant savings in code size. This also disables
64+
SLUB sysfs support. /sys/slab will not exist and there will be
65+
no support for cache validation etc.
66+
67+
config SLUB_DEBUG_ON
68+
bool "SLUB debugging on by default"
69+
depends on SLUB && SLUB_DEBUG
70+
select STACKDEPOT_ALWAYS_INIT if STACKTRACE_SUPPORT
71+
default n
72+
help
73+
Boot with debugging on by default. SLUB boots by default with
74+
the runtime debug capabilities switched off. Enabling this is
75+
equivalent to specifying the "slub_debug" parameter on boot.
76+
There is no support for more fine grained debug control like
77+
possible with slub_debug=xxx. SLUB debugging may be switched
78+
off in a kernel built with CONFIG_SLUB_DEBUG_ON by specifying
79+
"slub_debug=-".
80+
4881
config PAGE_OWNER
4982
bool "Track page owner"
5083
depends on DEBUG_KERNEL && STACKTRACE_SUPPORT

mm/internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ extern void *memmap_alloc(phys_addr_t size, phys_addr_t align,
374374
phys_addr_t min_addr,
375375
int nid, bool exact_nid);
376376

377-
void split_free_page(struct page *free_page,
378-
int order, unsigned long split_pfn_offset);
377+
int split_free_page(struct page *free_page,
378+
unsigned int order, unsigned long split_pfn_offset);
379379

380380
#if defined CONFIG_COMPACTION || defined CONFIG_CMA
381381

mm/kasan/report.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ static void print_address_description(void *addr, u8 tag)
347347
va->addr, va->addr + va->size, va->caller);
348348
pr_err("\n");
349349

350-
page = vmalloc_to_page(page);
350+
page = vmalloc_to_page(addr);
351351
}
352352
}
353353

0 commit comments

Comments
 (0)