Skip to content

Commit 8f6f76a

Browse files
committed
Merge tag 'mm-nonmm-stable-2023-11-02-14-08' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull non-MM updates from Andrew Morton: "As usual, lots of singleton and doubleton patches all over the tree and there's little I can say which isn't in the individual changelogs. The lengthier patch series are - 'kdump: use generic functions to simplify crashkernel reservation in arch', from Baoquan He. This is mainly cleanups and consolidation of the 'crashkernel=' kernel parameter handling - After much discussion, David Laight's 'minmax: Relax type checks in min() and max()' is here. Hopefully reduces some typecasting and the use of min_t() and max_t() - A group of patches from Oleg Nesterov which clean up and slightly fix our handling of reads from /proc/PID/task/... and which remove task_struct.thread_group" * tag 'mm-nonmm-stable-2023-11-02-14-08' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (64 commits) scripts/gdb/vmalloc: disable on no-MMU scripts/gdb: fix usage of MOD_TEXT not defined when CONFIG_MODULES=n .mailmap: add address mapping for Tomeu Vizoso mailmap: update email address for Claudiu Beznea tools/testing/selftests/mm/run_vmtests.sh: lower the ptrace permissions .mailmap: map Benjamin Poirier's address scripts/gdb: add lx_current support for riscv ocfs2: fix a spelling typo in comment proc: test ProtectionKey in proc-empty-vm test proc: fix proc-empty-vm test with vsyscall fs/proc/base.c: remove unneeded semicolon do_io_accounting: use sig->stats_lock do_io_accounting: use __for_each_thread() ocfs2: replace BUG_ON() at ocfs2_num_free_extents() with ocfs2_error() ocfs2: fix a typo in a comment scripts/show_delta: add __main__ judgement before main code treewide: mark stuff as __ro_after_init fs: ocfs2: check status values proc: test /proc/${pid}/statm compiler.h: move __is_constexpr() to compiler.h ...
2 parents ecae0bd + 6620999 commit 8f6f76a

File tree

106 files changed

+894
-1000
lines changed

Some content is hidden

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

106 files changed

+894
-1000
lines changed

.mailmap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Ben M Cahill <[email protected]>
9595
9696
9797
98+
9899
99100
100101
@@ -128,6 +129,7 @@ Christian Brauner <[email protected]> <[email protected]>
128129
Christian Marangi <[email protected]>
129130
Christophe Ricard <[email protected]>
130131
Christoph Hellwig <[email protected]>
132+
131133
132134
Corey Minyard <[email protected]>
133135
Damian Hobson-Garcia <[email protected]>
@@ -568,6 +570,7 @@ Takashi YOSHII <[email protected]>
568570
Tamizh Chelvam Raja <[email protected]> <[email protected]>
569571
570572
Tejun Heo <[email protected]>
573+
571574
Thomas Graf <[email protected]>
572575
573576
Thomas Pedersen <[email protected]>

arch/arm/kernel/setup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,8 @@ static void __init reserve_crashkernel(void)
10101010

10111011
total_mem = get_total_mem();
10121012
ret = parse_crashkernel(boot_command_line, total_mem,
1013-
&crash_size, &crash_base);
1013+
&crash_size, &crash_base,
1014+
NULL, NULL);
10141015
/* invalid value specified or crashkernel=0 */
10151016
if (ret || !crash_size)
10161017
return;

arch/arm64/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,9 @@ config ARCH_DEFAULT_KEXEC_IMAGE_VERIFY_SIG
14981498
config ARCH_SUPPORTS_CRASH_DUMP
14991499
def_bool y
15001500

1501+
config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION
1502+
def_bool CRASH_CORE
1503+
15011504
config TRANS_TABLE
15021505
def_bool y
15031506
depends on HIBERNATION || KEXEC_CORE

arch/arm64/include/asm/crash_core.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
#ifndef _ARM64_CRASH_CORE_H
3+
#define _ARM64_CRASH_CORE_H
4+
5+
/* Current arm64 boot protocol requires 2MB alignment */
6+
#define CRASH_ALIGN SZ_2M
7+
8+
#define CRASH_ADDR_LOW_MAX arm64_dma_phys_limit
9+
#define CRASH_ADDR_HIGH_MAX (PHYS_MASK + 1)
10+
#endif

arch/arm64/mm/init.c

Lines changed: 8 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,6 @@ EXPORT_SYMBOL(memstart_addr);
6565
*/
6666
phys_addr_t __ro_after_init arm64_dma_phys_limit;
6767

68-
/* Current arm64 boot protocol requires 2MB alignment */
69-
#define CRASH_ALIGN SZ_2M
70-
71-
#define CRASH_ADDR_LOW_MAX arm64_dma_phys_limit
72-
#define CRASH_ADDR_HIGH_MAX (PHYS_MASK + 1)
73-
#define CRASH_HIGH_SEARCH_BASE SZ_4G
74-
75-
#define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20)
76-
7768
/*
7869
* To make optimal use of block mappings when laying out the linear
7970
* mapping, round down the base of physical memory to a size that can
@@ -101,140 +92,25 @@ phys_addr_t __ro_after_init arm64_dma_phys_limit;
10192
#define ARM64_MEMSTART_ALIGN (1UL << ARM64_MEMSTART_SHIFT)
10293
#endif
10394

104-
static int __init reserve_crashkernel_low(unsigned long long low_size)
105-
{
106-
unsigned long long low_base;
107-
108-
low_base = memblock_phys_alloc_range(low_size, CRASH_ALIGN, 0, CRASH_ADDR_LOW_MAX);
109-
if (!low_base) {
110-
pr_err("cannot allocate crashkernel low memory (size:0x%llx).\n", low_size);
111-
return -ENOMEM;
112-
}
113-
114-
pr_info("crashkernel low memory reserved: 0x%08llx - 0x%08llx (%lld MB)\n",
115-
low_base, low_base + low_size, low_size >> 20);
116-
117-
crashk_low_res.start = low_base;
118-
crashk_low_res.end = low_base + low_size - 1;
119-
insert_resource(&iomem_resource, &crashk_low_res);
120-
121-
return 0;
122-
}
123-
124-
/*
125-
* reserve_crashkernel() - reserves memory for crash kernel
126-
*
127-
* This function reserves memory area given in "crashkernel=" kernel command
128-
* line parameter. The memory reserved is used by dump capture kernel when
129-
* primary kernel is crashing.
130-
*/
131-
static void __init reserve_crashkernel(void)
95+
static void __init arch_reserve_crashkernel(void)
13296
{
133-
unsigned long long crash_low_size = 0, search_base = 0;
134-
unsigned long long crash_max = CRASH_ADDR_LOW_MAX;
97+
unsigned long long low_size = 0;
13598
unsigned long long crash_base, crash_size;
13699
char *cmdline = boot_command_line;
137-
bool fixed_base = false;
138100
bool high = false;
139101
int ret;
140102

141103
if (!IS_ENABLED(CONFIG_KEXEC_CORE))
142104
return;
143105

144-
/* crashkernel=X[@offset] */
145106
ret = parse_crashkernel(cmdline, memblock_phys_mem_size(),
146-
&crash_size, &crash_base);
147-
if (ret == -ENOENT) {
148-
ret = parse_crashkernel_high(cmdline, 0, &crash_size, &crash_base);
149-
if (ret || !crash_size)
150-
return;
151-
152-
/*
153-
* crashkernel=Y,low can be specified or not, but invalid value
154-
* is not allowed.
155-
*/
156-
ret = parse_crashkernel_low(cmdline, 0, &crash_low_size, &crash_base);
157-
if (ret == -ENOENT)
158-
crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE;
159-
else if (ret)
160-
return;
161-
162-
search_base = CRASH_HIGH_SEARCH_BASE;
163-
crash_max = CRASH_ADDR_HIGH_MAX;
164-
high = true;
165-
} else if (ret || !crash_size) {
166-
/* The specified value is invalid */
107+
&crash_size, &crash_base,
108+
&low_size, &high);
109+
if (ret)
167110
return;
168-
}
169-
170-
crash_size = PAGE_ALIGN(crash_size);
171-
172-
/* User specifies base address explicitly. */
173-
if (crash_base) {
174-
fixed_base = true;
175-
search_base = crash_base;
176-
crash_max = crash_base + crash_size;
177-
}
178-
179-
retry:
180-
crash_base = memblock_phys_alloc_range(crash_size, CRASH_ALIGN,
181-
search_base, crash_max);
182-
if (!crash_base) {
183-
/*
184-
* For crashkernel=size[KMG]@offset[KMG], print out failure
185-
* message if can't reserve the specified region.
186-
*/
187-
if (fixed_base) {
188-
pr_warn("crashkernel reservation failed - memory is in use.\n");
189-
return;
190-
}
191-
192-
/*
193-
* For crashkernel=size[KMG], if the first attempt was for
194-
* low memory, fall back to high memory, the minimum required
195-
* low memory will be reserved later.
196-
*/
197-
if (!high && crash_max == CRASH_ADDR_LOW_MAX) {
198-
crash_max = CRASH_ADDR_HIGH_MAX;
199-
search_base = CRASH_ADDR_LOW_MAX;
200-
crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE;
201-
goto retry;
202-
}
203-
204-
/*
205-
* For crashkernel=size[KMG],high, if the first attempt was
206-
* for high memory, fall back to low memory.
207-
*/
208-
if (high && crash_max == CRASH_ADDR_HIGH_MAX) {
209-
crash_max = CRASH_ADDR_LOW_MAX;
210-
search_base = 0;
211-
goto retry;
212-
}
213-
pr_warn("cannot allocate crashkernel (size:0x%llx)\n",
214-
crash_size);
215-
return;
216-
}
217-
218-
if ((crash_base >= CRASH_ADDR_LOW_MAX) && crash_low_size &&
219-
reserve_crashkernel_low(crash_low_size)) {
220-
memblock_phys_free(crash_base, crash_size);
221-
return;
222-
}
223-
224-
pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n",
225-
crash_base, crash_base + crash_size, crash_size >> 20);
226-
227-
/*
228-
* The crashkernel memory will be removed from the kernel linear
229-
* map. Inform kmemleak so that it won't try to access it.
230-
*/
231-
kmemleak_ignore_phys(crash_base);
232-
if (crashk_low_res.end)
233-
kmemleak_ignore_phys(crashk_low_res.start);
234111

235-
crashk_res.start = crash_base;
236-
crashk_res.end = crash_base + crash_size - 1;
237-
insert_resource(&iomem_resource, &crashk_res);
112+
reserve_crashkernel_generic(cmdline, crash_size, crash_base,
113+
low_size, high);
238114
}
239115

240116
/*
@@ -480,7 +356,7 @@ void __init bootmem_init(void)
480356
* request_standard_resources() depends on crashkernel's memory being
481357
* reserved, so do it here.
482358
*/
483-
reserve_crashkernel();
359+
arch_reserve_crashkernel();
484360

485361
memblock_dump_all();
486362
}

arch/loongarch/kernel/setup.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,9 @@ static void __init arch_parse_crashkernel(void)
267267
unsigned long long crash_base, crash_size;
268268

269269
total_mem = memblock_phys_mem_size();
270-
ret = parse_crashkernel(boot_command_line, total_mem, &crash_size, &crash_base);
270+
ret = parse_crashkernel(boot_command_line, total_mem,
271+
&crash_size, &crash_base,
272+
NULL, NULL);
271273
if (ret < 0 || crash_size <= 0)
272274
return;
273275

arch/mips/kernel/setup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ static void __init mips_parse_crashkernel(void)
460460

461461
total_mem = memblock_phys_mem_size();
462462
ret = parse_crashkernel(boot_command_line, total_mem,
463-
&crash_size, &crash_base);
463+
&crash_size, &crash_base,
464+
NULL, NULL);
464465
if (ret != 0 || crash_size <= 0)
465466
return;
466467

arch/powerpc/kernel/fadump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ static __init u64 fadump_calculate_reserve_size(void)
313313
* memory at a predefined offset.
314314
*/
315315
ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
316-
&size, &base);
316+
&size, &base, NULL, NULL);
317317
if (ret == 0 && size > 0) {
318318
unsigned long max_size;
319319

arch/powerpc/kexec/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void __init reserve_crashkernel(void)
109109
total_mem_sz = memory_limit ? memory_limit : memblock_phys_mem_size();
110110
/* use common parsing */
111111
ret = parse_crashkernel(boot_command_line, total_mem_sz,
112-
&crash_size, &crash_base);
112+
&crash_size, &crash_base, NULL, NULL);
113113
if (ret == 0 && crash_size > 0) {
114114
crashk_res.start = crash_base;
115115
crashk_res.end = crash_base + crash_size - 1;

arch/powerpc/mm/nohash/kaslr_booke.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static void __init get_crash_kernel(void *fdt, unsigned long size)
178178
int ret;
179179

180180
ret = parse_crashkernel(boot_command_line, size, &crash_size,
181-
&crash_base);
181+
&crash_base, NULL, NULL);
182182
if (ret != 0 || crash_size == 0)
183183
return;
184184
if (crash_base == 0)

arch/riscv/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,9 @@ config ARCH_SUPPORTS_KEXEC_PURGATORY
693693
config ARCH_SUPPORTS_CRASH_DUMP
694694
def_bool y
695695

696+
config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION
697+
def_bool CRASH_CORE
698+
696699
config COMPAT
697700
bool "Kernel support for 32-bit U-mode"
698701
default 64BIT

arch/riscv/include/asm/crash_core.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
#ifndef _RISCV_CRASH_CORE_H
3+
#define _RISCV_CRASH_CORE_H
4+
5+
#define CRASH_ALIGN PMD_SIZE
6+
7+
#define CRASH_ADDR_LOW_MAX dma32_phys_limit
8+
#define CRASH_ADDR_HIGH_MAX memblock_end_of_DRAM()
9+
10+
extern phys_addr_t memblock_end_of_DRAM(void);
11+
#endif

arch/riscv/include/asm/processor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ static inline void wait_for_interrupt(void)
116116
__asm__ __volatile__ ("wfi");
117117
}
118118

119+
extern phys_addr_t dma32_phys_limit;
120+
119121
struct device_node;
120122
int riscv_of_processor_hartid(struct device_node *node, unsigned long *hartid);
121123
int riscv_early_of_processor_hartid(struct device_node *node, unsigned long *hartid);

0 commit comments

Comments
 (0)