mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
7d5f2ba038cd9bbdfdfddee8e87a320cec7a5e63
7 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b6c30404bc |
zfcpdump: drop use of mmap() for /proc/vmcore
The function copy_table_entry_write() maps/unmaps /proc/vmcore for each 64kB of the file in order to write its content to a dump partition. This requires a page allocation of order 2 in kernel (crst_table_alloc) each time a mmap() syscall is performed and which cannot always be fulfilled due to external memory fragmentation. And this in turn results in a OOM kernel panic while writing /proc/vmcore content to a dump partition. To make zfcpdump more robust in the face of such problems with page allocations of order > 0, we use a simple file read/write loop to transfer the content of /proc/vmcore to a dump partition. This solution is less efficient (by not much) than the old one with mmap() because it requires additional user space copy but we trade off here efficiency for robustness which is more important for zfcpdump. We use a statically allocated buffer to read data into from /proc/vmcore and write to a dump partition to avoid repeated use of the memory mapping kernel path which would be required for a buffer allocated dynamically at each entry of copy_table_entry_write(). Another possible and very convenient solution would be to use sendfile() which would avoid any user space copies but, unfortunately, sendfile() doesn't work with large /proc files. Example of failed mmap() call for /proc/vmcore ============================================== [ 26.568654] init invoked oom-killer: gfp_mask=0x40cc0(GFP_KERNEL|__GFP_COMP), order=2, oom_score_adj=0 [ 26.568665] CPU: 0 PID: 1 Comm: init Not tainted 6.9.0-20240504.rc6.git0.9986ea583f39.300.fc39.s390x+zfcpdump #1 [ 26.568668] Hardware name: IBM 3931 A01 704 (LPAR) [ 26.568669] Call Trace: [ 26.568671] [<000003ffe03277c6>] dump_stack_lvl+0x76/0x98 [ 26.568676] [<000003ffe00f15c8>] dump_header+0x58/0x2d0 [ 26.568680] [<000003ffe00f219a>] out_of_memory+0x252/0x348 [ 26.568683] [<000003ffe0132f3e>] __alloc_pages_slowpath.constprop.0+0x65e/0x7c0 [ 26.568686] [<000003ffe01331a4>] __alloc_pages+0x104/0x128 [ 26.568688] [<000003ffe001ab46>] crst_table_alloc+0x2e/0xa0 [ 26.568693] [<000003ffe01164c4>] __pmd_alloc+0x24/0x160 [ 26.568696] [<000003ffe0116650>] pmd_alloc+0x50/0x68 [ 26.568698] [<000003ffe0117be4>] remap_pfn_range_notrack+0x194/0x310 [ 26.568701] [<000003ffe0117d7c>] remap_pfn_range+0x1c/0x28 [ 26.568703] [<000003ffe0015442>] remap_oldmem_pfn_range+0xb2/0x108 [ 26.568705] [<000003ffe01a0544>] mmap_vmcore+0x414/0x448 [ 26.568707] [<000003ffe01937c4>] proc_reg_mmap+0x84/0xa0 [ 26.568709] [<000003ffe011f264>] mmap_region+0x22c/0x6f8 [ 26.568711] [<000003ffe011fae8>] do_mmap+0x3b8/0x410 [ 26.568713] [<000003ffe01015cc>] vm_mmap_pgoff+0x9c/0xe8 [ 26.568715] [<000003ffe011d006>] ksys_mmap_pgoff+0x8e/0xb8 [ 26.568716] [<000003ffe011d0f4>] __s390x_sys_old_mmap+0x74/0x90 [ 26.568718] [<000003ffe0341a2a>] __do_syscall+0x1aa/0x220 [ 26.568720] [<000003ffe03478b0>] system_call+0x70/0x98 [ 26.568724] Mem-Info: [ 26.568725] active_anon:1 inactive_anon:12 isolated_anon:0 active_file:83590 inactive_file:93939 isolated_file:0 unevictable:201 dirty:17845 writeback:4 slab_reclaimable:4259 slab_unreclaimable:1482 mapped:174 shmem:0 pagetables:810 sec_pagetables:0 bounce:0 kernel_misc_reclaimable:0 free:2694 free_pcp:105 free_cma:0 [ 26.568729] Node 0 active_anon:4kB inactive_anon:48kB active_file:334360kB inactive_file:375756kB unevictable:804kB isolated(anon):0kB isolated(file):0kB mapped:696kB dirty:71380kB writeback:16kB shmem:0kB writeback_tmp:0kB kernel_stack:544kB pagetables:3240kB sec_pagetables:0kB all_unreclaimable? no [ 26.568732] DMA free:10776kB boost:0kB min:3496kB low:4368kB high:5240kB reserved_highatomic:0KB active_anon:4kB inactive_anon:48kB active_file:334360kB inactive_file:375756kB unevictable:804kB writepending:71360kB present:786428kB managed:764664kB mlocked:0kB bounce:0kB free_pcp:420kB local_pcp:420kB free_cma:0kB [ 26.568735] lowmem_reserve[]: 0 0 0 [ 26.568738] DMA: 1069*4kB (UH) 757*8kB (UH) 11*16kB (H) 6*32kB (H) 1*64kB (H) 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 10764kB [ 26.568747] 177773 total pagecache pages [ 26.568748] 196607 pages RAM [ 26.568748] 0 pages HighMem/MovableOnly [ 26.568749] 5441 pages reserved [ 26.568749] Tasks state (memory values in pages): [ 26.568750] [ pid ] uid tgid total_vm rss rss_anon rss_file rss_shmem pgtables_bytes swapents oom_score_adj name [ 26.568751] Out of memory and no killable processes... [ 26.568752] Kernel panic - not syncing: System is deadlocked on memory [ 26.568755] CPU: 0 PID: 1 Comm: init Not tainted 6.9.0-20240504.rc6.git0.9986ea583f39.300.fc39.s390x+zfcpdump #1 [ 26.568758] Hardware name: IBM 3931 A01 704 (LPAR) [ 26.568759] Call Trace: [ 26.568760] [<000003ffe03277c6>] dump_stack_lvl+0x76/0x98 [ 26.568763] [<000003ffe001f14e>] panic+0x10e/0x2e8 [ 26.568765] [<000003ffe00f21c8>] out_of_memory+0x280/0x348 [ 26.568768] [<000003ffe0132f3e>] __alloc_pages_slowpath.constprop.0+0x65e/0x7c0 [ 26.568771] [<000003ffe01331a4>] __alloc_pages+0x104/0x128 [ 26.568773] [<000003ffe001ab46>] crst_table_alloc+0x2e/0xa0 [ 26.568776] [<000003ffe01164c4>] __pmd_alloc+0x24/0x160 [ 26.568779] [<000003ffe0116650>] pmd_alloc+0x50/0x68 [ 26.568781] [<000003ffe0117be4>] remap_pfn_range_notrack+0x194/0x310 [ 26.568784] [<000003ffe0117d7c>] remap_pfn_range+0x1c/0x28 [ 26.568787] [<000003ffe0015442>] remap_oldmem_pfn_range+0xb2/0x108 [ 26.568789] [<000003ffe01a0544>] mmap_vmcore+0x414/0x448 [ 26.568791] [<000003ffe01937c4>] proc_reg_mmap+0x84/0xa0 [ 26.568793] [<000003ffe011f264>] mmap_region+0x22c/0x6f8 [ 26.568795] [<000003ffe011fae8>] do_mmap+0x3b8/0x410 [ 26.568797] [<000003ffe01015cc>] vm_mmap_pgoff+0x9c/0xe8 [ 26.568799] [<000003ffe011d006>] ksys_mmap_pgoff+0x8e/0xb8 [ 26.568801] [<000003ffe011d0f4>] __s390x_sys_old_mmap+0x74/0x90 [ 26.568803] [<000003ffe0341a2a>] __do_syscall+0x1aa/0x220 [ 26.568805] [<000003ffe03478b0>] system_call+0x70/0x98 Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com> Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com> |
||
|
|
802c7db50e |
zfcpdump: fix hsa release for V!=R kernel
Since V!=R kernel introduction, HSA memory can be contained in/spread over more than one ELF LOAD segment of /proc/vmcore simultaneously. Therefore, the old HSA release logic is no longer valid because it assumes that HSA memory is fully contained in exactly one ELF LOAD segment of /proc/vmcore. This resulted in zfcpdump releasing HSA memory too soon and by that making parts of /proc/vmcore which cover HSA memory unreadable by user space. To correct this problem on V!=R kernel, we need first to find all ELF LOAD segments containing HSA memory, write those /proc/vmcore parts first and only then release HSA memory. The new HSA release logic must be able to handle both V!=R and V==R kernels to be backwards compatible. ==================== Tests of V!=R kernel ==================== Output of test run (KASLR on) ============================= Writing dump: TRACE: Read: /sys/kernel/debug/zcore/hsa: TRACE: '2ffff000' TRACE: ELF LOAD segment: p_offset=0x0000000000009000 p_filesz=0x0000000001cb0000 p_paddr=0x00000002f1e30000 p_vaddr=0x000002c609044000 TRACE: ELF LOAD segment: p_offset=0x0000000001cb9000 p_filesz=0x0000000040000000 p_paddr=0x0000000000000000 p_vaddr=0x000001bd00000000 TRACE: ELF LOAD segment: p_offset=0x0000000041cb9000 p_filesz=0x0000000300000000 p_paddr=0x0000000100000000 p_vaddr=0x000001be00000000 TRACE: Write copy table entry 0: off=0x0000000001cb9000 size=0x000000002ffff000 hsa=1 TRACE: Write copy table entry 1: off=0x0000000000001000 size=0x0000000001cb8000 hsa=0 TRACE: Release HSA memory TRACE: Write copy table entry 2: off=0x0000000031cb8000 size=0x0000000310001000 hsa=0 TRACE: Write copy table entry 3: off=0x0000000000000000 size=0x0000000000001000 hsa=0 Dump successful Output of test run (KASLR off) ============================== Writing dump: TRACE: Read: /sys/kernel/debug/zcore/hsa: TRACE: '2ffff000' TRACE: ELF LOAD segment: p_offset=0x0000000000009000 p_filesz=0x0000000001cb0000 p_paddr=0x0000000000c21000 p_vaddr=0x000003ffe0000000 TRACE: ELF LOAD segment: p_offset=0x0000000001cb9000 p_filesz=0x0000000040000000 p_paddr=0x0000000000000000 p_vaddr=0x000002f200000000 TRACE: ELF LOAD segment: p_offset=0x0000000041cb9000 p_filesz=0x0000000300000000 p_paddr=0x0000000100000000 p_vaddr=0x000002f300000000 TRACE: Write copy table entry 0: off=0x0000000000009000 size=0x0000000001cb0000 hsa=1 TRACE: Write copy table entry 1: off=0x0000000001cb9000 size=0x000000002ffff000 hsa=1 TRACE: Write copy table entry 2: off=0x0000000000001000 size=0x0000000000008000 hsa=0 TRACE: Release HSA memory TRACE: Write copy table entry 3: off=0x0000000031cb8000 size=0x0000000310001000 hsa=0 TRACE: Write copy table entry 4: off=0x0000000000000000 size=0x0000000000001000 hsa=0 Dump successful ==================== Tests of V==R kernel ==================== Output of test run (KASLR on) ============================= Writing dump: TRACE: Read: /sys/kernel/debug/zcore/hsa: TRACE: '2ffff000' TRACE: ELF LOAD segment: p_offset=0x0000000000009000 p_filesz=0x0000000000000000 p_paddr=0x0000000000000000 p_vaddr=0x0000000000000000 TRACE: ELF LOAD segment: p_offset=0x0000000000009000 p_filesz=0x0000000040000000 p_paddr=0x0000000000000000 p_vaddr=0x0000000000000000 TRACE: ELF LOAD segment: p_offset=0x0000000040009000 p_filesz=0x0000000300000000 p_paddr=0x0000000100000000 p_vaddr=0x0000000100000000 TRACE: Write copy table entry 0: off=0x0000000000009000 size=0x000000002ffff000 hsa=1 TRACE: Write copy table entry 1: off=0x0000000000001000 size=0x0000000000008000 hsa=0 TRACE: Release HSA memory TRACE: Write copy table entry 2: off=0x0000000030008000 size=0x0000000310001000 hsa=0 TRACE: Write copy table entry 3: off=0x0000000000000000 size=0x0000000000001000 hsa=0 Dump successful Output of test run (KASLR off) ============================== Writing dump: TRACE: Read: /sys/kernel/debug/zcore/hsa: TRACE: '2ffff000' TRACE: ELF LOAD segment: p_offset=0x0000000000009000 p_filesz=0x0000000000000000 p_paddr=0x0000000000000000 p_vaddr=0x0000000000000000 TRACE: ELF LOAD segment: p_offset=0x0000000000009000 p_filesz=0x0000000040000000 p_paddr=0x0000000000000000 p_vaddr=0x0000000000000000 TRACE: ELF LOAD segment: p_offset=0x0000000040009000 p_filesz=0x0000000300000000 p_paddr=0x0000000100000000 p_vaddr=0x0000000100000000 TRACE: Write copy table entry 0: off=0x0000000000009000 size=0x000000002ffff000 hsa=1 TRACE: Write copy table entry 1: off=0x0000000000001000 size=0x0000000000008000 hsa=0 TRACE: Release HSA memory TRACE: Write copy table entry 2: off=0x0000000030008000 size=0x0000000310001000 hsa=0 TRACE: Write copy table entry 3: off=0x0000000000000000 size=0x0000000000001000 hsa=0 Dump successful Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com> Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com> |
||
|
|
0ed6c1ccde |
zfcpdump: Search for zero paddr vmcore load to identify HSA
Check for vmcore LOAD segment with zero paddr (instead of zero vaddr) to identify HSA since physical and virtual addresses can be uncoupled on s390. Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com> Acked-by: Alexander Egorenkov <egorenar@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com> |
||
|
|
1ae4fd18fe |
zfcpdump: reuse SCSI struct definitions from boot_defs.h
To remove duplication of definitions. Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com> Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com> |
||
|
|
c7fcb457b0 |
zfcpdump: Make use of __packed macro
Make use of the pre-defined __packed macro throughout zfcpdump. Signed-off-by: Philipp Rudo <prudo@linux.ibm.com> Reviewed-by: Stefan Haberland <sth@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com> |
||
|
|
f02de298c1 |
zfcpdump: Remove module load
The zfcpdump kernel is built without module support. Furthermore the initrd doesn't contain modprobe. So trying to load modules using modprobe in zfcpdump userspace doesn't really make sense. Signed-off-by: Philipp Rudo <prudo@linux.ibm.com> Reviewed-by: Steffen Maier <maier@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com> |
||
|
|
b627b8d8e1 |
Initial s390-tools-2.0.0 import
This commit is based on the s390-tools-1.39.0 version. Changes on top of s390-tools-1.39.0: - Add MIT license to all source files - Add LICENSE file - Transform REAMDE to README.md (markdown) - Add AUTHORS.md file - Add CONTRIBUTING.md file - Move changelog from README to CHANGELOG.md file Reviewed-by: Stefan Haberland <sth@linux.vnet.ibm.com> Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com> |