Skip to content

Commit 4c48fab

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge misc updates from Andrew Morton: "A few small subsystems and some of MM. 172 patches. Subsystems affected by this patch series: hexagon, scripts, ntfs, ocfs2, vfs, and mm (slab-generic, slab, slub, debug, pagecache, swap, memcg, pagemap, mprotect, mremap, page-reporting, vmalloc, kasan, pagealloc, memory-failure, hugetlb, vmscan, z3fold, compaction, mempolicy, oom-kill, hugetlbfs, and migration)" * emailed patches from Andrew Morton <[email protected]>: (172 commits) mm/migrate: remove unneeded semicolons hugetlbfs: remove unneeded return value of hugetlb_vmtruncate() hugetlbfs: fix some comment typos hugetlbfs: correct some obsolete comments about inode i_mutex hugetlbfs: make hugepage size conversion more readable hugetlbfs: remove meaningless variable avoid_reserve hugetlbfs: correct obsolete function name in hugetlbfs_read_iter() hugetlbfs: use helper macro default_hstate in init_hugetlbfs_fs hugetlbfs: remove useless BUG_ON(!inode) in hugetlbfs_setattr() hugetlbfs: remove special hugetlbfs_set_page_dirty() mm/hugetlb: change hugetlb_reserve_pages() to type bool mm, oom: fix a comment in dump_task() mm/mempolicy: use helper range_in_vma() in queue_pages_test_walk() numa balancing: migrate on fault among multiple bound nodes mm, compaction: make fast_isolate_freepages() stay within zone mm/compaction: fix misbehaviors of fast_find_migrateblock() mm/compaction: correct deferral logic for proactive compaction mm/compaction: remove duplicated VM_BUG_ON_PAGE !PageLocked mm/compaction: remove rcu_read_lock during page compaction z3fold: simplify the zhdr initialization code in init_z3fold_page() ...
2 parents 062c84f + a553e3c commit 4c48fab

File tree

117 files changed

+2027
-1734
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+2027
-1734
lines changed

Documentation/admin-guide/cgroup-v2.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,10 @@ PAGE_SIZE multiple when read back.
12991299
Amount of cached filesystem data that was modified and
13001300
is currently being written back to disk
13011301

1302+
swapcached
1303+
Amount of swap cached in memory. The swapcache is accounted
1304+
against both memory and swap usage.
1305+
13021306
anon_thp
13031307
Amount of memory used in anonymous mappings backed by
13041308
transparent hugepages

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4904,14 +4904,6 @@
49044904
last alloc / free. For more information see
49054905
Documentation/vm/slub.rst.
49064906

4907-
slub_memcg_sysfs= [MM, SLUB]
4908-
Determines whether to enable sysfs directories for
4909-
memory cgroup sub-caches. 1 to enable, 0 to disable.
4910-
The default is determined by CONFIG_SLUB_MEMCG_SYSFS_ON.
4911-
Enabling this can lead to a very high number of debug
4912-
directories and files being created under
4913-
/sys/kernel/slub.
4914-
49154907
slub_max_order= [MM, SLUB]
49164908
Determines the maximum allowed order for slabs.
49174909
A high setting may cause OOMs due to memory

Documentation/admin-guide/sysctl/vm.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -983,11 +983,11 @@ that benefit from having their data cached, zone_reclaim_mode should be
983983
left disabled as the caching effect is likely to be more important than
984984
data locality.
985985

986-
zone_reclaim may be enabled if it's known that the workload is partitioned
987-
such that each partition fits within a NUMA node and that accessing remote
988-
memory would cause a measurable performance reduction. The page allocator
989-
will then reclaim easily reusable pages (those page cache pages that are
990-
currently not used) before allocating off node pages.
986+
Consider enabling one or more zone_reclaim mode bits if it's known that the
987+
workload is partitioned such that each partition fits within a NUMA node
988+
and that accessing remote memory would cause a measurable performance
989+
reduction. The page allocator will take additional actions before
990+
allocating off node pages.
991991

992992
Allowing zone reclaim to write out pages stops processes that are
993993
writing large amounts of data from dirtying pages on other nodes. Zone

Documentation/core-api/mm-api.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ User Space Memory Access
1919
Memory Allocation Controls
2020
==========================
2121

22-
Functions which need to allocate memory often use GFP flags to express
23-
how that memory should be allocated. The GFP acronym stands for "get
24-
free pages", the underlying memory allocation function. Not every GFP
25-
flag is allowed to every function which may allocate memory. Most
26-
users will want to use a plain ``GFP_KERNEL``.
22+
.. kernel-doc:: include/linux/gfp.h
23+
:internal:
2724

2825
.. kernel-doc:: include/linux/gfp.h
2926
:doc: Page mobility and placement hints

Documentation/dev-tools/kasan.rst

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,14 @@ negative values to distinguish between different kinds of inaccessible memory
147147
like redzones or freed memory (see mm/kasan/kasan.h).
148148

149149
In the report above the arrows point to the shadow byte 03, which means that
150-
the accessed address is partially accessible.
151-
152-
For tag-based KASAN this last report section shows the memory tags around the
153-
accessed address (see `Implementation details`_ section).
150+
the accessed address is partially accessible. For tag-based KASAN modes this
151+
last report section shows the memory tags around the accessed address
152+
(see the `Implementation details`_ section).
154153

155154
Boot parameters
156155
~~~~~~~~~~~~~~~
157156

158-
Hardware tag-based KASAN mode (see the section about different mode below) is
157+
Hardware tag-based KASAN mode (see the section about various modes below) is
159158
intended for use in production as a security mitigation. Therefore it supports
160159
boot parameters that allow to disable KASAN competely or otherwise control
161160
particular KASAN features.
@@ -289,6 +288,13 @@ reserved to tag freed memory regions.
289288
Hardware tag-based KASAN currently only supports tagging of
290289
kmem_cache_alloc/kmalloc and page_alloc memory.
291290

291+
If the hardware doesn't support MTE (pre ARMv8.5), hardware tag-based KASAN
292+
won't be enabled. In this case all boot parameters are ignored.
293+
294+
Note, that enabling CONFIG_KASAN_HW_TAGS always results in in-kernel TBI being
295+
enabled. Even when kasan.mode=off is provided, or when the hardware doesn't
296+
support MTE (but supports TBI).
297+
292298
What memory accesses are sanitised by KASAN?
293299
--------------------------------------------
294300

@@ -352,17 +358,17 @@ unmapped. This will require changes in arch-specific code.
352358
This allows ``VMAP_STACK`` support on x86, and can simplify support of
353359
architectures that do not have a fixed module region.
354360

355-
CONFIG_KASAN_KUNIT_TEST & CONFIG_TEST_KASAN_MODULE
356-
--------------------------------------------------
361+
CONFIG_KASAN_KUNIT_TEST and CONFIG_KASAN_MODULE_TEST
362+
----------------------------------------------------
357363

358-
KASAN tests consist on two parts:
364+
KASAN tests consist of two parts:
359365

360366
1. Tests that are integrated with the KUnit Test Framework. Enabled with
361367
``CONFIG_KASAN_KUNIT_TEST``. These tests can be run and partially verified
362368
automatically in a few different ways, see the instructions below.
363369

364370
2. Tests that are currently incompatible with KUnit. Enabled with
365-
``CONFIG_TEST_KASAN_MODULE`` and can only be run as a module. These tests can
371+
``CONFIG_KASAN_MODULE_TEST`` and can only be run as a module. These tests can
366372
only be verified manually, by loading the kernel module and inspecting the
367373
kernel log for KASAN reports.
368374

Documentation/vm/arch_pgtable_helpers.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ PTE Page Table Helpers
5050
+---------------------------+--------------------------------------------------+
5151
| pte_mkwrite | Creates a writable PTE |
5252
+---------------------------+--------------------------------------------------+
53-
| pte_mkwrprotect | Creates a write protected PTE |
53+
| pte_wrprotect | Creates a write protected PTE |
5454
+---------------------------+--------------------------------------------------+
5555
| pte_mkspecial | Creates a special PTE |
5656
+---------------------------+--------------------------------------------------+
@@ -120,7 +120,7 @@ PMD Page Table Helpers
120120
+---------------------------+--------------------------------------------------+
121121
| pmd_mkwrite | Creates a writable PMD |
122122
+---------------------------+--------------------------------------------------+
123-
| pmd_mkwrprotect | Creates a write protected PMD |
123+
| pmd_wrprotect | Creates a write protected PMD |
124124
+---------------------------+--------------------------------------------------+
125125
| pmd_mkspecial | Creates a special PMD |
126126
+---------------------------+--------------------------------------------------+
@@ -186,7 +186,7 @@ PUD Page Table Helpers
186186
+---------------------------+--------------------------------------------------+
187187
| pud_mkwrite | Creates a writable PUD |
188188
+---------------------------+--------------------------------------------------+
189-
| pud_mkwrprotect | Creates a write protected PUD |
189+
| pud_wrprotect | Creates a write protected PUD |
190190
+---------------------------+--------------------------------------------------+
191191
| pud_mkdevmap | Creates a ZONE_DEVICE mapped PUD |
192192
+---------------------------+--------------------------------------------------+
@@ -224,7 +224,7 @@ HugeTLB Page Table Helpers
224224
+---------------------------+--------------------------------------------------+
225225
| huge_pte_mkwrite | Creates a writable HugeTLB |
226226
+---------------------------+--------------------------------------------------+
227-
| huge_pte_mkwrprotect | Creates a write protected HugeTLB |
227+
| huge_pte_wrprotect | Creates a write protected HugeTLB |
228228
+---------------------------+--------------------------------------------------+
229229
| huge_ptep_get_and_clear | Clears a HugeTLB |
230230
+---------------------------+--------------------------------------------------+

arch/arm64/include/asm/memory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ static inline const void *__tag_set(const void *addr, u8 tag)
244244

245245
#ifdef CONFIG_KASAN_HW_TAGS
246246
#define arch_enable_tagging() mte_enable_kernel()
247+
#define arch_set_tagging_report_once(state) mte_set_report_once(state)
247248
#define arch_init_tags(max_tag) mte_init_tags(max_tag)
248249
#define arch_get_random_tag() mte_get_random_tag()
249250
#define arch_get_mem_tag(addr) mte_get_mem_tag(addr)

arch/arm64/include/asm/mte-kasan.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ void *mte_set_mem_tag_range(void *addr, size_t size, u8 tag);
3232
void mte_enable_kernel(void);
3333
void mte_init_tags(u64 max_tag);
3434

35+
void mte_set_report_once(bool state);
36+
bool mte_report_once(void);
37+
3538
#else /* CONFIG_ARM64_MTE */
3639

3740
static inline u8 mte_get_ptr_tag(void *ptr)
@@ -60,6 +63,15 @@ static inline void mte_init_tags(u64 max_tag)
6063
{
6164
}
6265

66+
static inline void mte_set_report_once(bool state)
67+
{
68+
}
69+
70+
static inline bool mte_report_once(void)
71+
{
72+
return false;
73+
}
74+
6375
#endif /* CONFIG_ARM64_MTE */
6476

6577
#endif /* __ASSEMBLY__ */

arch/arm64/kernel/mte.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
u64 gcr_kernel_excl __ro_after_init;
2727

28+
static bool report_fault_once = true;
29+
2830
static void mte_sync_page_tags(struct page *page, pte_t *ptep, bool check_swap)
2931
{
3032
pte_t old_pte = READ_ONCE(*ptep);
@@ -158,6 +160,16 @@ void mte_enable_kernel(void)
158160
isb();
159161
}
160162

163+
void mte_set_report_once(bool state)
164+
{
165+
WRITE_ONCE(report_fault_once, state);
166+
}
167+
168+
bool mte_report_once(void)
169+
{
170+
return READ_ONCE(report_fault_once);
171+
}
172+
161173
static void update_sctlr_el1_tcf0(u64 tcf0)
162174
{
163175
/* ISB required for the kernel uaccess routines */

arch/arm64/mm/fault.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,24 @@ static void die_kernel_fault(const char *msg, unsigned long addr,
302302
static void report_tag_fault(unsigned long addr, unsigned int esr,
303303
struct pt_regs *regs)
304304
{
305-
bool is_write = ((esr & ESR_ELx_WNR) >> ESR_ELx_WNR_SHIFT) != 0;
305+
static bool reported;
306+
bool is_write;
307+
308+
if (READ_ONCE(reported))
309+
return;
310+
311+
/*
312+
* This is used for KASAN tests and assumes that no MTE faults
313+
* happened before running the tests.
314+
*/
315+
if (mte_report_once())
316+
WRITE_ONCE(reported, true);
306317

307318
/*
308319
* SAS bits aren't set for all faults reported in EL1, so we can't
309320
* find out access size.
310321
*/
322+
is_write = !!(esr & ESR_ELx_WNR);
311323
kasan_report(addr, 0, is_write, regs->pc);
312324
}
313325
#else
@@ -319,12 +331,8 @@ static inline void report_tag_fault(unsigned long addr, unsigned int esr,
319331
static void do_tag_recovery(unsigned long addr, unsigned int esr,
320332
struct pt_regs *regs)
321333
{
322-
static bool reported;
323334

324-
if (!READ_ONCE(reported)) {
325-
report_tag_fault(addr, esr, regs);
326-
WRITE_ONCE(reported, true);
327-
}
335+
report_tag_fault(addr, esr, regs);
328336

329337
/*
330338
* Disable MTE Tag Checking on the local CPU for the current EL.

0 commit comments

Comments
 (0)