Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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
...

+920 -1026
+3
.mailmap
··· 95 95 Ben Widawsky <bwidawsk@kernel.org> <ben@bwidawsk.net> 96 96 Ben Widawsky <bwidawsk@kernel.org> <ben.widawsky@intel.com> 97 97 Ben Widawsky <bwidawsk@kernel.org> <benjamin.widawsky@intel.com> 98 + Benjamin Poirier <benjamin.poirier@gmail.com> <bpoirier@suse.de> 98 99 Bjorn Andersson <andersson@kernel.org> <bjorn@kryo.se> 99 100 Bjorn Andersson <andersson@kernel.org> <bjorn.andersson@linaro.org> 100 101 Bjorn Andersson <andersson@kernel.org> <bjorn.andersson@sonymobile.com> ··· 129 128 Christian Marangi <ansuelsmth@gmail.com> 130 129 Christophe Ricard <christophe.ricard@gmail.com> 131 130 Christoph Hellwig <hch@lst.de> 131 + Claudiu Beznea <claudiu.beznea@tuxon.dev> <claudiu.beznea@microchip.com> 132 132 Colin Ian King <colin.i.king@gmail.com> <colin.king@canonical.com> 133 133 Corey Minyard <minyard@acm.org> 134 134 Damian Hobson-Garcia <dhobsong@igel.co.jp> ··· 570 568 Tamizh Chelvam Raja <quic_tamizhr@quicinc.com> <tamizhr@codeaurora.org> 571 569 Taniya Das <quic_tdas@quicinc.com> <tdas@codeaurora.org> 572 570 Tejun Heo <htejun@gmail.com> 571 + Tomeu Vizoso <tomeu@tomeuvizoso.net> <tomeu.vizoso@collabora.com> 573 572 Thomas Graf <tgraf@suug.ch> 574 573 Thomas Körper <socketcan@esd.eu> <thomas.koerper@esd.eu> 575 574 Thomas Pedersen <twp@codeaurora.org>
+2 -1
arch/arm/kernel/setup.c
··· 1010 1010 1011 1011 total_mem = get_total_mem(); 1012 1012 ret = parse_crashkernel(boot_command_line, total_mem, 1013 - &crash_size, &crash_base); 1013 + &crash_size, &crash_base, 1014 + NULL, NULL); 1014 1015 /* invalid value specified or crashkernel=0 */ 1015 1016 if (ret || !crash_size) 1016 1017 return;
+3
arch/arm64/Kconfig
··· 1498 1498 config ARCH_SUPPORTS_CRASH_DUMP 1499 1499 def_bool y 1500 1500 1501 + config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION 1502 + def_bool CRASH_CORE 1503 + 1501 1504 config TRANS_TABLE 1502 1505 def_bool y 1503 1506 depends on HIBERNATION || KEXEC_CORE
+10
arch/arm64/include/asm/crash_core.h
··· 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
+8 -132
arch/arm64/mm/init.c
··· 65 65 */ 66 66 phys_addr_t __ro_after_init arm64_dma_phys_limit; 67 67 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 - 77 68 /* 78 69 * To make optimal use of block mappings when laying out the linear 79 70 * mapping, round down the base of physical memory to a size that can ··· 92 101 #define ARM64_MEMSTART_ALIGN (1UL << ARM64_MEMSTART_SHIFT) 93 102 #endif 94 103 95 - static int __init reserve_crashkernel_low(unsigned long long low_size) 104 + static void __init arch_reserve_crashkernel(void) 96 105 { 97 - unsigned long long low_base; 98 - 99 - low_base = memblock_phys_alloc_range(low_size, CRASH_ALIGN, 0, CRASH_ADDR_LOW_MAX); 100 - if (!low_base) { 101 - pr_err("cannot allocate crashkernel low memory (size:0x%llx).\n", low_size); 102 - return -ENOMEM; 103 - } 104 - 105 - pr_info("crashkernel low memory reserved: 0x%08llx - 0x%08llx (%lld MB)\n", 106 - low_base, low_base + low_size, low_size >> 20); 107 - 108 - crashk_low_res.start = low_base; 109 - crashk_low_res.end = low_base + low_size - 1; 110 - insert_resource(&iomem_resource, &crashk_low_res); 111 - 112 - return 0; 113 - } 114 - 115 - /* 116 - * reserve_crashkernel() - reserves memory for crash kernel 117 - * 118 - * This function reserves memory area given in "crashkernel=" kernel command 119 - * line parameter. The memory reserved is used by dump capture kernel when 120 - * primary kernel is crashing. 121 - */ 122 - static void __init reserve_crashkernel(void) 123 - { 124 - unsigned long long crash_low_size = 0, search_base = 0; 125 - unsigned long long crash_max = CRASH_ADDR_LOW_MAX; 106 + unsigned long long low_size = 0; 126 107 unsigned long long crash_base, crash_size; 127 108 char *cmdline = boot_command_line; 128 - bool fixed_base = false; 129 109 bool high = false; 130 110 int ret; 131 111 132 112 if (!IS_ENABLED(CONFIG_KEXEC_CORE)) 133 113 return; 134 114 135 - /* crashkernel=X[@offset] */ 136 115 ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), 137 - &crash_size, &crash_base); 138 - if (ret == -ENOENT) { 139 - ret = parse_crashkernel_high(cmdline, 0, &crash_size, &crash_base); 140 - if (ret || !crash_size) 141 - return; 142 - 143 - /* 144 - * crashkernel=Y,low can be specified or not, but invalid value 145 - * is not allowed. 146 - */ 147 - ret = parse_crashkernel_low(cmdline, 0, &crash_low_size, &crash_base); 148 - if (ret == -ENOENT) 149 - crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; 150 - else if (ret) 151 - return; 152 - 153 - search_base = CRASH_HIGH_SEARCH_BASE; 154 - crash_max = CRASH_ADDR_HIGH_MAX; 155 - high = true; 156 - } else if (ret || !crash_size) { 157 - /* The specified value is invalid */ 116 + &crash_size, &crash_base, 117 + &low_size, &high); 118 + if (ret) 158 119 return; 159 - } 160 120 161 - crash_size = PAGE_ALIGN(crash_size); 162 - 163 - /* User specifies base address explicitly. */ 164 - if (crash_base) { 165 - fixed_base = true; 166 - search_base = crash_base; 167 - crash_max = crash_base + crash_size; 168 - } 169 - 170 - retry: 171 - crash_base = memblock_phys_alloc_range(crash_size, CRASH_ALIGN, 172 - search_base, crash_max); 173 - if (!crash_base) { 174 - /* 175 - * For crashkernel=size[KMG]@offset[KMG], print out failure 176 - * message if can't reserve the specified region. 177 - */ 178 - if (fixed_base) { 179 - pr_warn("crashkernel reservation failed - memory is in use.\n"); 180 - return; 181 - } 182 - 183 - /* 184 - * For crashkernel=size[KMG], if the first attempt was for 185 - * low memory, fall back to high memory, the minimum required 186 - * low memory will be reserved later. 187 - */ 188 - if (!high && crash_max == CRASH_ADDR_LOW_MAX) { 189 - crash_max = CRASH_ADDR_HIGH_MAX; 190 - search_base = CRASH_ADDR_LOW_MAX; 191 - crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; 192 - goto retry; 193 - } 194 - 195 - /* 196 - * For crashkernel=size[KMG],high, if the first attempt was 197 - * for high memory, fall back to low memory. 198 - */ 199 - if (high && crash_max == CRASH_ADDR_HIGH_MAX) { 200 - crash_max = CRASH_ADDR_LOW_MAX; 201 - search_base = 0; 202 - goto retry; 203 - } 204 - pr_warn("cannot allocate crashkernel (size:0x%llx)\n", 205 - crash_size); 206 - return; 207 - } 208 - 209 - if ((crash_base >= CRASH_ADDR_LOW_MAX) && crash_low_size && 210 - reserve_crashkernel_low(crash_low_size)) { 211 - memblock_phys_free(crash_base, crash_size); 212 - return; 213 - } 214 - 215 - pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n", 216 - crash_base, crash_base + crash_size, crash_size >> 20); 217 - 218 - /* 219 - * The crashkernel memory will be removed from the kernel linear 220 - * map. Inform kmemleak so that it won't try to access it. 221 - */ 222 - kmemleak_ignore_phys(crash_base); 223 - if (crashk_low_res.end) 224 - kmemleak_ignore_phys(crashk_low_res.start); 225 - 226 - crashk_res.start = crash_base; 227 - crashk_res.end = crash_base + crash_size - 1; 228 - insert_resource(&iomem_resource, &crashk_res); 121 + reserve_crashkernel_generic(cmdline, crash_size, crash_base, 122 + low_size, high); 229 123 } 230 124 231 125 /* ··· 356 480 * request_standard_resources() depends on crashkernel's memory being 357 481 * reserved, so do it here. 358 482 */ 359 - reserve_crashkernel(); 483 + arch_reserve_crashkernel(); 360 484 361 485 memblock_dump_all(); 362 486 }
+3 -1
arch/loongarch/kernel/setup.c
··· 267 267 unsigned long long crash_base, crash_size; 268 268 269 269 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); 271 273 if (ret < 0 || crash_size <= 0) 272 274 return; 273 275
+2 -1
arch/mips/kernel/setup.c
··· 460 460 461 461 total_mem = memblock_phys_mem_size(); 462 462 ret = parse_crashkernel(boot_command_line, total_mem, 463 - &crash_size, &crash_base); 463 + &crash_size, &crash_base, 464 + NULL, NULL); 464 465 if (ret != 0 || crash_size <= 0) 465 466 return; 466 467
+1 -1
arch/powerpc/kernel/fadump.c
··· 313 313 * memory at a predefined offset. 314 314 */ 315 315 ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), 316 - &size, &base); 316 + &size, &base, NULL, NULL); 317 317 if (ret == 0 && size > 0) { 318 318 unsigned long max_size; 319 319
+1 -1
arch/powerpc/kexec/core.c
··· 109 109 total_mem_sz = memory_limit ? memory_limit : memblock_phys_mem_size(); 110 110 /* use common parsing */ 111 111 ret = parse_crashkernel(boot_command_line, total_mem_sz, 112 - &crash_size, &crash_base); 112 + &crash_size, &crash_base, NULL, NULL); 113 113 if (ret == 0 && crash_size > 0) { 114 114 crashk_res.start = crash_base; 115 115 crashk_res.end = crash_base + crash_size - 1;
+1 -1
arch/powerpc/mm/nohash/kaslr_booke.c
··· 178 178 int ret; 179 179 180 180 ret = parse_crashkernel(boot_command_line, size, &crash_size, 181 - &crash_base); 181 + &crash_base, NULL, NULL); 182 182 if (ret != 0 || crash_size == 0) 183 183 return; 184 184 if (crash_base == 0)
+3
arch/riscv/Kconfig
··· 693 693 config ARCH_SUPPORTS_CRASH_DUMP 694 694 def_bool y 695 695 696 + config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION 697 + def_bool CRASH_CORE 698 + 696 699 config COMPAT 697 700 bool "Kernel support for 32-bit U-mode" 698 701 default 64BIT
+11
arch/riscv/include/asm/crash_core.h
··· 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
+2
arch/riscv/include/asm/processor.h
··· 116 116 __asm__ __volatile__ ("wfi"); 117 117 } 118 118 119 + extern phys_addr_t dma32_phys_limit; 120 + 119 121 struct device_node; 120 122 int riscv_of_processor_hartid(struct device_node *node, unsigned long *hartid); 121 123 int riscv_early_of_processor_hartid(struct device_node *node, unsigned long *hartid);
+11 -130
arch/riscv/mm/init.c
··· 65 65 void *_dtb_early_va __initdata; 66 66 uintptr_t _dtb_early_pa __initdata; 67 67 68 - static phys_addr_t dma32_phys_limit __initdata; 68 + phys_addr_t dma32_phys_limit __initdata; 69 69 70 70 static void __init zone_sizes_init(void) 71 71 { ··· 1333 1333 } 1334 1334 #endif /* CONFIG_MMU */ 1335 1335 1336 - /* Reserve 128M low memory by default for swiotlb buffer */ 1337 - #define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20) 1338 - 1339 - static int __init reserve_crashkernel_low(unsigned long long low_size) 1340 - { 1341 - unsigned long long low_base; 1342 - 1343 - low_base = memblock_phys_alloc_range(low_size, PMD_SIZE, 0, dma32_phys_limit); 1344 - if (!low_base) { 1345 - pr_err("cannot allocate crashkernel low memory (size:0x%llx).\n", low_size); 1346 - return -ENOMEM; 1347 - } 1348 - 1349 - pr_info("crashkernel low memory reserved: 0x%016llx - 0x%016llx (%lld MB)\n", 1350 - low_base, low_base + low_size, low_size >> 20); 1351 - 1352 - crashk_low_res.start = low_base; 1353 - crashk_low_res.end = low_base + low_size - 1; 1354 - 1355 - return 0; 1356 - } 1357 - 1358 1336 /* 1359 1337 * reserve_crashkernel() - reserves memory for crash kernel 1360 1338 * ··· 1340 1362 * line parameter. The memory reserved is used by dump capture kernel when 1341 1363 * primary kernel is crashing. 1342 1364 */ 1343 - static void __init reserve_crashkernel(void) 1365 + static void __init arch_reserve_crashkernel(void) 1344 1366 { 1345 - unsigned long long crash_base = 0; 1346 - unsigned long long crash_size = 0; 1347 - unsigned long long crash_low_size = 0; 1348 - unsigned long search_start = memblock_start_of_DRAM(); 1349 - unsigned long search_end = (unsigned long)dma32_phys_limit; 1367 + unsigned long long low_size = 0; 1368 + unsigned long long crash_base, crash_size; 1350 1369 char *cmdline = boot_command_line; 1351 - bool fixed_base = false; 1352 1370 bool high = false; 1353 - 1354 - int ret = 0; 1371 + int ret; 1355 1372 1356 1373 if (!IS_ENABLED(CONFIG_KEXEC_CORE)) 1357 1374 return; 1358 - /* 1359 - * Don't reserve a region for a crash kernel on a crash kernel 1360 - * since it doesn't make much sense and we have limited memory 1361 - * resources. 1362 - */ 1363 - if (is_kdump_kernel()) { 1364 - pr_info("crashkernel: ignoring reservation request\n"); 1365 - return; 1366 - } 1367 1375 1368 1376 ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), 1369 - &crash_size, &crash_base); 1370 - if (ret == -ENOENT) { 1371 - /* Fallback to crashkernel=X,[high,low] */ 1372 - ret = parse_crashkernel_high(cmdline, 0, &crash_size, &crash_base); 1373 - if (ret || !crash_size) 1374 - return; 1375 - 1376 - /* 1377 - * crashkernel=Y,low is valid only when crashkernel=X,high 1378 - * is passed. 1379 - */ 1380 - ret = parse_crashkernel_low(cmdline, 0, &crash_low_size, &crash_base); 1381 - if (ret == -ENOENT) 1382 - crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; 1383 - else if (ret) 1384 - return; 1385 - 1386 - search_start = (unsigned long)dma32_phys_limit; 1387 - search_end = memblock_end_of_DRAM(); 1388 - high = true; 1389 - } else if (ret || !crash_size) { 1390 - /* Invalid argument value specified */ 1377 + &crash_size, &crash_base, 1378 + &low_size, &high); 1379 + if (ret) 1391 1380 return; 1392 - } 1393 1381 1394 - crash_size = PAGE_ALIGN(crash_size); 1395 - 1396 - if (crash_base) { 1397 - fixed_base = true; 1398 - search_start = crash_base; 1399 - search_end = crash_base + crash_size; 1400 - } 1401 - 1402 - /* 1403 - * Current riscv boot protocol requires 2MB alignment for 1404 - * RV64 and 4MB alignment for RV32 (hugepage size) 1405 - * 1406 - * Try to alloc from 32bit addressible physical memory so that 1407 - * swiotlb can work on the crash kernel. 1408 - */ 1409 - crash_base = memblock_phys_alloc_range(crash_size, PMD_SIZE, 1410 - search_start, search_end); 1411 - if (crash_base == 0) { 1412 - /* 1413 - * For crashkernel=size[KMG]@offset[KMG], print out failure 1414 - * message if can't reserve the specified region. 1415 - */ 1416 - if (fixed_base) { 1417 - pr_warn("crashkernel: allocating failed with given size@offset\n"); 1418 - return; 1419 - } 1420 - 1421 - if (high) { 1422 - /* 1423 - * For crashkernel=size[KMG],high, if the first attempt was 1424 - * for high memory, fall back to low memory. 1425 - */ 1426 - search_start = memblock_start_of_DRAM(); 1427 - search_end = (unsigned long)dma32_phys_limit; 1428 - } else { 1429 - /* 1430 - * For crashkernel=size[KMG], if the first attempt was for 1431 - * low memory, fall back to high memory, the minimum required 1432 - * low memory will be reserved later. 1433 - */ 1434 - search_start = (unsigned long)dma32_phys_limit; 1435 - search_end = memblock_end_of_DRAM(); 1436 - crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; 1437 - } 1438 - 1439 - crash_base = memblock_phys_alloc_range(crash_size, PMD_SIZE, 1440 - search_start, search_end); 1441 - if (crash_base == 0) { 1442 - pr_warn("crashkernel: couldn't allocate %lldKB\n", 1443 - crash_size >> 10); 1444 - return; 1445 - } 1446 - } 1447 - 1448 - if ((crash_base >= dma32_phys_limit) && crash_low_size && 1449 - reserve_crashkernel_low(crash_low_size)) { 1450 - memblock_phys_free(crash_base, crash_size); 1451 - return; 1452 - } 1453 - 1454 - pr_info("crashkernel: reserved 0x%016llx - 0x%016llx (%lld MB)\n", 1455 - crash_base, crash_base + crash_size, crash_size >> 20); 1456 - 1457 - crashk_res.start = crash_base; 1458 - crashk_res.end = crash_base + crash_size - 1; 1382 + reserve_crashkernel_generic(cmdline, crash_size, crash_base, 1383 + low_size, high); 1459 1384 } 1460 1385 1461 1386 void __init paging_init(void) ··· 1376 1495 arch_numa_init(); 1377 1496 sparse_init(); 1378 1497 zone_sizes_init(); 1379 - reserve_crashkernel(); 1498 + arch_reserve_crashkernel(); 1380 1499 memblock_dump_all(); 1381 1500 } 1382 1501
+2 -2
arch/s390/kernel/setup.c
··· 625 625 phys_addr_t low, high; 626 626 int rc; 627 627 628 - rc = parse_crashkernel(boot_command_line, ident_map_size, &crash_size, 629 - &crash_base); 628 + rc = parse_crashkernel(boot_command_line, ident_map_size, 629 + &crash_size, &crash_base, NULL, NULL); 630 630 631 631 crash_base = ALIGN(crash_base, KEXEC_CRASH_MEM_ALIGN); 632 632 crash_size = ALIGN(crash_size, KEXEC_CRASH_MEM_ALIGN);
+1 -1
arch/sh/kernel/machine_kexec.c
··· 154 154 int ret; 155 155 156 156 ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), 157 - &crash_size, &crash_base); 157 + &crash_size, &crash_base, NULL, NULL); 158 158 if (ret == 0 && crash_size > 0) { 159 159 crashk_res.start = crash_base; 160 160 crashk_res.end = crash_base + crash_size - 1;
+3
arch/x86/Kconfig
··· 2075 2075 config ARCH_SUPPORTS_CRASH_HOTPLUG 2076 2076 def_bool y 2077 2077 2078 + config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION 2079 + def_bool CRASH_CORE 2080 + 2078 2081 config PHYSICAL_START 2079 2082 hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP) 2080 2083 default "0x1000000"
+42
arch/x86/include/asm/crash_core.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _X86_CRASH_CORE_H 3 + #define _X86_CRASH_CORE_H 4 + 5 + /* 16M alignment for crash kernel regions */ 6 + #define CRASH_ALIGN SZ_16M 7 + 8 + /* 9 + * Keep the crash kernel below this limit. 10 + * 11 + * Earlier 32-bits kernels would limit the kernel to the low 512 MB range 12 + * due to mapping restrictions. 13 + * 14 + * 64-bit kdump kernels need to be restricted to be under 64 TB, which is 15 + * the upper limit of system RAM in 4-level paging mode. Since the kdump 16 + * jump could be from 5-level paging to 4-level paging, the jump will fail if 17 + * the kernel is put above 64 TB, and during the 1st kernel bootup there's 18 + * no good way to detect the paging mode of the target kernel which will be 19 + * loaded for dumping. 20 + */ 21 + extern unsigned long swiotlb_size_or_default(void); 22 + 23 + #ifdef CONFIG_X86_32 24 + # define CRASH_ADDR_LOW_MAX SZ_512M 25 + # define CRASH_ADDR_HIGH_MAX SZ_512M 26 + #else 27 + # define CRASH_ADDR_LOW_MAX SZ_4G 28 + # define CRASH_ADDR_HIGH_MAX SZ_64T 29 + #endif 30 + 31 + # define DEFAULT_CRASH_KERNEL_LOW_SIZE crash_low_size_default() 32 + 33 + static inline unsigned long crash_low_size_default(void) 34 + { 35 + #ifdef CONFIG_X86_64 36 + return max(swiotlb_size_or_default() + (8UL << 20), 256UL << 20); 37 + #else 38 + return 0; 39 + #endif 40 + } 41 + 42 + #endif /* _X86_CRASH_CORE_H */
+11 -136
arch/x86/kernel/setup.c
··· 466 466 } 467 467 } 468 468 469 - /* 470 - * --------- Crashkernel reservation ------------------------------ 471 - */ 472 - 473 - /* 16M alignment for crash kernel regions */ 474 - #define CRASH_ALIGN SZ_16M 475 - 476 - /* 477 - * Keep the crash kernel below this limit. 478 - * 479 - * Earlier 32-bits kernels would limit the kernel to the low 512 MB range 480 - * due to mapping restrictions. 481 - * 482 - * 64-bit kdump kernels need to be restricted to be under 64 TB, which is 483 - * the upper limit of system RAM in 4-level paging mode. Since the kdump 484 - * jump could be from 5-level paging to 4-level paging, the jump will fail if 485 - * the kernel is put above 64 TB, and during the 1st kernel bootup there's 486 - * no good way to detect the paging mode of the target kernel which will be 487 - * loaded for dumping. 488 - */ 489 - #ifdef CONFIG_X86_32 490 - # define CRASH_ADDR_LOW_MAX SZ_512M 491 - # define CRASH_ADDR_HIGH_MAX SZ_512M 492 - #else 493 - # define CRASH_ADDR_LOW_MAX SZ_4G 494 - # define CRASH_ADDR_HIGH_MAX SZ_64T 495 - #endif 496 - 497 - static int __init reserve_crashkernel_low(void) 469 + static void __init arch_reserve_crashkernel(void) 498 470 { 499 - #ifdef CONFIG_X86_64 500 - unsigned long long base, low_base = 0, low_size = 0; 501 - unsigned long low_mem_limit; 502 - int ret; 503 - 504 - low_mem_limit = min(memblock_phys_mem_size(), CRASH_ADDR_LOW_MAX); 505 - 506 - /* crashkernel=Y,low */ 507 - ret = parse_crashkernel_low(boot_command_line, low_mem_limit, &low_size, &base); 508 - if (ret) { 509 - /* 510 - * two parts from kernel/dma/swiotlb.c: 511 - * -swiotlb size: user-specified with swiotlb= or default. 512 - * 513 - * -swiotlb overflow buffer: now hardcoded to 32k. We round it 514 - * to 8M for other buffers that may need to stay low too. Also 515 - * make sure we allocate enough extra low memory so that we 516 - * don't run out of DMA buffers for 32-bit devices. 517 - */ 518 - low_size = max(swiotlb_size_or_default() + (8UL << 20), 256UL << 20); 519 - } else { 520 - /* passed with crashkernel=0,low ? */ 521 - if (!low_size) 522 - return 0; 523 - } 524 - 525 - low_base = memblock_phys_alloc_range(low_size, CRASH_ALIGN, 0, CRASH_ADDR_LOW_MAX); 526 - if (!low_base) { 527 - pr_err("Cannot reserve %ldMB crashkernel low memory, please try smaller size.\n", 528 - (unsigned long)(low_size >> 20)); 529 - return -ENOMEM; 530 - } 531 - 532 - pr_info("Reserving %ldMB of low memory at %ldMB for crashkernel (low RAM limit: %ldMB)\n", 533 - (unsigned long)(low_size >> 20), 534 - (unsigned long)(low_base >> 20), 535 - (unsigned long)(low_mem_limit >> 20)); 536 - 537 - crashk_low_res.start = low_base; 538 - crashk_low_res.end = low_base + low_size - 1; 539 - insert_resource(&iomem_resource, &crashk_low_res); 540 - #endif 541 - return 0; 542 - } 543 - 544 - static void __init reserve_crashkernel(void) 545 - { 546 - unsigned long long crash_size, crash_base, total_mem; 471 + unsigned long long crash_base, crash_size, low_size = 0; 472 + char *cmdline = boot_command_line; 547 473 bool high = false; 548 474 int ret; 549 475 550 476 if (!IS_ENABLED(CONFIG_KEXEC_CORE)) 551 477 return; 552 478 553 - total_mem = memblock_phys_mem_size(); 554 - 555 - /* crashkernel=XM */ 556 - ret = parse_crashkernel(boot_command_line, total_mem, &crash_size, &crash_base); 557 - if (ret != 0 || crash_size <= 0) { 558 - /* crashkernel=X,high */ 559 - ret = parse_crashkernel_high(boot_command_line, total_mem, 560 - &crash_size, &crash_base); 561 - if (ret != 0 || crash_size <= 0) 562 - return; 563 - high = true; 564 - } 479 + ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), 480 + &crash_size, &crash_base, 481 + &low_size, &high); 482 + if (ret) 483 + return; 565 484 566 485 if (xen_pv_domain()) { 567 486 pr_info("Ignoring crashkernel for a Xen PV domain\n"); 568 487 return; 569 488 } 570 489 571 - /* 0 means: find the address automatically */ 572 - if (!crash_base) { 573 - /* 574 - * Set CRASH_ADDR_LOW_MAX upper bound for crash memory, 575 - * crashkernel=x,high reserves memory over 4G, also allocates 576 - * 256M extra low memory for DMA buffers and swiotlb. 577 - * But the extra memory is not required for all machines. 578 - * So try low memory first and fall back to high memory 579 - * unless "crashkernel=size[KMG],high" is specified. 580 - */ 581 - if (!high) 582 - crash_base = memblock_phys_alloc_range(crash_size, 583 - CRASH_ALIGN, CRASH_ALIGN, 584 - CRASH_ADDR_LOW_MAX); 585 - if (!crash_base) 586 - crash_base = memblock_phys_alloc_range(crash_size, 587 - CRASH_ALIGN, CRASH_ALIGN, 588 - CRASH_ADDR_HIGH_MAX); 589 - if (!crash_base) { 590 - pr_info("crashkernel reservation failed - No suitable area found.\n"); 591 - return; 592 - } 593 - } else { 594 - unsigned long long start; 595 - 596 - start = memblock_phys_alloc_range(crash_size, SZ_1M, crash_base, 597 - crash_base + crash_size); 598 - if (start != crash_base) { 599 - pr_info("crashkernel reservation failed - memory is in use.\n"); 600 - return; 601 - } 602 - } 603 - 604 - if (crash_base >= (1ULL << 32) && reserve_crashkernel_low()) { 605 - memblock_phys_free(crash_base, crash_size); 606 - return; 607 - } 608 - 609 - pr_info("Reserving %ldMB of memory at %ldMB for crashkernel (System RAM: %ldMB)\n", 610 - (unsigned long)(crash_size >> 20), 611 - (unsigned long)(crash_base >> 20), 612 - (unsigned long)(total_mem >> 20)); 613 - 614 - crashk_res.start = crash_base; 615 - crashk_res.end = crash_base + crash_size - 1; 616 - insert_resource(&iomem_resource, &crashk_res); 490 + reserve_crashkernel_generic(cmdline, crash_size, crash_base, 491 + low_size, high); 617 492 } 618 493 619 494 static struct resource standard_io_resources[] = { ··· 1104 1229 * Reserve memory for crash kernel after SRAT is parsed so that it 1105 1230 * won't consume hotpluggable memory. 1106 1231 */ 1107 - reserve_crashkernel(); 1232 + arch_reserve_crashkernel(); 1108 1233 1109 1234 memblock_find_dma_reserve(); 1110 1235
+3 -3
block/bdev.c
··· 292 292 */ 293 293 294 294 static __cacheline_aligned_in_smp DEFINE_MUTEX(bdev_lock); 295 - static struct kmem_cache * bdev_cachep __read_mostly; 295 + static struct kmem_cache *bdev_cachep __ro_after_init; 296 296 297 297 static struct inode *bdev_alloc_inode(struct super_block *sb) 298 298 { ··· 361 361 .kill_sb = kill_anon_super, 362 362 }; 363 363 364 - struct super_block *blockdev_superblock __read_mostly; 364 + struct super_block *blockdev_superblock __ro_after_init; 365 365 EXPORT_SYMBOL_GPL(blockdev_superblock); 366 366 367 367 void __init bdev_cache_init(void) 368 368 { 369 369 int err; 370 - static struct vfsmount *bd_mnt; 370 + static struct vfsmount *bd_mnt __ro_after_init; 371 371 372 372 bdev_cachep = kmem_cache_create("bdev_cache", sizeof(struct bdev_inode), 373 373 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
+1 -2
drivers/accel/ivpu/ivpu_job.c
··· 618 618 619 619 void ivpu_job_done_thread_fini(struct ivpu_device *vdev) 620 620 { 621 - kthread_stop(vdev->job_done_thread); 622 - put_task_struct(vdev->job_done_thread); 621 + kthread_stop_put(vdev->job_done_thread); 623 622 }
+4 -8
drivers/dma-buf/st-dma-fence-chain.c
··· 476 476 for (i = 0; i < ncpus; i++) { 477 477 int ret; 478 478 479 - ret = kthread_stop(threads[i]); 479 + ret = kthread_stop_put(threads[i]); 480 480 if (ret && !err) 481 481 err = ret; 482 - put_task_struct(threads[i]); 483 482 } 484 483 kfree(threads); 485 484 ··· 590 591 for (i = 0; i < fc.chain_length; i++) 591 592 dma_fence_signal(fc.fences[i]); 592 593 593 - err = kthread_stop(tsk); 594 - put_task_struct(tsk); 594 + err = kthread_stop_put(tsk); 595 595 596 596 err: 597 597 fence_chains_fini(&fc); ··· 619 621 for (i = fc.chain_length; i--; ) 620 622 dma_fence_signal(fc.fences[i]); 621 623 622 - err = kthread_stop(tsk); 623 - put_task_struct(tsk); 624 + err = kthread_stop_put(tsk); 624 625 625 626 err: 626 627 fence_chains_fini(&fc); ··· 666 669 for (i = 0; i < fc.chain_length; i++) 667 670 dma_fence_signal(fc.fences[i]); 668 671 669 - err = kthread_stop(tsk); 670 - put_task_struct(tsk); 672 + err = kthread_stop_put(tsk); 671 673 672 674 err: 673 675 fence_chains_fini(&fc);
+1 -3
drivers/dma-buf/st-dma-fence.c
··· 548 548 for (i = 0; i < ARRAY_SIZE(t); i++) { 549 549 int err; 550 550 551 - err = kthread_stop(t[i].task); 551 + err = kthread_stop_put(t[i].task); 552 552 if (err && !ret) 553 553 ret = err; 554 - 555 - put_task_struct(t[i].task); 556 554 } 557 555 } 558 556
+1 -3
drivers/gpu/drm/i915/gt/selftest_migrate.c
··· 719 719 if (IS_ERR_OR_NULL(tsk)) 720 720 continue; 721 721 722 - status = kthread_stop(tsk); 722 + status = kthread_stop_put(tsk); 723 723 if (status && !err) 724 724 err = status; 725 - 726 - put_task_struct(tsk); 727 725 } 728 726 729 727 kfree(thread);
+1 -2
drivers/net/xen-netback/interface.c
··· 671 671 static void xenvif_disconnect_queue(struct xenvif_queue *queue) 672 672 { 673 673 if (queue->task) { 674 - kthread_stop(queue->task); 675 - put_task_struct(queue->task); 674 + kthread_stop_put(queue->task); 676 675 queue->task = NULL; 677 676 } 678 677
+9 -128
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
··· 3959 3959 3960 3960 return count; 3961 3961 } 3962 - 3963 - static int debugfs_bist_linkrate_v3_hw_open(struct inode *inode, 3964 - struct file *filp) 3965 - { 3966 - return single_open(filp, debugfs_bist_linkrate_v3_hw_show, 3967 - inode->i_private); 3968 - } 3969 - 3970 - static const struct file_operations debugfs_bist_linkrate_v3_hw_fops = { 3971 - .open = debugfs_bist_linkrate_v3_hw_open, 3972 - .read = seq_read, 3973 - .write = debugfs_bist_linkrate_v3_hw_write, 3974 - .llseek = seq_lseek, 3975 - .release = single_release, 3976 - .owner = THIS_MODULE, 3977 - }; 3962 + DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_linkrate_v3_hw); 3978 3963 3979 3964 static const struct { 3980 3965 int value; ··· 4034 4049 4035 4050 return count; 4036 4051 } 4037 - 4038 - static int debugfs_bist_code_mode_v3_hw_open(struct inode *inode, 4039 - struct file *filp) 4040 - { 4041 - return single_open(filp, debugfs_bist_code_mode_v3_hw_show, 4042 - inode->i_private); 4043 - } 4044 - 4045 - static const struct file_operations debugfs_bist_code_mode_v3_hw_fops = { 4046 - .open = debugfs_bist_code_mode_v3_hw_open, 4047 - .read = seq_read, 4048 - .write = debugfs_bist_code_mode_v3_hw_write, 4049 - .llseek = seq_lseek, 4050 - .release = single_release, 4051 - .owner = THIS_MODULE, 4052 - }; 4052 + DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_code_mode_v3_hw); 4053 4053 4054 4054 static ssize_t debugfs_bist_phy_v3_hw_write(struct file *filp, 4055 4055 const char __user *buf, ··· 4068 4098 4069 4099 return 0; 4070 4100 } 4071 - 4072 - static int debugfs_bist_phy_v3_hw_open(struct inode *inode, 4073 - struct file *filp) 4074 - { 4075 - return single_open(filp, debugfs_bist_phy_v3_hw_show, 4076 - inode->i_private); 4077 - } 4078 - 4079 - static const struct file_operations debugfs_bist_phy_v3_hw_fops = { 4080 - .open = debugfs_bist_phy_v3_hw_open, 4081 - .read = seq_read, 4082 - .write = debugfs_bist_phy_v3_hw_write, 4083 - .llseek = seq_lseek, 4084 - .release = single_release, 4085 - .owner = THIS_MODULE, 4086 - }; 4101 + DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_phy_v3_hw); 4087 4102 4088 4103 static ssize_t debugfs_bist_cnt_v3_hw_write(struct file *filp, 4089 4104 const char __user *buf, ··· 4101 4146 4102 4147 return 0; 4103 4148 } 4104 - 4105 - static int debugfs_bist_cnt_v3_hw_open(struct inode *inode, 4106 - struct file *filp) 4107 - { 4108 - return single_open(filp, debugfs_bist_cnt_v3_hw_show, 4109 - inode->i_private); 4110 - } 4111 - 4112 - static const struct file_operations debugfs_bist_cnt_v3_hw_ops = { 4113 - .open = debugfs_bist_cnt_v3_hw_open, 4114 - .read = seq_read, 4115 - .write = debugfs_bist_cnt_v3_hw_write, 4116 - .llseek = seq_lseek, 4117 - .release = single_release, 4118 - .owner = THIS_MODULE, 4119 - }; 4149 + DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_cnt_v3_hw); 4120 4150 4121 4151 static const struct { 4122 4152 int value; ··· 4165 4225 4166 4226 return count; 4167 4227 } 4168 - 4169 - static int debugfs_bist_mode_v3_hw_open(struct inode *inode, 4170 - struct file *filp) 4171 - { 4172 - return single_open(filp, debugfs_bist_mode_v3_hw_show, 4173 - inode->i_private); 4174 - } 4175 - 4176 - static const struct file_operations debugfs_bist_mode_v3_hw_fops = { 4177 - .open = debugfs_bist_mode_v3_hw_open, 4178 - .read = seq_read, 4179 - .write = debugfs_bist_mode_v3_hw_write, 4180 - .llseek = seq_lseek, 4181 - .release = single_release, 4182 - .owner = THIS_MODULE, 4183 - }; 4228 + DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_mode_v3_hw); 4184 4229 4185 4230 static ssize_t debugfs_bist_enable_v3_hw_write(struct file *filp, 4186 4231 const char __user *buf, ··· 4203 4278 4204 4279 return 0; 4205 4280 } 4206 - 4207 - static int debugfs_bist_enable_v3_hw_open(struct inode *inode, 4208 - struct file *filp) 4209 - { 4210 - return single_open(filp, debugfs_bist_enable_v3_hw_show, 4211 - inode->i_private); 4212 - } 4213 - 4214 - static const struct file_operations debugfs_bist_enable_v3_hw_fops = { 4215 - .open = debugfs_bist_enable_v3_hw_open, 4216 - .read = seq_read, 4217 - .write = debugfs_bist_enable_v3_hw_write, 4218 - .llseek = seq_lseek, 4219 - .release = single_release, 4220 - .owner = THIS_MODULE, 4221 - }; 4281 + DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_enable_v3_hw); 4222 4282 4223 4283 static const struct { 4224 4284 char *name; ··· 4241 4331 4242 4332 return 0; 4243 4333 } 4244 - 4245 - static int debugfs_v3_hw_open(struct inode *inode, struct file *filp) 4246 - { 4247 - return single_open(filp, debugfs_v3_hw_show, 4248 - inode->i_private); 4249 - } 4250 - 4251 - static const struct file_operations debugfs_v3_hw_fops = { 4252 - .open = debugfs_v3_hw_open, 4253 - .read = seq_read, 4254 - .write = debugfs_v3_hw_write, 4255 - .llseek = seq_lseek, 4256 - .release = single_release, 4257 - .owner = THIS_MODULE, 4258 - }; 4334 + DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_v3_hw); 4259 4335 4260 4336 static ssize_t debugfs_phy_down_cnt_v3_hw_write(struct file *filp, 4261 4337 const char __user *buf, ··· 4272 4376 4273 4377 return 0; 4274 4378 } 4275 - 4276 - static int debugfs_phy_down_cnt_v3_hw_open(struct inode *inode, 4277 - struct file *filp) 4278 - { 4279 - return single_open(filp, debugfs_phy_down_cnt_v3_hw_show, 4280 - inode->i_private); 4281 - } 4282 - 4283 - static const struct file_operations debugfs_phy_down_cnt_v3_hw_fops = { 4284 - .open = debugfs_phy_down_cnt_v3_hw_open, 4285 - .read = seq_read, 4286 - .write = debugfs_phy_down_cnt_v3_hw_write, 4287 - .llseek = seq_lseek, 4288 - .release = single_release, 4289 - .owner = THIS_MODULE, 4290 - }; 4379 + DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_phy_down_cnt_v3_hw); 4291 4380 4292 4381 enum fifo_dump_mode_v3_hw { 4293 4382 FIFO_DUMP_FORVER = (1U << 0), ··· 4711 4830 hisi_hba, &debugfs_bist_phy_v3_hw_fops); 4712 4831 4713 4832 debugfs_create_file("cnt", 0600, hisi_hba->debugfs_bist_dentry, 4714 - hisi_hba, &debugfs_bist_cnt_v3_hw_ops); 4833 + hisi_hba, &debugfs_bist_cnt_v3_hw_fops); 4715 4834 4716 4835 debugfs_create_file("loopback_mode", 0600, 4717 4836 hisi_hba->debugfs_bist_dentry,
+7 -52
drivers/scsi/qla2xxx/qla_dfs.c
··· 528 528 * 529 529 * Example for creating "TEST" sysfs file: 530 530 * 1. struct qla_hw_data { ... struct dentry *dfs_TEST; } 531 - * 2. QLA_DFS_SETUP_RD(TEST, scsi_qla_host_t); 531 + * 2. QLA_DFS_SETUP_RD(TEST); 532 532 * 3. In qla2x00_dfs_setup(): 533 533 * QLA_DFS_CREATE_FILE(ha, TEST, 0600, ha->dfs_dir, vha); 534 534 * 4. In qla2x00_dfs_remove(): 535 535 * QLA_DFS_REMOVE_FILE(ha, TEST); 536 536 */ 537 - #define QLA_DFS_SETUP_RD(_name, _ctx_struct) \ 538 - static int \ 539 - qla_dfs_##_name##_open(struct inode *inode, struct file *file) \ 540 - { \ 541 - _ctx_struct *__ctx = inode->i_private; \ 542 - \ 543 - return single_open(file, qla_dfs_##_name##_show, __ctx); \ 544 - } \ 545 - \ 546 - static const struct file_operations qla_dfs_##_name##_ops = { \ 547 - .open = qla_dfs_##_name##_open, \ 548 - .read = seq_read, \ 549 - .llseek = seq_lseek, \ 550 - .release = single_release, \ 551 - }; 537 + #define QLA_DFS_SETUP_RD(_name) DEFINE_SHOW_ATTRIBUTE(qla_dfs_##_name) 552 538 553 - #define QLA_DFS_SETUP_RW(_name, _ctx_struct) \ 554 - static int \ 555 - qla_dfs_##_name##_open(struct inode *inode, struct file *file) \ 556 - { \ 557 - _ctx_struct *__ctx = inode->i_private; \ 558 - \ 559 - return single_open(file, qla_dfs_##_name##_show, __ctx); \ 560 - } \ 561 - \ 562 - static const struct file_operations qla_dfs_##_name##_ops = { \ 563 - .open = qla_dfs_##_name##_open, \ 564 - .read = seq_read, \ 565 - .llseek = seq_lseek, \ 566 - .release = single_release, \ 567 - .write = qla_dfs_##_name##_write, \ 568 - }; 539 + #define QLA_DFS_SETUP_RW(_name) DEFINE_SHOW_STORE_ATTRIBUTE(qla_dfs_##_name) 569 540 570 541 #define QLA_DFS_ROOT_CREATE_FILE(_name, _perm, _ctx) \ 571 542 do { \ 572 543 if (!qla_dfs_##_name) \ 573 544 qla_dfs_##_name = debugfs_create_file(#_name, \ 574 545 _perm, qla2x00_dfs_root, _ctx, \ 575 - &qla_dfs_##_name##_ops); \ 546 + &qla_dfs_##_name##_fops); \ 576 547 } while (0) 577 548 578 549 #define QLA_DFS_ROOT_REMOVE_FILE(_name) \ ··· 558 587 do { \ 559 588 (_struct)->dfs_##_name = debugfs_create_file(#_name, \ 560 589 _perm, _parent, _ctx, \ 561 - &qla_dfs_##_name##_ops) \ 590 + &qla_dfs_##_name##_fops) \ 562 591 } while (0) 563 592 564 593 #define QLA_DFS_REMOVE_FILE(_struct, _name) \ ··· 568 597 (_struct)->dfs_##_name = NULL; \ 569 598 } \ 570 599 } while (0) 571 - 572 - static int 573 - qla_dfs_naqp_open(struct inode *inode, struct file *file) 574 - { 575 - struct scsi_qla_host *vha = inode->i_private; 576 - 577 - return single_open(file, qla_dfs_naqp_show, vha); 578 - } 579 600 580 601 static ssize_t 581 602 qla_dfs_naqp_write(struct file *file, const char __user *buffer, ··· 616 653 kfree(buf); 617 654 return rc; 618 655 } 619 - 620 - static const struct file_operations dfs_naqp_ops = { 621 - .open = qla_dfs_naqp_open, 622 - .read = seq_read, 623 - .llseek = seq_lseek, 624 - .release = single_release, 625 - .write = qla_dfs_naqp_write, 626 - }; 627 - 656 + QLA_DFS_SETUP_RW(naqp); 628 657 629 658 int 630 659 qla2x00_dfs_setup(scsi_qla_host_t *vha) ··· 662 707 663 708 if (IS_QLA27XX(ha) || IS_QLA83XX(ha) || IS_QLA28XX(ha)) { 664 709 ha->tgt.dfs_naqp = debugfs_create_file("naqp", 665 - 0400, ha->dfs_dir, vha, &dfs_naqp_ops); 710 + 0400, ha->dfs_dir, vha, &qla_dfs_naqp_fops); 666 711 if (IS_ERR(ha->tgt.dfs_naqp)) { 667 712 ql_log(ql_log_warn, vha, 0xd011, 668 713 "Unable to create debugFS naqp node.\n");
-6
drivers/usb/usbip/usbip_common.h
··· 298 298 __k; \ 299 299 }) 300 300 301 - #define kthread_stop_put(k) \ 302 - do { \ 303 - kthread_stop(k); \ 304 - put_task_struct(k); \ 305 - } while (0) 306 - 307 301 /* usbip_common.c */ 308 302 void usbip_dump_urb(struct urb *purb); 309 303 void usbip_dump_header(struct usbip_header *pdu);
+2 -2
fs/anon_inodes.c
··· 24 24 25 25 #include <linux/uaccess.h> 26 26 27 - static struct vfsmount *anon_inode_mnt __read_mostly; 28 - static struct inode *anon_inode_inode; 27 + static struct vfsmount *anon_inode_mnt __ro_after_init; 28 + static struct inode *anon_inode_inode __ro_after_init; 29 29 30 30 /* 31 31 * anon_inodefs_dname() is called from d_path().
+2 -2
fs/buffer.c
··· 2983 2983 /* 2984 2984 * Buffer-head allocation 2985 2985 */ 2986 - static struct kmem_cache *bh_cachep __read_mostly; 2986 + static struct kmem_cache *bh_cachep __ro_after_init; 2987 2987 2988 2988 /* 2989 2989 * Once the number of bh's in the machine exceeds this level, we start 2990 2990 * stripping them in writeback. 2991 2991 */ 2992 - static unsigned long max_buffer_heads; 2992 + static unsigned long max_buffer_heads __ro_after_init; 2993 2993 2994 2994 int buffer_heads_over_limit; 2995 2995
+1 -1
fs/char_dev.c
··· 25 25 26 26 #include "internal.h" 27 27 28 - static struct kobj_map *cdev_map; 28 + static struct kobj_map *cdev_map __ro_after_init; 29 29 30 30 static DEFINE_MUTEX(chrdevs_lock); 31 31
+4 -4
fs/dcache.c
··· 78 78 79 79 EXPORT_SYMBOL(rename_lock); 80 80 81 - static struct kmem_cache *dentry_cache __read_mostly; 81 + static struct kmem_cache *dentry_cache __ro_after_init; 82 82 83 83 const struct qstr empty_name = QSTR_INIT("", 0); 84 84 EXPORT_SYMBOL(empty_name); ··· 96 96 * information, yet avoid using a prime hash-size or similar. 97 97 */ 98 98 99 - static unsigned int d_hash_shift __read_mostly; 99 + static unsigned int d_hash_shift __ro_after_init; 100 100 101 - static struct hlist_bl_head *dentry_hashtable __read_mostly; 101 + static struct hlist_bl_head *dentry_hashtable __ro_after_init; 102 102 103 103 static inline struct hlist_bl_head *d_hash(unsigned int hash) 104 104 { ··· 3332 3332 } 3333 3333 3334 3334 /* SLAB cache for __getname() consumers */ 3335 - struct kmem_cache *names_cachep __read_mostly; 3335 + struct kmem_cache *names_cachep __ro_after_init; 3336 3336 EXPORT_SYMBOL(names_cachep); 3337 3337 3338 3338 void __init vfs_caches_init_early(void)
+1 -1
fs/direct-io.c
··· 151 151 }; 152 152 } ____cacheline_aligned_in_smp; 153 153 154 - static struct kmem_cache *dio_cache __read_mostly; 154 + static struct kmem_cache *dio_cache __ro_after_init; 155 155 156 156 /* 157 157 * How many pages are in the queue?
+3 -3
fs/eventpoll.c
··· 256 256 static struct eventpoll *inserting_into; 257 257 258 258 /* Slab cache used to allocate "struct epitem" */ 259 - static struct kmem_cache *epi_cache __read_mostly; 259 + static struct kmem_cache *epi_cache __ro_after_init; 260 260 261 261 /* Slab cache used to allocate "struct eppoll_entry" */ 262 - static struct kmem_cache *pwq_cache __read_mostly; 262 + static struct kmem_cache *pwq_cache __ro_after_init; 263 263 264 264 /* 265 265 * List of files with newly added links, where we may need to limit the number ··· 271 271 }; 272 272 static struct epitems_head *tfile_check_list = EP_UNACTIVE_PTR; 273 273 274 - static struct kmem_cache *ephead_cache __read_mostly; 274 + static struct kmem_cache *ephead_cache __ro_after_init; 275 275 276 276 static inline void free_ephead(struct epitems_head *head) 277 277 {
+1 -1
fs/fcntl.c
··· 844 844 } 845 845 846 846 static DEFINE_SPINLOCK(fasync_lock); 847 - static struct kmem_cache *fasync_cache __read_mostly; 847 + static struct kmem_cache *fasync_cache __ro_after_init; 848 848 849 849 static void fasync_free_rcu(struct rcu_head *head) 850 850 {
+1 -1
fs/file_table.c
··· 40 40 }; 41 41 42 42 /* SLAB cache for file structures */ 43 - static struct kmem_cache *filp_cachep __read_mostly; 43 + static struct kmem_cache *filp_cachep __ro_after_init; 44 44 45 45 static struct percpu_counter nr_files __cacheline_aligned_in_smp; 46 46
+3 -6
fs/gfs2/ops_fstype.c
··· 1126 1126 return 0; 1127 1127 1128 1128 fail: 1129 - kthread_stop(sdp->sd_logd_process); 1130 - put_task_struct(sdp->sd_logd_process); 1129 + kthread_stop_put(sdp->sd_logd_process); 1131 1130 sdp->sd_logd_process = NULL; 1132 1131 return error; 1133 1132 } ··· 1134 1135 void gfs2_destroy_threads(struct gfs2_sbd *sdp) 1135 1136 { 1136 1137 if (sdp->sd_logd_process) { 1137 - kthread_stop(sdp->sd_logd_process); 1138 - put_task_struct(sdp->sd_logd_process); 1138 + kthread_stop_put(sdp->sd_logd_process); 1139 1139 sdp->sd_logd_process = NULL; 1140 1140 } 1141 1141 if (sdp->sd_quotad_process) { 1142 - kthread_stop(sdp->sd_quotad_process); 1143 - put_task_struct(sdp->sd_quotad_process); 1142 + kthread_stop_put(sdp->sd_quotad_process); 1144 1143 sdp->sd_quotad_process = NULL; 1145 1144 } 1146 1145 }
+4 -4
fs/inode.c
··· 54 54 * inode_hash_lock 55 55 */ 56 56 57 - static unsigned int i_hash_mask __read_mostly; 58 - static unsigned int i_hash_shift __read_mostly; 59 - static struct hlist_head *inode_hashtable __read_mostly; 57 + static unsigned int i_hash_mask __ro_after_init; 58 + static unsigned int i_hash_shift __ro_after_init; 59 + static struct hlist_head *inode_hashtable __ro_after_init; 60 60 static __cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_hash_lock); 61 61 62 62 /* ··· 70 70 static DEFINE_PER_CPU(unsigned long, nr_inodes); 71 71 static DEFINE_PER_CPU(unsigned long, nr_unused); 72 72 73 - static struct kmem_cache *inode_cachep __read_mostly; 73 + static struct kmem_cache *inode_cachep __ro_after_init; 74 74 75 75 static long get_nr_inodes(void) 76 76 {
+3 -2
fs/kernfs/mount.c
··· 21 21 22 22 #include "kernfs-internal.h" 23 23 24 - struct kmem_cache *kernfs_node_cache, *kernfs_iattrs_cache; 25 - struct kernfs_global_locks *kernfs_locks; 24 + struct kmem_cache *kernfs_node_cache __ro_after_init; 25 + struct kmem_cache *kernfs_iattrs_cache __ro_after_init; 26 + struct kernfs_global_locks *kernfs_locks __ro_after_init; 26 27 27 28 static int kernfs_sop_show_options(struct seq_file *sf, struct dentry *dentry) 28 29 {
+2 -2
fs/locks.c
··· 167 167 */ 168 168 static DEFINE_SPINLOCK(blocked_lock_lock); 169 169 170 - static struct kmem_cache *flctx_cache __read_mostly; 171 - static struct kmem_cache *filelock_cache __read_mostly; 170 + static struct kmem_cache *flctx_cache __ro_after_init; 171 + static struct kmem_cache *filelock_cache __ro_after_init; 172 172 173 173 static struct file_lock_context * 174 174 locks_get_lock_context(struct inode *inode, int type)
+8 -8
fs/namespace.c
··· 39 39 /* Maximum number of mounts in a mount namespace */ 40 40 static unsigned int sysctl_mount_max __read_mostly = 100000; 41 41 42 - static unsigned int m_hash_mask __read_mostly; 43 - static unsigned int m_hash_shift __read_mostly; 44 - static unsigned int mp_hash_mask __read_mostly; 45 - static unsigned int mp_hash_shift __read_mostly; 42 + static unsigned int m_hash_mask __ro_after_init; 43 + static unsigned int m_hash_shift __ro_after_init; 44 + static unsigned int mp_hash_mask __ro_after_init; 45 + static unsigned int mp_hash_shift __ro_after_init; 46 46 47 47 static __initdata unsigned long mhash_entries; 48 48 static int __init set_mhash_entries(char *str) ··· 68 68 static DEFINE_IDA(mnt_id_ida); 69 69 static DEFINE_IDA(mnt_group_ida); 70 70 71 - static struct hlist_head *mount_hashtable __read_mostly; 72 - static struct hlist_head *mountpoint_hashtable __read_mostly; 73 - static struct kmem_cache *mnt_cache __read_mostly; 71 + static struct hlist_head *mount_hashtable __ro_after_init; 72 + static struct hlist_head *mountpoint_hashtable __ro_after_init; 73 + static struct kmem_cache *mnt_cache __ro_after_init; 74 74 static DECLARE_RWSEM(namespace_sem); 75 75 static HLIST_HEAD(unmounted); /* protected by namespace_sem */ 76 76 static LIST_HEAD(ex_mountpoints); /* protected by namespace_sem */ ··· 86 86 }; 87 87 88 88 /* /sys/fs */ 89 - struct kobject *fs_kobj; 89 + struct kobject *fs_kobj __ro_after_init; 90 90 EXPORT_SYMBOL_GPL(fs_kobj); 91 91 92 92 /*
+3 -3
fs/notify/dnotify/dnotify.c
··· 39 39 #define dnotify_sysctl_init() do { } while (0) 40 40 #endif 41 41 42 - static struct kmem_cache *dnotify_struct_cache __read_mostly; 43 - static struct kmem_cache *dnotify_mark_cache __read_mostly; 44 - static struct fsnotify_group *dnotify_group __read_mostly; 42 + static struct kmem_cache *dnotify_struct_cache __ro_after_init; 43 + static struct kmem_cache *dnotify_mark_cache __ro_after_init; 44 + static struct fsnotify_group *dnotify_group __ro_after_init; 45 45 46 46 /* 47 47 * dnotify will attach one of these to each inode (i_fsnotify_marks) which
+4 -4
fs/notify/fanotify/fanotify_user.c
··· 112 112 113 113 extern const struct fsnotify_ops fanotify_fsnotify_ops; 114 114 115 - struct kmem_cache *fanotify_mark_cache __read_mostly; 116 - struct kmem_cache *fanotify_fid_event_cachep __read_mostly; 117 - struct kmem_cache *fanotify_path_event_cachep __read_mostly; 118 - struct kmem_cache *fanotify_perm_event_cachep __read_mostly; 115 + struct kmem_cache *fanotify_mark_cache __ro_after_init; 116 + struct kmem_cache *fanotify_fid_event_cachep __ro_after_init; 117 + struct kmem_cache *fanotify_path_event_cachep __ro_after_init; 118 + struct kmem_cache *fanotify_perm_event_cachep __ro_after_init; 119 119 120 120 #define FANOTIFY_EVENT_ALIGN 4 121 121 #define FANOTIFY_FID_INFO_HDR_LEN \
+1 -1
fs/notify/inotify/inotify_user.c
··· 49 49 /* configurable via /proc/sys/fs/inotify/ */ 50 50 static int inotify_max_queued_events __read_mostly; 51 51 52 - struct kmem_cache *inotify_inode_mark_cachep __read_mostly; 52 + struct kmem_cache *inotify_inode_mark_cachep __ro_after_init; 53 53 54 54 #ifdef CONFIG_SYSCTL 55 55
+9 -2
fs/ocfs2/alloc.c
··· 967 967 el = &eb->h_list; 968 968 } 969 969 970 - BUG_ON(el->l_tree_depth != 0); 970 + if (el->l_tree_depth != 0) { 971 + retval = ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci), 972 + "Owner %llu has leaf extent block %llu with an invalid l_tree_depth of %u\n", 973 + (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), 974 + (unsigned long long)last_eb_blk, 975 + le16_to_cpu(el->l_tree_depth)); 976 + goto bail; 977 + } 971 978 972 979 retval = le16_to_cpu(el->l_count) - le16_to_cpu(el->l_next_free_rec); 973 980 bail: ··· 7649 7642 goto next_group; 7650 7643 } 7651 7644 out: 7652 - range->len = trimmed * sb->s_blocksize; 7645 + range->len = trimmed * osb->s_clustersize; 7653 7646 return ret; 7654 7647 } 7655 7648
+2 -2
fs/ocfs2/buffer_head_io.c
··· 158 158 if (new_bh && bh) { 159 159 /* If middle bh fails, let previous bh 160 160 * finish its read and then put it to 161 - * aovoid bh leak 161 + * avoid bh leak 162 162 */ 163 163 if (!buffer_jbd(bh)) 164 164 wait_on_buffer(bh); ··· 345 345 if (new_bh && bh) { 346 346 /* If middle bh fails, let previous bh 347 347 * finish its read and then put it to 348 - * aovoid bh leak 348 + * avoid bh leak 349 349 */ 350 350 if (!buffer_jbd(bh)) 351 351 wait_on_buffer(bh);
+1 -2
fs/ocfs2/dlmfs/dlmfs.c
··· 80 80 static int param_get_dlmfs_capabilities(char *buffer, 81 81 const struct kernel_param *kp) 82 82 { 83 - return strlcpy(buffer, DLMFS_CAPABILITIES, 84 - strlen(DLMFS_CAPABILITIES) + 1); 83 + return sysfs_emit(buffer, DLMFS_CAPABILITIES); 85 84 } 86 85 module_param_call(capabilities, param_set_dlmfs_capabilities, 87 86 param_get_dlmfs_capabilities, NULL, 0444);
+1 -1
fs/ocfs2/journal.c
··· 90 90 struct ocfs2_replay_map { 91 91 unsigned int rm_slots; 92 92 enum ocfs2_replay_state rm_state; 93 - unsigned char rm_replay_slots[]; 93 + unsigned char rm_replay_slots[] __counted_by(rm_slots); 94 94 }; 95 95 96 96 static void ocfs2_replay_map_set_state(struct ocfs2_super *osb, int state)
+8
fs/ocfs2/namei.c
··· 1597 1597 if (update_dot_dot) { 1598 1598 status = ocfs2_update_entry(old_inode, handle, 1599 1599 &old_inode_dot_dot_res, new_dir); 1600 + if (status < 0) { 1601 + mlog_errno(status); 1602 + goto bail; 1603 + } 1600 1604 drop_nlink(old_dir); 1601 1605 if (new_inode) { 1602 1606 drop_nlink(new_inode); ··· 1640 1636 INODE_CACHE(old_dir), 1641 1637 old_dir_bh, 1642 1638 OCFS2_JOURNAL_ACCESS_WRITE); 1639 + if (status < 0) { 1640 + mlog_errno(status); 1641 + goto bail; 1642 + } 1643 1643 fe = (struct ocfs2_dinode *) old_dir_bh->b_data; 1644 1644 ocfs2_set_links_count(fe, old_dir->i_nlink); 1645 1645 ocfs2_journal_dirty(handle, old_dir_bh);
+4
fs/ocfs2/quota_local.c
··· 1240 1240 &od->dq_local_phys_blk, 1241 1241 &pcount, 1242 1242 NULL); 1243 + if (status < 0) { 1244 + mlog_errno(status); 1245 + goto out; 1246 + } 1243 1247 1244 1248 /* Initialize dquot structure on disk */ 1245 1249 status = ocfs2_local_write_dquot(dquot);
+1 -1
fs/pipe.c
··· 864 864 kfree(pipe); 865 865 } 866 866 867 - static struct vfsmount *pipe_mnt __read_mostly; 867 + static struct vfsmount *pipe_mnt __ro_after_init; 868 868 869 869 /* 870 870 * pipefs_dname() is called from d_path().
+4 -3
fs/proc/array.c
··· 536 536 537 537 /* add up live thread stats at the group level */ 538 538 if (whole) { 539 - struct task_struct *t = task; 540 - do { 539 + struct task_struct *t; 540 + 541 + __for_each_thread(sig, t) { 541 542 min_flt += t->min_flt; 542 543 maj_flt += t->maj_flt; 543 544 gtime += task_gtime(t); 544 - } while_each_thread(task, t); 545 + } 545 546 546 547 min_flt += sig->min_flt; 547 548 maj_flt += sig->maj_flt;
+29 -23
fs/proc/base.c
··· 1153 1153 static ssize_t oom_adj_write(struct file *file, const char __user *buf, 1154 1154 size_t count, loff_t *ppos) 1155 1155 { 1156 - char buffer[PROC_NUMBUF]; 1156 + char buffer[PROC_NUMBUF] = {}; 1157 1157 int oom_adj; 1158 1158 int err; 1159 1159 1160 - memset(buffer, 0, sizeof(buffer)); 1161 1160 if (count > sizeof(buffer) - 1) 1162 1161 count = sizeof(buffer) - 1; 1163 1162 if (copy_from_user(buffer, buf, count)) { ··· 1212 1213 static ssize_t oom_score_adj_write(struct file *file, const char __user *buf, 1213 1214 size_t count, loff_t *ppos) 1214 1215 { 1215 - char buffer[PROC_NUMBUF]; 1216 + char buffer[PROC_NUMBUF] = {}; 1216 1217 int oom_score_adj; 1217 1218 int err; 1218 1219 1219 - memset(buffer, 0, sizeof(buffer)); 1220 1220 if (count > sizeof(buffer) - 1) 1221 1221 count = sizeof(buffer) - 1; 1222 1222 if (copy_from_user(buffer, buf, count)) { ··· 1356 1358 const char __user * buf, size_t count, loff_t *ppos) 1357 1359 { 1358 1360 struct task_struct *task; 1359 - char buffer[PROC_NUMBUF]; 1361 + char buffer[PROC_NUMBUF] = {}; 1360 1362 int make_it_fail; 1361 1363 int rv; 1362 1364 1363 1365 if (!capable(CAP_SYS_RESOURCE)) 1364 1366 return -EPERM; 1365 - memset(buffer, 0, sizeof(buffer)); 1367 + 1366 1368 if (count > sizeof(buffer) - 1) 1367 1369 count = sizeof(buffer) - 1; 1368 1370 if (copy_from_user(buffer, buf, count)) ··· 1507 1509 { 1508 1510 struct inode *inode = file_inode(file); 1509 1511 struct task_struct *p; 1510 - char buffer[PROC_NUMBUF]; 1512 + char buffer[PROC_NUMBUF] = {}; 1511 1513 int nice; 1512 1514 int err; 1513 1515 1514 - memset(buffer, 0, sizeof(buffer)); 1515 1516 if (count > sizeof(buffer) - 1) 1516 1517 count = sizeof(buffer) - 1; 1517 1518 if (copy_from_user(buffer, buf, count)) ··· 1663 1666 { 1664 1667 struct inode *inode = file_inode(file); 1665 1668 struct task_struct *p; 1666 - char buffer[TASK_COMM_LEN]; 1669 + char buffer[TASK_COMM_LEN] = {}; 1667 1670 const size_t maxlen = sizeof(buffer) - 1; 1668 1671 1669 - memset(buffer, 0, sizeof(buffer)); 1670 1672 if (copy_from_user(buffer, buf, count > maxlen ? maxlen : count)) 1671 1673 return -EFAULT; 1672 1674 ··· 2972 2976 #ifdef CONFIG_TASK_IO_ACCOUNTING 2973 2977 static int do_io_accounting(struct task_struct *task, struct seq_file *m, int whole) 2974 2978 { 2975 - struct task_io_accounting acct = task->ioac; 2976 - unsigned long flags; 2979 + struct task_io_accounting acct; 2977 2980 int result; 2978 2981 2979 2982 result = down_read_killable(&task->signal->exec_update_lock); ··· 2984 2989 goto out_unlock; 2985 2990 } 2986 2991 2987 - if (whole && lock_task_sighand(task, &flags)) { 2988 - struct task_struct *t = task; 2992 + if (whole) { 2993 + struct signal_struct *sig = task->signal; 2994 + struct task_struct *t; 2995 + unsigned int seq = 1; 2996 + unsigned long flags; 2989 2997 2990 - task_io_accounting_add(&acct, &task->signal->ioac); 2991 - while_each_thread(task, t) 2992 - task_io_accounting_add(&acct, &t->ioac); 2998 + rcu_read_lock(); 2999 + do { 3000 + seq++; /* 2 on the 1st/lockless path, otherwise odd */ 3001 + flags = read_seqbegin_or_lock_irqsave(&sig->stats_lock, &seq); 2993 3002 2994 - unlock_task_sighand(task, &flags); 3003 + acct = sig->ioac; 3004 + __for_each_thread(sig, t) 3005 + task_io_accounting_add(&acct, &t->ioac); 3006 + 3007 + } while (need_seqretry(&sig->stats_lock, seq)); 3008 + done_seqretry_irqrestore(&sig->stats_lock, seq, flags); 3009 + rcu_read_unlock(); 3010 + } else { 3011 + acct = task->ioac; 2995 3012 } 3013 + 2996 3014 seq_printf(m, 2997 3015 "rchar: %llu\n" 2998 3016 "wchar: %llu\n" ··· 3826 3818 for_each_thread(task, pos) { 3827 3819 if (!nr--) 3828 3820 goto found; 3829 - }; 3821 + } 3830 3822 fail: 3831 3823 pos = NULL; 3832 3824 goto out; ··· 3848 3840 struct task_struct *pos = NULL; 3849 3841 rcu_read_lock(); 3850 3842 if (pid_alive(start)) { 3851 - pos = next_thread(start); 3852 - if (thread_group_leader(pos)) 3853 - pos = NULL; 3854 - else 3843 + pos = __next_thread(start); 3844 + if (pos) 3855 3845 get_task_struct(pos); 3856 3846 } 3857 3847 rcu_read_unlock();
+4 -7
fs/proc/inode.c
··· 110 110 111 111 void proc_invalidate_siblings_dcache(struct hlist_head *inodes, spinlock_t *lock) 112 112 { 113 - struct inode *inode; 114 - struct proc_inode *ei; 115 113 struct hlist_node *node; 116 114 struct super_block *old_sb = NULL; 117 115 118 116 rcu_read_lock(); 119 - for (;;) { 117 + while ((node = hlist_first_rcu(inodes))) { 118 + struct proc_inode *ei = hlist_entry(node, struct proc_inode, sibling_inodes); 120 119 struct super_block *sb; 121 - node = hlist_first_rcu(inodes); 122 - if (!node) 123 - break; 124 - ei = hlist_entry(node, struct proc_inode, sibling_inodes); 120 + struct inode *inode; 121 + 125 122 spin_lock(lock); 126 123 hlist_del_init_rcu(&ei->sibling_inodes); 127 124 spin_unlock(lock);
+3 -8
fs/proc/task_mmu.c
··· 851 851 static int show_smap(struct seq_file *m, void *v) 852 852 { 853 853 struct vm_area_struct *vma = v; 854 - struct mem_size_stats mss; 855 - 856 - memset(&mss, 0, sizeof(mss)); 854 + struct mem_size_stats mss = {}; 857 855 858 856 smap_gather_stats(vma, &mss, 0); 859 857 ··· 877 879 static int show_smaps_rollup(struct seq_file *m, void *v) 878 880 { 879 881 struct proc_maps_private *priv = m->private; 880 - struct mem_size_stats mss; 882 + struct mem_size_stats mss = {}; 881 883 struct mm_struct *mm = priv->mm; 882 884 struct vm_area_struct *vma; 883 885 unsigned long vma_start = 0, last_vma_end = 0; ··· 892 894 ret = -ESRCH; 893 895 goto out_put_task; 894 896 } 895 - 896 - memset(&mss, 0, sizeof(mss)); 897 897 898 898 ret = mmap_read_lock_killable(mm); 899 899 if (ret) ··· 1244 1248 size_t count, loff_t *ppos) 1245 1249 { 1246 1250 struct task_struct *task; 1247 - char buffer[PROC_NUMBUF]; 1251 + char buffer[PROC_NUMBUF] = {}; 1248 1252 struct mm_struct *mm; 1249 1253 struct vm_area_struct *vma; 1250 1254 enum clear_refs_types type; 1251 1255 int itype; 1252 1256 int rv; 1253 1257 1254 - memset(buffer, 0, sizeof(buffer)); 1255 1258 if (count > sizeof(buffer) - 1) 1256 1259 count = sizeof(buffer) - 1; 1257 1260 if (copy_from_user(buffer, buf, count))
+1 -1
fs/userfaultfd.c
··· 49 49 }; 50 50 #endif 51 51 52 - static struct kmem_cache *userfaultfd_ctx_cachep __read_mostly; 52 + static struct kmem_cache *userfaultfd_ctx_cachep __ro_after_init; 53 53 54 54 /* 55 55 * Start with fault_pending_wqh and fault_wqh so they're more likely
-5
include/linux/compiler-clang.h
··· 14 14 #undef __cleanup 15 15 #define __cleanup(func) __maybe_unused __attribute__((__cleanup__(func))) 16 16 17 - /* same as gcc, this was present in clang-2.6 so we can assume it works 18 - * with any version that can compile the kernel 19 - */ 20 - #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) 21 - 22 17 /* all clang versions usable with the kernel support KASAN ABI version 5 */ 23 18 #define KASAN_ABI_VERSION 5 24 19
-2
include/linux/compiler-gcc.h
··· 39 39 #define __noretpoline __attribute__((__indirect_branch__("keep"))) 40 40 #endif 41 41 42 - #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) 43 - 44 42 #if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__) 45 43 #define __latent_entropy __attribute__((latent_entropy)) 46 44 #endif
+9 -4
include/linux/compiler.h
··· 177 177 __asm__ ("" : "=r" (var) : "0" (var)) 178 178 #endif 179 179 180 - /* Not-quite-unique ID. */ 181 - #ifndef __UNIQUE_ID 182 - # define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __LINE__) 183 - #endif 180 + #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) 184 181 185 182 /** 186 183 * data_race - mark an expression as containing intentional data races ··· 226 229 227 230 /* &a[0] degrades to a pointer: a different type from an array */ 228 231 #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) 232 + 233 + /* 234 + * This returns a constant expression while determining if an argument is 235 + * a constant expression, most importantly without evaluating the argument. 236 + * Glory to Martin Uecker <Martin.Uecker@med.uni-goettingen.de> 237 + */ 238 + #define __is_constexpr(x) \ 239 + (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) 229 240 230 241 /* 231 242 * Whether 'type' is a signed type or an unsigned type. Supports scalar types,
-8
include/linux/const.h
··· 3 3 4 4 #include <vdso/const.h> 5 5 6 - /* 7 - * This returns a constant expression while determining if an argument is 8 - * a constant expression, most importantly without evaluating the argument. 9 - * Glory to Martin Uecker <Martin.Uecker@med.uni-goettingen.de> 10 - */ 11 - #define __is_constexpr(x) \ 12 - (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) 13 - 14 6 #endif /* _LINUX_CONST_H */
+44 -5
include/linux/crash_core.h
··· 5 5 #include <linux/linkage.h> 6 6 #include <linux/elfcore.h> 7 7 #include <linux/elf.h> 8 + #ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION 9 + #include <asm/crash_core.h> 10 + #endif 11 + 12 + /* Location of a reserved region to hold the crash kernel. 13 + */ 14 + extern struct resource crashk_res; 15 + extern struct resource crashk_low_res; 8 16 9 17 #define CRASH_CORE_NOTE_NAME "CORE" 10 18 #define CRASH_CORE_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4) ··· 87 79 void *data, size_t data_len); 88 80 void final_note(Elf_Word *buf); 89 81 82 + #ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION 83 + #ifndef DEFAULT_CRASH_KERNEL_LOW_SIZE 84 + #define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20) 85 + #endif 86 + #endif 87 + 90 88 int __init parse_crashkernel(char *cmdline, unsigned long long system_ram, 91 - unsigned long long *crash_size, unsigned long long *crash_base); 92 - int parse_crashkernel_high(char *cmdline, unsigned long long system_ram, 93 - unsigned long long *crash_size, unsigned long long *crash_base); 94 - int parse_crashkernel_low(char *cmdline, unsigned long long system_ram, 95 - unsigned long long *crash_size, unsigned long long *crash_base); 89 + unsigned long long *crash_size, unsigned long long *crash_base, 90 + unsigned long long *low_size, bool *high); 91 + 92 + #ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION 93 + #ifndef DEFAULT_CRASH_KERNEL_LOW_SIZE 94 + #define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20) 95 + #endif 96 + #ifndef CRASH_ALIGN 97 + #define CRASH_ALIGN SZ_2M 98 + #endif 99 + #ifndef CRASH_ADDR_LOW_MAX 100 + #define CRASH_ADDR_LOW_MAX SZ_4G 101 + #endif 102 + #ifndef CRASH_ADDR_HIGH_MAX 103 + #define CRASH_ADDR_HIGH_MAX memblock_end_of_DRAM() 104 + #endif 105 + 106 + void __init reserve_crashkernel_generic(char *cmdline, 107 + unsigned long long crash_size, 108 + unsigned long long crash_base, 109 + unsigned long long crash_low_size, 110 + bool high); 111 + #else 112 + static inline void __init reserve_crashkernel_generic(char *cmdline, 113 + unsigned long long crash_size, 114 + unsigned long long crash_base, 115 + unsigned long long crash_low_size, 116 + bool high) 117 + {} 118 + #endif 96 119 97 120 /* Alignment required for elf header segment */ 98 121 #define ELF_CORE_HEADER_ALIGN 4096
+1 -1
include/linux/fortify-string.h
··· 639 639 __q_size_field, #op), \ 640 640 #op ": detected field-spanning write (size %zu) of single %s (size %zu)\n", \ 641 641 __fortify_size, \ 642 - "field \"" #p "\" at " __FILE__ ":" __stringify(__LINE__), \ 642 + "field \"" #p "\" at " FILE_LINE, \ 643 643 __p_size_field); \ 644 644 __underlying_##op(p, q, __fortify_size); \ 645 645 })
-4
include/linux/kexec.h
··· 22 22 #include <uapi/linux/kexec.h> 23 23 #include <linux/verification.h> 24 24 25 - /* Location of a reserved region to hold the crash kernel. 26 - */ 27 - extern struct resource crashk_res; 28 - extern struct resource crashk_low_res; 29 25 extern note_buf_t __percpu *crash_notes; 30 26 31 27 #ifdef CONFIG_KEXEC_CORE
-5
include/linux/kstrtox.h
··· 147 147 extern unsigned long long simple_strtoull(const char *,char **,unsigned int); 148 148 extern long long simple_strtoll(const char *,char **,unsigned int); 149 149 150 - static inline int strtobool(const char *s, bool *res) 151 - { 152 - return kstrtobool(s, res); 153 - } 154 - 155 150 #endif /* _LINUX_KSTRTOX_H */
+1
include/linux/kthread.h
··· 86 86 void kthread_bind(struct task_struct *k, unsigned int cpu); 87 87 void kthread_bind_mask(struct task_struct *k, const struct cpumask *mask); 88 88 int kthread_stop(struct task_struct *k); 89 + int kthread_stop_put(struct task_struct *k); 89 90 bool kthread_should_stop(void); 90 91 bool kthread_should_park(void); 91 92 bool kthread_should_stop_or_park(void);
+71 -58
include/linux/minmax.h
··· 2 2 #ifndef _LINUX_MINMAX_H 3 3 #define _LINUX_MINMAX_H 4 4 5 + #include <linux/build_bug.h> 6 + #include <linux/compiler.h> 5 7 #include <linux/const.h> 6 8 #include <linux/types.h> 7 9 8 10 /* 9 11 * min()/max()/clamp() macros must accomplish three things: 10 12 * 11 - * - avoid multiple evaluations of the arguments (so side-effects like 13 + * - Avoid multiple evaluations of the arguments (so side-effects like 12 14 * "x++" happen only once) when non-constant. 13 - * - perform strict type-checking (to generate warnings instead of 14 - * nasty runtime surprises). See the "unnecessary" pointer comparison 15 - * in __typecheck(). 16 - * - retain result as a constant expressions when called with only 15 + * - Retain result as a constant expressions when called with only 17 16 * constant expressions (to avoid tripping VLA warnings in stack 18 17 * allocation usage). 18 + * - Perform signed v unsigned type-checking (to generate compile 19 + * errors instead of nasty runtime surprises). 20 + * - Unsigned char/short are always promoted to signed int and can be 21 + * compared against signed or unsigned arguments. 22 + * - Unsigned arguments can be compared against non-negative signed constants. 23 + * - Comparison of a signed argument against an unsigned constant fails 24 + * even if the constant is below __INT_MAX__ and could be cast to int. 19 25 */ 20 26 #define __typecheck(x, y) \ 21 27 (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) 22 28 23 - #define __no_side_effects(x, y) \ 24 - (__is_constexpr(x) && __is_constexpr(y)) 29 + /* is_signed_type() isn't a constexpr for pointer types */ 30 + #define __is_signed(x) \ 31 + __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \ 32 + is_signed_type(typeof(x)), 0) 25 33 26 - #define __safe_cmp(x, y) \ 27 - (__typecheck(x, y) && __no_side_effects(x, y)) 34 + /* True for a non-negative signed int constant */ 35 + #define __is_noneg_int(x) \ 36 + (__builtin_choose_expr(__is_constexpr(x) && __is_signed(x), x, -1) >= 0) 28 37 29 - #define __cmp(x, y, op) ((x) op (y) ? (x) : (y)) 38 + #define __types_ok(x, y) \ 39 + (__is_signed(x) == __is_signed(y) || \ 40 + __is_signed((x) + 0) == __is_signed((y) + 0) || \ 41 + __is_noneg_int(x) || __is_noneg_int(y)) 30 42 31 - #define __cmp_once(x, y, unique_x, unique_y, op) ({ \ 32 - typeof(x) unique_x = (x); \ 33 - typeof(y) unique_y = (y); \ 34 - __cmp(unique_x, unique_y, op); }) 43 + #define __cmp_op_min < 44 + #define __cmp_op_max > 35 45 36 - #define __careful_cmp(x, y, op) \ 37 - __builtin_choose_expr(__safe_cmp(x, y), \ 38 - __cmp(x, y, op), \ 39 - __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op)) 46 + #define __cmp(op, x, y) ((x) __cmp_op_##op (y) ? (x) : (y)) 47 + 48 + #define __cmp_once(op, x, y, unique_x, unique_y) ({ \ 49 + typeof(x) unique_x = (x); \ 50 + typeof(y) unique_y = (y); \ 51 + static_assert(__types_ok(x, y), \ 52 + #op "(" #x ", " #y ") signedness error, fix types or consider u" #op "() before " #op "_t()"); \ 53 + __cmp(op, unique_x, unique_y); }) 54 + 55 + #define __careful_cmp(op, x, y) \ 56 + __builtin_choose_expr(__is_constexpr((x) - (y)), \ 57 + __cmp(op, x, y), \ 58 + __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y))) 40 59 41 60 #define __clamp(val, lo, hi) \ 42 61 ((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val))) 43 62 44 - #define __clamp_once(val, lo, hi, unique_val, unique_lo, unique_hi) ({ \ 45 - typeof(val) unique_val = (val); \ 46 - typeof(lo) unique_lo = (lo); \ 47 - typeof(hi) unique_hi = (hi); \ 48 - __clamp(unique_val, unique_lo, unique_hi); }) 49 - 50 - #define __clamp_input_check(lo, hi) \ 51 - (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \ 52 - __is_constexpr((lo) > (hi)), (lo) > (hi), false))) 63 + #define __clamp_once(val, lo, hi, unique_val, unique_lo, unique_hi) ({ \ 64 + typeof(val) unique_val = (val); \ 65 + typeof(lo) unique_lo = (lo); \ 66 + typeof(hi) unique_hi = (hi); \ 67 + static_assert(__builtin_choose_expr(__is_constexpr((lo) > (hi)), \ 68 + (lo) <= (hi), true), \ 69 + "clamp() low limit " #lo " greater than high limit " #hi); \ 70 + static_assert(__types_ok(val, lo), "clamp() 'lo' signedness error"); \ 71 + static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error"); \ 72 + __clamp(unique_val, unique_lo, unique_hi); }) 53 73 54 74 #define __careful_clamp(val, lo, hi) ({ \ 55 - __clamp_input_check(lo, hi) + \ 56 - __builtin_choose_expr(__typecheck(val, lo) && __typecheck(val, hi) && \ 57 - __typecheck(hi, lo) && __is_constexpr(val) && \ 58 - __is_constexpr(lo) && __is_constexpr(hi), \ 75 + __builtin_choose_expr(__is_constexpr((val) - (lo) + (hi)), \ 59 76 __clamp(val, lo, hi), \ 60 77 __clamp_once(val, lo, hi, __UNIQUE_ID(__val), \ 61 78 __UNIQUE_ID(__lo), __UNIQUE_ID(__hi))); }) ··· 82 65 * @x: first value 83 66 * @y: second value 84 67 */ 85 - #define min(x, y) __careful_cmp(x, y, <) 68 + #define min(x, y) __careful_cmp(min, x, y) 86 69 87 70 /** 88 71 * max - return maximum of two values of the same or compatible types 89 72 * @x: first value 90 73 * @y: second value 91 74 */ 92 - #define max(x, y) __careful_cmp(x, y, >) 75 + #define max(x, y) __careful_cmp(max, x, y) 76 + 77 + /** 78 + * umin - return minimum of two non-negative values 79 + * Signed types are zero extended to match a larger unsigned type. 80 + * @x: first value 81 + * @y: second value 82 + */ 83 + #define umin(x, y) \ 84 + __careful_cmp(min, (x) + 0u + 0ul + 0ull, (y) + 0u + 0ul + 0ull) 85 + 86 + /** 87 + * umax - return maximum of two non-negative values 88 + * @x: first value 89 + * @y: second value 90 + */ 91 + #define umax(x, y) \ 92 + __careful_cmp(max, (x) + 0u + 0ul + 0ull, (y) + 0u + 0ul + 0ull) 93 93 94 94 /** 95 95 * min3 - return minimum of three values ··· 158 124 * @x: first value 159 125 * @y: second value 160 126 */ 161 - #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) 127 + #define min_t(type, x, y) __careful_cmp(min, (type)(x), (type)(y)) 162 128 163 129 /** 164 130 * max_t - return maximum of two values, using the specified type ··· 166 132 * @x: first value 167 133 * @y: second value 168 134 */ 169 - #define max_t(type, x, y) __careful_cmp((type)(x), (type)(y), >) 170 - 171 - /* 172 - * Remove a const qualifier from integer types 173 - * _Generic(foo, type-name: association, ..., default: association) performs a 174 - * comparison against the foo type (not the qualified type). 175 - * Do not use the const keyword in the type-name as it will not match the 176 - * unqualified type of foo. 177 - */ 178 - #define __unconst_integer_type_cases(type) \ 179 - unsigned type: (unsigned type)0, \ 180 - signed type: (signed type)0 181 - 182 - #define __unconst_integer_typeof(x) typeof( \ 183 - _Generic((x), \ 184 - char: (char)0, \ 185 - __unconst_integer_type_cases(char), \ 186 - __unconst_integer_type_cases(short), \ 187 - __unconst_integer_type_cases(int), \ 188 - __unconst_integer_type_cases(long), \ 189 - __unconst_integer_type_cases(long long), \ 190 - default: (x))) 135 + #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y)) 191 136 192 137 /* 193 138 * Do not check the array parameter using __must_be_array(). ··· 182 169 * 'int *buff' and 'int buff[N]' types. 183 170 * 184 171 * The array can be an array of const items. 185 - * typeof() keeps the const qualifier. Use __unconst_integer_typeof() in order 172 + * typeof() keeps the const qualifier. Use __unqual_scalar_typeof() in order 186 173 * to discard the const qualifier for the __element variable. 187 174 */ 188 175 #define __minmax_array(op, array, len) ({ \ 189 176 typeof(&(array)[0]) __array = (array); \ 190 177 typeof(len) __len = (len); \ 191 - __unconst_integer_typeof(__array[0]) __element = __array[--__len]; \ 178 + __unqual_scalar_typeof(__array[0]) __element = __array[--__len];\ 192 179 while (__len--) \ 193 180 __element = op(__element, __array[__len]); \ 194 181 __element; })
-1
include/linux/sched.h
··· 1007 1007 /* PID/PID hash table linkage. */ 1008 1008 struct pid *thread_pid; 1009 1009 struct hlist_node pid_links[PIDTYPE_MAX]; 1010 - struct list_head thread_group; 1011 1010 struct list_head thread_node; 1012 1011 1013 1012 struct completion *vfork_done;
+15 -4
include/linux/sched/signal.h
··· 707 707 return p1->signal == p2->signal; 708 708 } 709 709 710 - static inline struct task_struct *next_thread(const struct task_struct *p) 710 + /* 711 + * returns NULL if p is the last thread in the thread group 712 + */ 713 + static inline struct task_struct *__next_thread(struct task_struct *p) 711 714 { 712 - return list_entry_rcu(p->thread_group.next, 713 - struct task_struct, thread_group); 715 + return list_next_or_null_rcu(&p->signal->thread_head, 716 + &p->thread_node, 717 + struct task_struct, 718 + thread_node); 719 + } 720 + 721 + static inline struct task_struct *next_thread(struct task_struct *p) 722 + { 723 + return __next_thread(p) ?: p->group_leader; 714 724 } 715 725 716 726 static inline int thread_group_empty(struct task_struct *p) 717 727 { 718 - return list_empty(&p->thread_group); 728 + return thread_group_leader(p) && 729 + list_is_last(&p->thread_node, &p->signal->thread_head); 719 730 } 720 731 721 732 #define delay_group_leader(p) \
+15
include/linux/seq_file.h
··· 207 207 .release = single_release, \ 208 208 } 209 209 210 + #define DEFINE_SHOW_STORE_ATTRIBUTE(__name) \ 211 + static int __name ## _open(struct inode *inode, struct file *file) \ 212 + { \ 213 + return single_open(file, __name ## _show, inode->i_private); \ 214 + } \ 215 + \ 216 + static const struct file_operations __name ## _fops = { \ 217 + .owner = THIS_MODULE, \ 218 + .open = __name ## _open, \ 219 + .read = seq_read, \ 220 + .write = __name ## _write, \ 221 + .llseek = seq_lseek, \ 222 + .release = single_release, \ 223 + } 224 + 210 225 #define DEFINE_PROC_SHOW_ATTRIBUTE(__name) \ 211 226 static int __name ## _open(struct inode *inode, struct file *file) \ 212 227 { \
+2
include/linux/stringify.h
··· 9 9 #define __stringify_1(x...) #x 10 10 #define __stringify(x...) __stringify_1(x) 11 11 12 + #define FILE_LINE __FILE__ ":" __stringify(__LINE__) 13 + 12 14 #endif /* !__LINUX_STRINGIFY_H */
+1 -2
include/linux/timer.h
··· 77 77 .entry = { .next = TIMER_ENTRY_STATIC }, \ 78 78 .function = (_function), \ 79 79 .flags = (_flags), \ 80 - __TIMER_LOCKDEP_MAP_INITIALIZER( \ 81 - __FILE__ ":" __stringify(__LINE__)) \ 80 + __TIMER_LOCKDEP_MAP_INITIALIZER(FILE_LINE) \ 82 81 } 83 82 84 83 #define DEFINE_TIMER(_name, _function) \
-1
init/init_task.c
··· 133 133 .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(init_task.pi_lock), 134 134 .timer_slack_ns = 50000, /* 50 usec default slack */ 135 135 .thread_pid = &init_struct_pid, 136 - .thread_group = LIST_HEAD_INIT(init_task.thread_group), 137 136 .thread_node = LIST_HEAD_INIT(init_signals.thread_head), 138 137 #ifdef CONFIG_AUDIT 139 138 .loginuid = INVALID_UID,
+1 -1
kernel/Kconfig.kexec
··· 110 110 For more details see Documentation/admin-guide/kdump/kdump.rst 111 111 112 112 For s390, this option also enables zfcpdump. 113 - See also <file:Documentation/s390/zfcpdump.rst> 113 + See also <file:Documentation/arch/s390/zfcpdump.rst> 114 114 115 115 config CRASH_HOTPLUG 116 116 bool "Update the crash elfcorehdr on system configuration changes"
+2 -2
kernel/audit_tree.c
··· 87 87 * that makes a difference. Some. 88 88 */ 89 89 90 - static struct fsnotify_group *audit_tree_group; 91 - static struct kmem_cache *audit_tree_mark_cachep __read_mostly; 90 + static struct fsnotify_group *audit_tree_group __ro_after_init; 91 + static struct kmem_cache *audit_tree_mark_cachep __ro_after_init; 92 92 93 93 static struct audit_tree *alloc_tree(const char *s) 94 94 {
+163 -21
kernel/crash_core.c
··· 5 5 */ 6 6 7 7 #include <linux/buildid.h> 8 - #include <linux/crash_core.h> 9 8 #include <linux/init.h> 10 9 #include <linux/utsname.h> 11 10 #include <linux/vmalloc.h> ··· 12 13 #include <linux/kexec.h> 13 14 #include <linux/memory.h> 14 15 #include <linux/cpuhotplug.h> 16 + #include <linux/memblock.h> 17 + #include <linux/kexec.h> 18 + #include <linux/kmemleak.h> 15 19 16 20 #include <asm/page.h> 17 21 #include <asm/sections.h> ··· 34 32 35 33 /* trusted vmcoreinfo, e.g. we can make a copy in the crash memory */ 36 34 static unsigned char *vmcoreinfo_data_safecopy; 35 + 36 + /* Location of the reserved area for the crash kernel */ 37 + struct resource crashk_res = { 38 + .name = "Crash kernel", 39 + .start = 0, 40 + .end = 0, 41 + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, 42 + .desc = IORES_DESC_CRASH_KERNEL 43 + }; 44 + struct resource crashk_low_res = { 45 + .name = "Crash kernel", 46 + .start = 0, 47 + .end = 0, 48 + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, 49 + .desc = IORES_DESC_CRASH_KERNEL 50 + }; 37 51 38 52 /* 39 53 * parsing the "crashkernel" commandline ··· 266 248 unsigned long long system_ram, 267 249 unsigned long long *crash_size, 268 250 unsigned long long *crash_base, 269 - const char *name, 270 251 const char *suffix) 271 252 { 272 253 char *first_colon, *first_space; 273 254 char *ck_cmdline; 255 + char *name = "crashkernel="; 274 256 275 257 BUG_ON(!crash_size || !crash_base); 276 258 *crash_size = 0; ··· 301 283 /* 302 284 * That function is the entry point for command line parsing and should be 303 285 * called from the arch-specific code. 286 + * 287 + * If crashkernel=,high|low is supported on architecture, non-NULL values 288 + * should be passed to parameters 'low_size' and 'high'. 304 289 */ 305 290 int __init parse_crashkernel(char *cmdline, 306 291 unsigned long long system_ram, 307 292 unsigned long long *crash_size, 308 - unsigned long long *crash_base) 293 + unsigned long long *crash_base, 294 + unsigned long long *low_size, 295 + bool *high) 309 296 { 310 - return __parse_crashkernel(cmdline, system_ram, crash_size, crash_base, 311 - "crashkernel=", NULL); 312 - } 297 + int ret; 313 298 314 - int __init parse_crashkernel_high(char *cmdline, 315 - unsigned long long system_ram, 316 - unsigned long long *crash_size, 317 - unsigned long long *crash_base) 318 - { 319 - return __parse_crashkernel(cmdline, system_ram, crash_size, crash_base, 320 - "crashkernel=", suffix_tbl[SUFFIX_HIGH]); 321 - } 299 + /* crashkernel=X[@offset] */ 300 + ret = __parse_crashkernel(cmdline, system_ram, crash_size, 301 + crash_base, NULL); 302 + #ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION 303 + /* 304 + * If non-NULL 'high' passed in and no normal crashkernel 305 + * setting detected, try parsing crashkernel=,high|low. 306 + */ 307 + if (high && ret == -ENOENT) { 308 + ret = __parse_crashkernel(cmdline, 0, crash_size, 309 + crash_base, suffix_tbl[SUFFIX_HIGH]); 310 + if (ret || !*crash_size) 311 + return -EINVAL; 322 312 323 - int __init parse_crashkernel_low(char *cmdline, 324 - unsigned long long system_ram, 325 - unsigned long long *crash_size, 326 - unsigned long long *crash_base) 327 - { 328 - return __parse_crashkernel(cmdline, system_ram, crash_size, crash_base, 329 - "crashkernel=", suffix_tbl[SUFFIX_LOW]); 313 + /* 314 + * crashkernel=Y,low can be specified or not, but invalid value 315 + * is not allowed. 316 + */ 317 + ret = __parse_crashkernel(cmdline, 0, low_size, 318 + crash_base, suffix_tbl[SUFFIX_LOW]); 319 + if (ret == -ENOENT) { 320 + *low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; 321 + ret = 0; 322 + } else if (ret) { 323 + return ret; 324 + } 325 + 326 + *high = true; 327 + } 328 + #endif 329 + if (!*crash_size) 330 + ret = -EINVAL; 331 + 332 + return ret; 330 333 } 331 334 332 335 /* ··· 359 320 return 0; 360 321 } 361 322 early_param("crashkernel", parse_crashkernel_dummy); 323 + 324 + #ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION 325 + static int __init reserve_crashkernel_low(unsigned long long low_size) 326 + { 327 + #ifdef CONFIG_64BIT 328 + unsigned long long low_base; 329 + 330 + low_base = memblock_phys_alloc_range(low_size, CRASH_ALIGN, 0, CRASH_ADDR_LOW_MAX); 331 + if (!low_base) { 332 + pr_err("cannot allocate crashkernel low memory (size:0x%llx).\n", low_size); 333 + return -ENOMEM; 334 + } 335 + 336 + pr_info("crashkernel low memory reserved: 0x%08llx - 0x%08llx (%lld MB)\n", 337 + low_base, low_base + low_size, low_size >> 20); 338 + 339 + crashk_low_res.start = low_base; 340 + crashk_low_res.end = low_base + low_size - 1; 341 + insert_resource(&iomem_resource, &crashk_low_res); 342 + #endif 343 + return 0; 344 + } 345 + 346 + void __init reserve_crashkernel_generic(char *cmdline, 347 + unsigned long long crash_size, 348 + unsigned long long crash_base, 349 + unsigned long long crash_low_size, 350 + bool high) 351 + { 352 + unsigned long long search_end = CRASH_ADDR_LOW_MAX, search_base = 0; 353 + bool fixed_base = false; 354 + 355 + /* User specifies base address explicitly. */ 356 + if (crash_base) { 357 + fixed_base = true; 358 + search_base = crash_base; 359 + search_end = crash_base + crash_size; 360 + } else if (high) { 361 + search_base = CRASH_ADDR_LOW_MAX; 362 + search_end = CRASH_ADDR_HIGH_MAX; 363 + } 364 + 365 + retry: 366 + crash_base = memblock_phys_alloc_range(crash_size, CRASH_ALIGN, 367 + search_base, search_end); 368 + if (!crash_base) { 369 + /* 370 + * For crashkernel=size[KMG]@offset[KMG], print out failure 371 + * message if can't reserve the specified region. 372 + */ 373 + if (fixed_base) { 374 + pr_warn("crashkernel reservation failed - memory is in use.\n"); 375 + return; 376 + } 377 + 378 + /* 379 + * For crashkernel=size[KMG], if the first attempt was for 380 + * low memory, fall back to high memory, the minimum required 381 + * low memory will be reserved later. 382 + */ 383 + if (!high && search_end == CRASH_ADDR_LOW_MAX) { 384 + search_end = CRASH_ADDR_HIGH_MAX; 385 + search_base = CRASH_ADDR_LOW_MAX; 386 + crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; 387 + goto retry; 388 + } 389 + 390 + /* 391 + * For crashkernel=size[KMG],high, if the first attempt was 392 + * for high memory, fall back to low memory. 393 + */ 394 + if (high && search_end == CRASH_ADDR_HIGH_MAX) { 395 + search_end = CRASH_ADDR_LOW_MAX; 396 + search_base = 0; 397 + goto retry; 398 + } 399 + pr_warn("cannot allocate crashkernel (size:0x%llx)\n", 400 + crash_size); 401 + return; 402 + } 403 + 404 + if ((crash_base > CRASH_ADDR_LOW_MAX) && 405 + crash_low_size && reserve_crashkernel_low(crash_low_size)) { 406 + memblock_phys_free(crash_base, crash_size); 407 + return; 408 + } 409 + 410 + pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n", 411 + crash_base, crash_base + crash_size, crash_size >> 20); 412 + 413 + /* 414 + * The crashkernel memory will be removed from the kernel linear 415 + * map. Inform kmemleak so that it won't try to access it. 416 + */ 417 + kmemleak_ignore_phys(crash_base); 418 + if (crashk_low_res.end) 419 + kmemleak_ignore_phys(crashk_low_res.start); 420 + 421 + crashk_res.start = crash_base; 422 + crashk_res.end = crash_base + crash_size - 1; 423 + insert_resource(&iomem_resource, &crashk_res); 424 + } 425 + #endif 362 426 363 427 int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, 364 428 void **addr, unsigned long *sz)
-1
kernel/exit.c
··· 135 135 list_del_init(&p->sibling); 136 136 __this_cpu_dec(process_counts); 137 137 } 138 - list_del_rcu(&p->thread_group); 139 138 list_del_rcu(&p->thread_node); 140 139 } 141 140
-3
kernel/fork.c
··· 2577 2577 p->dirty_paused_when = 0; 2578 2578 2579 2579 p->pdeath_signal = 0; 2580 - INIT_LIST_HEAD(&p->thread_group); 2581 2580 p->task_works = NULL; 2582 2581 clear_posix_cputimers_work(p); 2583 2582 ··· 2704 2705 atomic_inc(&current->signal->live); 2705 2706 refcount_inc(&current->signal->sigcnt); 2706 2707 task_join_group_stop(p); 2707 - list_add_tail_rcu(&p->thread_group, 2708 - &p->group_leader->thread_group); 2709 2708 list_add_tail_rcu(&p->thread_node, 2710 2709 &p->signal->thread_head); 2711 2710 }
+1 -1
kernel/gcov/fs.c
··· 99 99 struct gcov_info *info; 100 100 size_t size; 101 101 loff_t pos; 102 - char buffer[]; 102 + char buffer[] __counted_by(size); 103 103 }; 104 104 105 105 /**
+5 -10
kernel/irq/manage.c
··· 1852 1852 struct task_struct *t = new->thread; 1853 1853 1854 1854 new->thread = NULL; 1855 - kthread_stop(t); 1856 - put_task_struct(t); 1855 + kthread_stop_put(t); 1857 1856 } 1858 1857 if (new->secondary && new->secondary->thread) { 1859 1858 struct task_struct *t = new->secondary->thread; 1860 1859 1861 1860 new->secondary->thread = NULL; 1862 - kthread_stop(t); 1863 - put_task_struct(t); 1861 + kthread_stop_put(t); 1864 1862 } 1865 1863 out_mput: 1866 1864 module_put(desc->owner); ··· 1969 1971 * the same bit to a newly requested action. 1970 1972 */ 1971 1973 if (action->thread) { 1972 - kthread_stop(action->thread); 1973 - put_task_struct(action->thread); 1974 - if (action->secondary && action->secondary->thread) { 1975 - kthread_stop(action->secondary->thread); 1976 - put_task_struct(action->secondary->thread); 1977 - } 1974 + kthread_stop_put(action->thread); 1975 + if (action->secondary && action->secondary->thread) 1976 + kthread_stop_put(action->secondary->thread); 1978 1977 } 1979 1978 1980 1979 /* Last action releases resources */
-17
kernel/kexec_core.c
··· 52 52 /* Flag to indicate we are going to kexec a new kernel */ 53 53 bool kexec_in_progress = false; 54 54 55 - 56 - /* Location of the reserved area for the crash kernel */ 57 - struct resource crashk_res = { 58 - .name = "Crash kernel", 59 - .start = 0, 60 - .end = 0, 61 - .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, 62 - .desc = IORES_DESC_CRASH_KERNEL 63 - }; 64 - struct resource crashk_low_res = { 65 - .name = "Crash kernel", 66 - .start = 0, 67 - .end = 0, 68 - .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, 69 - .desc = IORES_DESC_CRASH_KERNEL 70 - }; 71 - 72 55 int kexec_should_crash(struct task_struct *p) 73 56 { 74 57 /*
+18
kernel/kthread.c
··· 715 715 } 716 716 EXPORT_SYMBOL(kthread_stop); 717 717 718 + /** 719 + * kthread_stop_put - stop a thread and put its task struct 720 + * @k: thread created by kthread_create(). 721 + * 722 + * Stops a thread created by kthread_create() and put its task_struct. 723 + * Only use when holding an extra task struct reference obtained by 724 + * calling get_task_struct(). 725 + */ 726 + int kthread_stop_put(struct task_struct *k) 727 + { 728 + int ret; 729 + 730 + ret = kthread_stop(k); 731 + put_task_struct(k); 732 + return ret; 733 + } 734 + EXPORT_SYMBOL(kthread_stop_put); 735 + 718 736 int kthreadd(void *unused) 719 737 { 720 738 struct task_struct *tsk = current;
+13 -9
kernel/panic.c
··· 192 192 */ 193 193 void nmi_panic(struct pt_regs *regs, const char *msg) 194 194 { 195 - int old_cpu, cpu; 195 + int old_cpu, this_cpu; 196 196 197 - cpu = raw_smp_processor_id(); 198 - old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, cpu); 197 + old_cpu = PANIC_CPU_INVALID; 198 + this_cpu = raw_smp_processor_id(); 199 199 200 - if (old_cpu == PANIC_CPU_INVALID) 200 + /* atomic_try_cmpxchg updates old_cpu on failure */ 201 + if (atomic_try_cmpxchg(&panic_cpu, &old_cpu, this_cpu)) 201 202 panic("%s", msg); 202 - else if (old_cpu != cpu) 203 + else if (old_cpu != this_cpu) 203 204 nmi_panic_self_stop(regs); 204 205 } 205 206 EXPORT_SYMBOL(nmi_panic); ··· 312 311 * stop themself or will wait until they are stopped by the 1st CPU 313 312 * with smp_send_stop(). 314 313 * 315 - * `old_cpu == PANIC_CPU_INVALID' means this is the 1st CPU which 316 - * comes here, so go ahead. 314 + * cmpxchg success means this is the 1st CPU which comes here, 315 + * so go ahead. 317 316 * `old_cpu == this_cpu' means we came from nmi_panic() which sets 318 317 * panic_cpu to this CPU. In this case, this is also the 1st CPU. 319 318 */ 319 + old_cpu = PANIC_CPU_INVALID; 320 320 this_cpu = raw_smp_processor_id(); 321 - old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, this_cpu); 322 321 323 - if (old_cpu != PANIC_CPU_INVALID && old_cpu != this_cpu) 322 + /* atomic_try_cmpxchg updates old_cpu on failure */ 323 + if (atomic_try_cmpxchg(&panic_cpu, &old_cpu, this_cpu)) { 324 + /* go ahead */ 325 + } else if (old_cpu != this_cpu) 324 326 panic_smp_self_stop(); 325 327 326 328 console_verbose();
-6
kernel/pid_namespace.c
··· 286 286 if (write && !checkpoint_restore_ns_capable(pid_ns->user_ns)) 287 287 return -EPERM; 288 288 289 - /* 290 - * Writing directly to ns' last_pid field is OK, since this field 291 - * is volatile in a living namespace anyway and a code writing to 292 - * it should synchronize its usage with external means. 293 - */ 294 - 295 289 next = idr_get_cursor(&pid_ns->idr) - 1; 296 290 297 291 tmp.data = &next;
+1 -1
kernel/sched/core.c
··· 9869 9869 LIST_HEAD(task_groups); 9870 9870 9871 9871 /* Cacheline aligned slab cache for task_group */ 9872 - static struct kmem_cache *task_group_cache __read_mostly; 9872 + static struct kmem_cache *task_group_cache __ro_after_init; 9873 9873 #endif 9874 9874 9875 9875 void __init sched_init(void)
+14 -10
kernel/signal.c
··· 415 415 int override_rlimit, const unsigned int sigqueue_flags) 416 416 { 417 417 struct sigqueue *q = NULL; 418 - struct ucounts *ucounts = NULL; 418 + struct ucounts *ucounts; 419 419 long sigpending; 420 420 421 421 /* ··· 1058 1058 signal->flags = SIGNAL_GROUP_EXIT; 1059 1059 signal->group_exit_code = sig; 1060 1060 signal->group_stop_count = 0; 1061 - t = p; 1062 - do { 1061 + __for_each_thread(signal, t) { 1063 1062 task_clear_jobctl_pending(t, JOBCTL_PENDING_MASK); 1064 1063 sigaddset(&t->pending.signal, SIGKILL); 1065 1064 signal_wake_up(t, 1); 1066 - } while_each_thread(p, t); 1065 + } 1067 1066 return; 1068 1067 } 1069 1068 } ··· 1470 1471 int __kill_pgrp_info(int sig, struct kernel_siginfo *info, struct pid *pgrp) 1471 1472 { 1472 1473 struct task_struct *p = NULL; 1473 - int retval, success; 1474 + int ret = -ESRCH; 1474 1475 1475 - success = 0; 1476 - retval = -ESRCH; 1477 1476 do_each_pid_task(pgrp, PIDTYPE_PGID, p) { 1478 1477 int err = group_send_sig_info(sig, info, p, PIDTYPE_PGID); 1479 - success |= !err; 1480 - retval = err; 1478 + /* 1479 + * If group_send_sig_info() succeeds at least once ret 1480 + * becomes 0 and after that the code below has no effect. 1481 + * Otherwise we return the last err or -ESRCH if this 1482 + * process group is empty. 1483 + */ 1484 + if (ret) 1485 + ret = err; 1481 1486 } while_each_pid_task(pgrp, PIDTYPE_PGID, p); 1482 - return success ? 0 : retval; 1487 + 1488 + return ret; 1483 1489 } 1484 1490 1485 1491 int kill_pid_info(int sig, struct kernel_siginfo *info, struct pid *pid)
+1 -2
kernel/smpboot.c
··· 272 272 struct task_struct *tsk = *per_cpu_ptr(ht->store, cpu); 273 273 274 274 if (tsk) { 275 - kthread_stop(tsk); 276 - put_task_struct(tsk); 275 + kthread_stop_put(tsk); 277 276 *per_cpu_ptr(ht->store, cpu) = NULL; 278 277 } 279 278 }
+20 -21
kernel/sys.c
··· 1786 1786 unsigned long flags; 1787 1787 u64 tgutime, tgstime, utime, stime; 1788 1788 unsigned long maxrss = 0; 1789 + struct signal_struct *sig = p->signal; 1789 1790 1790 1791 memset((char *)r, 0, sizeof (*r)); 1791 1792 utime = stime = 0; ··· 1794 1793 if (who == RUSAGE_THREAD) { 1795 1794 task_cputime_adjusted(current, &utime, &stime); 1796 1795 accumulate_thread_rusage(p, r); 1797 - maxrss = p->signal->maxrss; 1796 + maxrss = sig->maxrss; 1798 1797 goto out; 1799 1798 } 1800 1799 ··· 1804 1803 switch (who) { 1805 1804 case RUSAGE_BOTH: 1806 1805 case RUSAGE_CHILDREN: 1807 - utime = p->signal->cutime; 1808 - stime = p->signal->cstime; 1809 - r->ru_nvcsw = p->signal->cnvcsw; 1810 - r->ru_nivcsw = p->signal->cnivcsw; 1811 - r->ru_minflt = p->signal->cmin_flt; 1812 - r->ru_majflt = p->signal->cmaj_flt; 1813 - r->ru_inblock = p->signal->cinblock; 1814 - r->ru_oublock = p->signal->coublock; 1815 - maxrss = p->signal->cmaxrss; 1806 + utime = sig->cutime; 1807 + stime = sig->cstime; 1808 + r->ru_nvcsw = sig->cnvcsw; 1809 + r->ru_nivcsw = sig->cnivcsw; 1810 + r->ru_minflt = sig->cmin_flt; 1811 + r->ru_majflt = sig->cmaj_flt; 1812 + r->ru_inblock = sig->cinblock; 1813 + r->ru_oublock = sig->coublock; 1814 + maxrss = sig->cmaxrss; 1816 1815 1817 1816 if (who == RUSAGE_CHILDREN) 1818 1817 break; ··· 1822 1821 thread_group_cputime_adjusted(p, &tgutime, &tgstime); 1823 1822 utime += tgutime; 1824 1823 stime += tgstime; 1825 - r->ru_nvcsw += p->signal->nvcsw; 1826 - r->ru_nivcsw += p->signal->nivcsw; 1827 - r->ru_minflt += p->signal->min_flt; 1828 - r->ru_majflt += p->signal->maj_flt; 1829 - r->ru_inblock += p->signal->inblock; 1830 - r->ru_oublock += p->signal->oublock; 1831 - if (maxrss < p->signal->maxrss) 1832 - maxrss = p->signal->maxrss; 1833 - t = p; 1834 - do { 1824 + r->ru_nvcsw += sig->nvcsw; 1825 + r->ru_nivcsw += sig->nivcsw; 1826 + r->ru_minflt += sig->min_flt; 1827 + r->ru_majflt += sig->maj_flt; 1828 + r->ru_inblock += sig->inblock; 1829 + r->ru_oublock += sig->oublock; 1830 + if (maxrss < sig->maxrss) 1831 + maxrss = sig->maxrss; 1832 + __for_each_thread(sig, t) 1835 1833 accumulate_thread_rusage(t, r); 1836 - } while_each_thread(p, t); 1837 1834 break; 1838 1835 1839 1836 default:
+2 -3
kernel/taskstats.c
··· 233 233 else 234 234 memset(stats, 0, sizeof(*stats)); 235 235 236 - tsk = first; 237 236 start_time = ktime_get_ns(); 238 - do { 237 + for_each_thread(first, tsk) { 239 238 if (tsk->exit_state) 240 239 continue; 241 240 /* ··· 257 258 258 259 stats->nvcsw += tsk->nvcsw; 259 260 stats->nivcsw += tsk->nivcsw; 260 - } while_each_thread(first, tsk); 261 + } 261 262 262 263 unlock_task_sighand(first, &flags); 263 264 rc = 0;
+1 -1
kernel/user_namespace.c
··· 22 22 #include <linux/bsearch.h> 23 23 #include <linux/sort.h> 24 24 25 - static struct kmem_cache *user_ns_cachep __read_mostly; 25 + static struct kmem_cache *user_ns_cachep __ro_after_init; 26 26 static DEFINE_MUTEX(userns_state_mutex); 27 27 28 28 static bool new_idmap_permitted(const struct file *file,
+8 -8
kernel/workqueue.c
··· 418 418 * process context while holding a pool lock. Bounce to a dedicated kthread 419 419 * worker to avoid A-A deadlocks. 420 420 */ 421 - static struct kthread_worker *pwq_release_worker; 421 + static struct kthread_worker *pwq_release_worker __ro_after_init; 422 422 423 - struct workqueue_struct *system_wq __read_mostly; 423 + struct workqueue_struct *system_wq __ro_after_init; 424 424 EXPORT_SYMBOL(system_wq); 425 - struct workqueue_struct *system_highpri_wq __read_mostly; 425 + struct workqueue_struct *system_highpri_wq __ro_after_init; 426 426 EXPORT_SYMBOL_GPL(system_highpri_wq); 427 - struct workqueue_struct *system_long_wq __read_mostly; 427 + struct workqueue_struct *system_long_wq __ro_after_init; 428 428 EXPORT_SYMBOL_GPL(system_long_wq); 429 - struct workqueue_struct *system_unbound_wq __read_mostly; 429 + struct workqueue_struct *system_unbound_wq __ro_after_init; 430 430 EXPORT_SYMBOL_GPL(system_unbound_wq); 431 - struct workqueue_struct *system_freezable_wq __read_mostly; 431 + struct workqueue_struct *system_freezable_wq __ro_after_init; 432 432 EXPORT_SYMBOL_GPL(system_freezable_wq); 433 - struct workqueue_struct *system_power_efficient_wq __read_mostly; 433 + struct workqueue_struct *system_power_efficient_wq __ro_after_init; 434 434 EXPORT_SYMBOL_GPL(system_power_efficient_wq); 435 - struct workqueue_struct *system_freezable_power_efficient_wq __read_mostly; 435 + struct workqueue_struct *system_freezable_power_efficient_wq __ro_after_init; 436 436 EXPORT_SYMBOL_GPL(system_freezable_power_efficient_wq); 437 437 438 438 static int worker_thread(void *__worker);
+1 -1
lib/debugobjects.c
··· 89 89 static int debug_objects_pool_min_level __read_mostly 90 90 = ODEBUG_POOL_MIN_LEVEL; 91 91 static const struct debug_obj_descr *descr_test __read_mostly; 92 - static struct kmem_cache *obj_cache __read_mostly; 92 + static struct kmem_cache *obj_cache __ro_after_init; 93 93 94 94 /* 95 95 * Track numbers of kmem_cache_alloc()/free() calls done.
+1 -2
mm/damon/core.c
··· 735 735 if (tsk) { 736 736 get_task_struct(tsk); 737 737 mutex_unlock(&ctx->kdamond_lock); 738 - kthread_stop(tsk); 739 - put_task_struct(tsk); 738 + kthread_stop_put(tsk); 740 739 return 0; 741 740 } 742 741 mutex_unlock(&ctx->kdamond_lock);
+1 -1
mm/khugepaged.c
··· 91 91 #define MM_SLOTS_HASH_BITS 10 92 92 static DEFINE_READ_MOSTLY_HASHTABLE(mm_slots_hash, MM_SLOTS_HASH_BITS); 93 93 94 - static struct kmem_cache *mm_slot_cache __read_mostly; 94 + static struct kmem_cache *mm_slot_cache __ro_after_init; 95 95 96 96 struct collapse_control { 97 97 bool is_khugepaged;
+4 -4
mm/shmem.c
··· 42 42 #include <linux/iversion.h> 43 43 #include "swap.h" 44 44 45 - static struct vfsmount *shm_mnt; 45 + static struct vfsmount *shm_mnt __ro_after_init; 46 46 47 47 #ifdef CONFIG_SHMEM 48 48 /* ··· 4400 4400 #endif 4401 4401 }; 4402 4402 4403 - static struct kmem_cache *shmem_inode_cachep; 4403 + static struct kmem_cache *shmem_inode_cachep __ro_after_init; 4404 4404 4405 4405 static struct inode *shmem_alloc_inode(struct super_block *sb) 4406 4406 { ··· 4432 4432 inode_init_once(&info->vfs_inode); 4433 4433 } 4434 4434 4435 - static void shmem_init_inodecache(void) 4435 + static void __init shmem_init_inodecache(void) 4436 4436 { 4437 4437 shmem_inode_cachep = kmem_cache_create("shmem_inode_cache", 4438 4438 sizeof(struct shmem_inode_info), 4439 4439 0, SLAB_PANIC|SLAB_ACCOUNT, shmem_init_inode); 4440 4440 } 4441 4441 4442 - static void shmem_destroy_inodecache(void) 4442 + static void __init shmem_destroy_inodecache(void) 4443 4443 { 4444 4444 kmem_cache_destroy(shmem_inode_cachep); 4445 4445 }
+1 -2
net/core/pktgen.c
··· 4032 4032 list_for_each_safe(q, n, &list) { 4033 4033 t = list_entry(q, struct pktgen_thread, th_list); 4034 4034 list_del(&t->th_list); 4035 - kthread_stop(t->tsk); 4036 - put_task_struct(t->tsk); 4035 + kthread_stop_put(t->tsk); 4037 4036 kfree(t); 4038 4037 } 4039 4038
+6 -4
scripts/gdb/linux/constants.py.in
··· 66 66 LX_GDBPARSED(IRQ_HIDDEN) 67 67 68 68 /* linux/module.h */ 69 - LX_GDBPARSED(MOD_TEXT) 70 - LX_GDBPARSED(MOD_DATA) 71 - LX_GDBPARSED(MOD_RODATA) 72 - LX_GDBPARSED(MOD_RO_AFTER_INIT) 69 + if IS_BUILTIN(CONFIG_MODULES): 70 + LX_GDBPARSED(MOD_TEXT) 71 + LX_GDBPARSED(MOD_DATA) 72 + LX_GDBPARSED(MOD_RODATA) 73 + LX_GDBPARSED(MOD_RO_AFTER_INIT) 73 74 74 75 /* linux/mount.h */ 75 76 LX_VALUE(MNT_NOSUID) ··· 158 157 LX_CONFIG(CONFIG_PAGE_OWNER) 159 158 LX_CONFIG(CONFIG_SLUB_DEBUG) 160 159 LX_CONFIG(CONFIG_SLAB_FREELIST_HARDENED) 160 + LX_CONFIG(CONFIG_MMU)
+15
scripts/gdb/linux/cpus.py
··· 179 179 else: 180 180 raise gdb.GdbError("Sorry, obtaining the current task is not allowed " 181 181 "while running in userspace(EL0)") 182 + elif utils.is_target_arch("riscv"): 183 + current_tp = gdb.parse_and_eval("$tp") 184 + scratch_reg = gdb.parse_and_eval("$sscratch") 185 + 186 + # by default tp points to current task 187 + current_task = current_tp.cast(task_ptr_type) 188 + 189 + # scratch register is set 0 in trap handler after entering kernel. 190 + # When hart is in user mode, scratch register is pointing to task_struct. 191 + # and tp is used by user mode. So when scratch register holds larger value 192 + # (negative address as ulong is larger value) than tp, then use scratch register. 193 + if (scratch_reg.cast(utils.get_ulong_type()) > current_tp.cast(utils.get_ulong_type())): 194 + current_task = scratch_reg.cast(task_ptr_type) 195 + 196 + return current_task.dereference() 182 197 else: 183 198 raise gdb.GdbError("Sorry, obtaining the current task is not yet " 184 199 "supported with this arch")
+6 -2
scripts/gdb/linux/vmalloc.py
··· 10 10 import re 11 11 from linux import lists, utils, stackdepot, constants, mm 12 12 13 - vmap_area_type = utils.CachedType('struct vmap_area') 14 - vmap_area_ptr_type = vmap_area_type.get_type().pointer() 13 + if constants.LX_CONFIG_MMU: 14 + vmap_area_type = utils.CachedType('struct vmap_area') 15 + vmap_area_ptr_type = vmap_area_type.get_type().pointer() 15 16 16 17 def is_vmalloc_addr(x): 17 18 pg_ops = mm.page_ops().ops ··· 26 25 super(LxVmallocInfo, self).__init__("lx-vmallocinfo", gdb.COMMAND_DATA) 27 26 28 27 def invoke(self, arg, from_tty): 28 + if not constants.LX_CONFIG_MMU: 29 + raise gdb.GdbError("Requires MMU support") 30 + 29 31 vmap_area_list = gdb.parse_and_eval('vmap_area_list') 30 32 for vmap_area in lists.list_for_each_entry(vmap_area_list, vmap_area_ptr_type, "list"): 31 33 if not vmap_area['vm']:
+20 -18
scripts/get_maintainer.pl
··· 57 57 my $status = 0; 58 58 my $letters = ""; 59 59 my $keywords = 1; 60 + my $keywords_in_file = 0; 60 61 my $sections = 0; 61 62 my $email_file_emails = 0; 62 63 my $from_filename = 0; ··· 273 272 'letters=s' => \$letters, 274 273 'pattern-depth=i' => \$pattern_depth, 275 274 'k|keywords!' => \$keywords, 275 + 'kf|keywords-in-file!' => \$keywords_in_file, 276 276 'sections!' => \$sections, 277 277 'fe|file-emails!' => \$email_file_emails, 278 278 'f|file' => \$from_filename, ··· 320 318 $subsystem = 0; 321 319 $web = 0; 322 320 $keywords = 0; 321 + $keywords_in_file = 0; 323 322 $interactive = 0; 324 323 } else { 325 324 my $selections = $email + $scm + $status + $subsystem + $web; ··· 551 548 $file =~ s/^\Q${cur_path}\E//; #strip any absolute path 552 549 $file =~ s/^\Q${lk_path}\E//; #or the path to the lk tree 553 550 push(@files, $file); 554 - if ($file ne "MAINTAINERS" && -f $file && $keywords) { 551 + if ($file ne "MAINTAINERS" && -f $file && $keywords && $keywords_in_file) { 555 552 open(my $f, '<', $file) 556 553 or die "$P: Can't open $file: $!\n"; 557 554 my $text = do { local($/) ; <$f> }; 558 555 close($f); 559 - if ($keywords) { 560 - foreach my $line (keys %keyword_hash) { 561 - if ($text =~ m/$keyword_hash{$line}/x) { 562 - push(@keyword_tvi, $line); 563 - } 556 + foreach my $line (keys %keyword_hash) { 557 + if ($text =~ m/$keyword_hash{$line}/x) { 558 + push(@keyword_tvi, $line); 564 559 } 565 560 } 566 561 } ··· 920 919 } 921 920 922 921 foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) { 923 - add_categories($line); 922 + add_categories($line, ""); 924 923 if ($sections) { 925 924 my $i; 926 925 my $start = find_starting_index($line); ··· 948 947 if ($keywords) { 949 948 @keyword_tvi = sort_and_uniq(@keyword_tvi); 950 949 foreach my $line (@keyword_tvi) { 951 - add_categories($line); 950 + add_categories($line, ":Keyword:$keyword_hash{$line}"); 952 951 } 953 952 } 954 953 ··· 1077 1076 Other options: 1078 1077 --pattern-depth => Number of pattern directory traversals (default: 0 (all)) 1079 1078 --keywords => scan patch for keywords (default: $keywords) 1079 + --keywords-in-file => scan file for keywords (default: $keywords_in_file) 1080 1080 --sections => print all of the subsystem sections with pattern matches 1081 1081 --letters => print all matching 'letter' types from all matching sections 1082 1082 --mailmap => use .mailmap file (default: $email_use_mailmap) ··· 1088 1086 1089 1087 Default options: 1090 1088 [--email --tree --nogit --git-fallback --m --r --n --l --multiline 1091 - --pattern-depth=0 --remove-duplicates --rolestats] 1089 + --pattern-depth=0 --remove-duplicates --rolestats --keywords] 1092 1090 1093 1091 Notes: 1094 1092 Using "-f directory" may give unexpected results: ··· 1314 1312 } 1315 1313 1316 1314 sub add_categories { 1317 - my ($index) = @_; 1315 + my ($index, $suffix) = @_; 1318 1316 1319 1317 my $i; 1320 1318 my $start = find_starting_index($index); ··· 1344 1342 if (!$hash_list_to{lc($list_address)}) { 1345 1343 $hash_list_to{lc($list_address)} = 1; 1346 1344 push(@list_to, [$list_address, 1347 - "subscriber list${list_role}"]); 1345 + "subscriber list${list_role}" . $suffix]); 1348 1346 } 1349 1347 } 1350 1348 } else { ··· 1354 1352 if ($email_moderated_list) { 1355 1353 $hash_list_to{lc($list_address)} = 1; 1356 1354 push(@list_to, [$list_address, 1357 - "moderated list${list_role}"]); 1355 + "moderated list${list_role}" . $suffix]); 1358 1356 } 1359 1357 } else { 1360 1358 $hash_list_to{lc($list_address)} = 1; 1361 1359 push(@list_to, [$list_address, 1362 - "open list${list_role}"]); 1360 + "open list${list_role}" . $suffix]); 1363 1361 } 1364 1362 } 1365 1363 } ··· 1367 1365 } elsif ($ptype eq "M") { 1368 1366 if ($email_maintainer) { 1369 1367 my $role = get_maintainer_role($i); 1370 - push_email_addresses($pvalue, $role); 1368 + push_email_addresses($pvalue, $role . $suffix); 1371 1369 } 1372 1370 } elsif ($ptype eq "R") { 1373 1371 if ($email_reviewer) { 1374 1372 my $subsystem = get_subsystem_name($i); 1375 - push_email_addresses($pvalue, "reviewer:$subsystem"); 1373 + push_email_addresses($pvalue, "reviewer:$subsystem" . $suffix); 1376 1374 } 1377 1375 } elsif ($ptype eq "T") { 1378 - push(@scm, $pvalue); 1376 + push(@scm, $pvalue . $suffix); 1379 1377 } elsif ($ptype eq "W") { 1380 - push(@web, $pvalue); 1378 + push(@web, $pvalue . $suffix); 1381 1379 } elsif ($ptype eq "S") { 1382 - push(@status, $pvalue); 1380 + push(@status, $pvalue . $suffix); 1383 1381 } 1384 1382 } 1385 1383 }
+2 -1
scripts/show_delta
··· 125 125 for line in lines: 126 126 print (convert_line(line, base_time),) 127 127 128 - main() 128 + if __name__ == "__main__": 129 + main()
+1 -1
security/integrity/iint.c
··· 23 23 24 24 static struct rb_root integrity_iint_tree = RB_ROOT; 25 25 static DEFINE_RWLOCK(integrity_iint_lock); 26 - static struct kmem_cache *iint_cache __read_mostly; 26 + static struct kmem_cache *iint_cache __ro_after_init; 27 27 28 28 struct dentry *integrity_dir; 29 29
+4 -5
sound/pci/asihpi/hpidebug.h
··· 29 29 the start of each message, eg see linux kernel hpios.h */ 30 30 31 31 #ifdef SOURCEFILE_NAME 32 + #undef FILE_LINE 32 33 #define FILE_LINE SOURCEFILE_NAME ":" __stringify(__LINE__) " " 33 - #else 34 - #define FILE_LINE __FILE__ ":" __stringify(__LINE__) " " 35 34 #endif 36 35 37 36 #define HPI_DEBUG_ASSERT(expression) \ 38 37 do { \ 39 38 if (!(expression)) { \ 40 39 printk(KERN_ERR FILE_LINE \ 41 - "ASSERT " __stringify(expression)); \ 40 + " ASSERT " __stringify(expression)); \ 42 41 } \ 43 42 } while (0) 44 43 ··· 45 46 do { \ 46 47 if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \ 47 48 printk(HPI_DEBUG_FLAG_##level \ 48 - FILE_LINE __VA_ARGS__); \ 49 + FILE_LINE " " __VA_ARGS__); \ 49 50 } \ 50 51 } while (0) 51 52 ··· 69 70 do { \ 70 71 if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \ 71 72 hpi_debug_message(phm, HPI_DEBUG_FLAG_##level \ 72 - FILE_LINE __stringify(level)); \ 73 + FILE_LINE " " __stringify(level)); \ 73 74 } \ 74 75 } while (0) 75 76
+8
tools/include/linux/compiler.h
··· 63 63 # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) 64 64 #endif 65 65 66 + /* 67 + * This returns a constant expression while determining if an argument is 68 + * a constant expression, most importantly without evaluating the argument. 69 + * Glory to Martin Uecker <Martin.Uecker@med.uni-goettingen.de> 70 + */ 71 + #define __is_constexpr(x) \ 72 + (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) 73 + 66 74 #ifdef __ANDROID__ 67 75 /* 68 76 * FIXME: Big hammer to get rid of tons of:
-8
tools/include/linux/const.h
··· 3 3 4 4 #include <vdso/const.h> 5 5 6 - /* 7 - * This returns a constant expression while determining if an argument is 8 - * a constant expression, most importantly without evaluating the argument. 9 - * Glory to Martin Uecker <Martin.Uecker@med.uni-goettingen.de> 10 - */ 11 - #define __is_constexpr(x) \ 12 - (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) 13 - 14 6 #endif /* _LINUX_CONST_H */
+1
tools/testing/selftests/mm/run_vmtests.sh
··· 309 309 # MADV_POPULATE_READ and MADV_POPULATE_WRITE tests 310 310 CATEGORY="madv_populate" run_test ./madv_populate 311 311 312 + echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope 312 313 CATEGORY="memfd_secret" run_test ./memfd_secret 313 314 314 315 # KSM KSM_MERGE_TIME_HUGE_PAGES test with size of 100
+183 -51
tools/testing/selftests/proc/proc-empty-vm.c
··· 23 23 * /proc/${pid}/smaps 24 24 * /proc/${pid}/smaps_rollup 25 25 */ 26 + #undef _GNU_SOURCE 27 + #define _GNU_SOURCE 28 + 26 29 #undef NDEBUG 27 30 #include <assert.h> 28 31 #include <errno.h> ··· 37 34 #include <sys/mman.h> 38 35 #include <sys/ptrace.h> 39 36 #include <sys/resource.h> 37 + #include <sys/syscall.h> 40 38 #include <sys/types.h> 41 39 #include <sys/wait.h> 42 40 #include <unistd.h> ··· 45 41 #ifdef __amd64__ 46 42 #define TEST_VSYSCALL 47 43 #endif 44 + 45 + #if defined __amd64__ 46 + #ifndef SYS_pkey_alloc 47 + #define SYS_pkey_alloc 330 48 + #endif 49 + #ifndef SYS_pkey_free 50 + #define SYS_pkey_free 331 51 + #endif 52 + #elif defined __i386__ 53 + #ifndef SYS_pkey_alloc 54 + #define SYS_pkey_alloc 381 55 + #endif 56 + #ifndef SYS_pkey_free 57 + #define SYS_pkey_free 382 58 + #endif 59 + #else 60 + #error "SYS_pkey_alloc" 61 + #endif 62 + 63 + static int g_protection_key_support; 64 + 65 + static int protection_key_support(void) 66 + { 67 + long rv = syscall(SYS_pkey_alloc, 0, 0); 68 + if (rv > 0) { 69 + syscall(SYS_pkey_free, (int)rv); 70 + return 1; 71 + } else if (rv == -1 && errno == ENOSYS) { 72 + return 0; 73 + } else if (rv == -1 && errno == EINVAL) { 74 + // ospke=n 75 + return 0; 76 + } else { 77 + fprintf(stderr, "%s: error: rv %ld, errno %d\n", __func__, rv, errno); 78 + exit(EXIT_FAILURE); 79 + } 80 + } 48 81 49 82 /* 50 83 * 0: vsyscall VMA doesn't exist vsyscall=none ··· 101 60 static const char proc_pid_smaps_vsyscall_0[] = ""; 102 61 103 62 static const char proc_pid_smaps_vsyscall_1[] = 104 - "ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]\n" 105 - "Size: 4 kB\n" 106 - "KernelPageSize: 4 kB\n" 107 - "MMUPageSize: 4 kB\n" 108 - "Rss: 0 kB\n" 109 - "Pss: 0 kB\n" 110 - "Pss_Dirty: 0 kB\n" 111 - "Shared_Clean: 0 kB\n" 112 - "Shared_Dirty: 0 kB\n" 113 - "Private_Clean: 0 kB\n" 114 - "Private_Dirty: 0 kB\n" 115 - "Referenced: 0 kB\n" 116 - "Anonymous: 0 kB\n" 117 - "LazyFree: 0 kB\n" 118 - "AnonHugePages: 0 kB\n" 119 - "ShmemPmdMapped: 0 kB\n" 120 - "FilePmdMapped: 0 kB\n" 121 - "Shared_Hugetlb: 0 kB\n" 122 - "Private_Hugetlb: 0 kB\n" 123 - "Swap: 0 kB\n" 124 - "SwapPss: 0 kB\n" 125 - "Locked: 0 kB\n" 126 - "THPeligible: 0\n" 127 - /* 128 - * "ProtectionKey:" field is conditional. It is possible to check it as well, 129 - * but I don't have such machine. 130 - */ 131 - ; 132 - 133 - static const char proc_pid_smaps_vsyscall_2[] = 134 63 "ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0 [vsyscall]\n" 135 64 "Size: 4 kB\n" 136 65 "KernelPageSize: 4 kB\n" ··· 114 103 "Private_Dirty: 0 kB\n" 115 104 "Referenced: 0 kB\n" 116 105 "Anonymous: 0 kB\n" 106 + "KSM: 0 kB\n" 117 107 "LazyFree: 0 kB\n" 118 108 "AnonHugePages: 0 kB\n" 119 109 "ShmemPmdMapped: 0 kB\n" ··· 125 113 "SwapPss: 0 kB\n" 126 114 "Locked: 0 kB\n" 127 115 "THPeligible: 0\n" 128 - /* 129 - * "ProtectionKey:" field is conditional. It is possible to check it as well, 130 - * but I'm too tired. 131 - */ 116 + ; 117 + 118 + static const char proc_pid_smaps_vsyscall_2[] = 119 + "ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]\n" 120 + "Size: 4 kB\n" 121 + "KernelPageSize: 4 kB\n" 122 + "MMUPageSize: 4 kB\n" 123 + "Rss: 0 kB\n" 124 + "Pss: 0 kB\n" 125 + "Pss_Dirty: 0 kB\n" 126 + "Shared_Clean: 0 kB\n" 127 + "Shared_Dirty: 0 kB\n" 128 + "Private_Clean: 0 kB\n" 129 + "Private_Dirty: 0 kB\n" 130 + "Referenced: 0 kB\n" 131 + "Anonymous: 0 kB\n" 132 + "KSM: 0 kB\n" 133 + "LazyFree: 0 kB\n" 134 + "AnonHugePages: 0 kB\n" 135 + "ShmemPmdMapped: 0 kB\n" 136 + "FilePmdMapped: 0 kB\n" 137 + "Shared_Hugetlb: 0 kB\n" 138 + "Private_Hugetlb: 0 kB\n" 139 + "Swap: 0 kB\n" 140 + "SwapPss: 0 kB\n" 141 + "Locked: 0 kB\n" 142 + "THPeligible: 0\n" 132 143 ; 133 144 134 145 static void sigaction_SIGSEGV(int _, siginfo_t *__, void *___) ··· 273 238 } 274 239 perror("open /proc/${pid}/smaps"); 275 240 return EXIT_FAILURE; 276 - } else { 277 - ssize_t rv = read(fd, buf, sizeof(buf)); 278 - close(fd); 279 - if (g_vsyscall == 0) { 280 - assert(rv == 0); 281 - } else { 282 - size_t len = strlen(g_proc_pid_maps_vsyscall); 283 - /* TODO "ProtectionKey:" */ 284 - assert(rv > len); 285 - assert(memcmp(buf, g_proc_pid_maps_vsyscall, len) == 0); 286 - } 287 - return EXIT_SUCCESS; 288 241 } 242 + ssize_t rv = read(fd, buf, sizeof(buf)); 243 + close(fd); 244 + 245 + assert(0 <= rv); 246 + assert(rv <= sizeof(buf)); 247 + 248 + if (g_vsyscall == 0) { 249 + assert(rv == 0); 250 + } else { 251 + size_t len = strlen(g_proc_pid_smaps_vsyscall); 252 + assert(rv > len); 253 + assert(memcmp(buf, g_proc_pid_smaps_vsyscall, len) == 0); 254 + 255 + if (g_protection_key_support) { 256 + #define PROTECTION_KEY "ProtectionKey: 0\n" 257 + assert(memmem(buf, rv, PROTECTION_KEY, strlen(PROTECTION_KEY))); 258 + } 259 + } 260 + 261 + return EXIT_SUCCESS; 289 262 } 290 263 291 264 static const char g_smaps_rollup[] = ··· 346 303 } 347 304 } 348 305 306 + static const char *parse_u64(const char *p, const char *const end, uint64_t *rv) 307 + { 308 + *rv = 0; 309 + for (; p != end; p += 1) { 310 + if ('0' <= *p && *p <= '9') { 311 + assert(!__builtin_mul_overflow(*rv, 10, rv)); 312 + assert(!__builtin_add_overflow(*rv, *p - '0', rv)); 313 + } else { 314 + break; 315 + } 316 + } 317 + assert(p != end); 318 + return p; 319 + } 320 + 321 + /* 322 + * There seems to be 2 types of valid output: 323 + * "0 A A B 0 0 0\n" for dynamic exeuctables, 324 + * "0 0 0 B 0 0 0\n" for static executables. 325 + */ 326 + static int test_proc_pid_statm(pid_t pid) 327 + { 328 + char buf[4096]; 329 + snprintf(buf, sizeof(buf), "/proc/%u/statm", pid); 330 + int fd = open(buf, O_RDONLY); 331 + if (fd == -1) { 332 + perror("open /proc/${pid}/statm"); 333 + return EXIT_FAILURE; 334 + } 335 + 336 + ssize_t rv = read(fd, buf, sizeof(buf)); 337 + close(fd); 338 + 339 + assert(rv >= 0); 340 + assert(rv <= sizeof(buf)); 341 + if (0) { 342 + write(1, buf, rv); 343 + } 344 + 345 + const char *p = buf; 346 + const char *const end = p + rv; 347 + 348 + /* size */ 349 + assert(p != end && *p++ == '0'); 350 + assert(p != end && *p++ == ' '); 351 + 352 + uint64_t resident; 353 + p = parse_u64(p, end, &resident); 354 + assert(p != end && *p++ == ' '); 355 + 356 + uint64_t shared; 357 + p = parse_u64(p, end, &shared); 358 + assert(p != end && *p++ == ' '); 359 + 360 + uint64_t text; 361 + p = parse_u64(p, end, &text); 362 + assert(p != end && *p++ == ' '); 363 + 364 + assert(p != end && *p++ == '0'); 365 + assert(p != end && *p++ == ' '); 366 + 367 + /* data */ 368 + assert(p != end && *p++ == '0'); 369 + assert(p != end && *p++ == ' '); 370 + 371 + assert(p != end && *p++ == '0'); 372 + assert(p != end && *p++ == '\n'); 373 + 374 + assert(p == end); 375 + 376 + /* 377 + * "text" is "mm->end_code - mm->start_code" at execve(2) time. 378 + * munmap() doesn't change it. It can be anything (just link 379 + * statically). It can't be 0 because executing to this point 380 + * implies at least 1 page of code. 381 + */ 382 + assert(text > 0); 383 + 384 + /* 385 + * These two are always equal. Always 0 for statically linked 386 + * executables and sometimes 0 for dynamically linked executables. 387 + * There is no way to tell one from another without parsing ELF 388 + * which is too much for this test. 389 + */ 390 + assert(resident == shared); 391 + 392 + return EXIT_SUCCESS; 393 + } 394 + 349 395 int main(void) 350 396 { 351 397 int rv = EXIT_SUCCESS; ··· 459 327 default: 460 328 abort(); 461 329 } 330 + 331 + g_protection_key_support = protection_key_support(); 462 332 463 333 pid_t pid = fork(); 464 334 if (pid == -1) { ··· 523 389 if (rv == EXIT_SUCCESS) { 524 390 rv = test_proc_pid_smaps_rollup(pid); 525 391 } 526 - /* 527 - * TODO test /proc/${pid}/statm, task_statm() 528 - * ->start_code, ->end_code aren't updated by munmap(). 529 - * Output can be "0 0 0 2 0 0 0\n" where "2" can be anything. 530 - */ 392 + if (rv == EXIT_SUCCESS) { 393 + rv = test_proc_pid_statm(pid); 394 + } 531 395 532 396 /* Cut the rope. */ 533 397 int wstatus;