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

s390: Remove zfcpdump NR_CPUS dependency

Currently zfpcdump can only collect registers for up to CONFIG_NR_CPUS
CPUss. This dependency is not necessary. So remove it by dynamically
allocating the save area array.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Michael Holzheu and committed by
Martin Schwidefsky
58952942 05e0baaf

+49 -26
+9
arch/s390/include/asm/ipl.h
··· 7 7 #ifndef _ASM_S390_IPL_H 8 8 #define _ASM_S390_IPL_H 9 9 10 + #include <asm/lowcore.h> 10 11 #include <asm/types.h> 11 12 #include <asm/cio.h> 12 13 #include <asm/setup.h> ··· 88 87 extern u32 ipl_flags; 89 88 extern u32 dump_prefix_page; 90 89 extern unsigned int zfcpdump_prefix_array[]; 90 + 91 + struct dump_save_areas { 92 + struct save_area **areas; 93 + int count; 94 + }; 95 + 96 + extern struct dump_save_areas dump_save_areas; 97 + struct save_area *dump_save_area_create(int cpu); 91 98 92 99 extern void do_reipl(void); 93 100 extern void do_halt(void);
-1
arch/s390/include/asm/smp.h
··· 14 14 #define raw_smp_processor_id() (S390_lowcore.cpu_nr) 15 15 16 16 extern struct mutex smp_cpu_state_mutex; 17 - extern struct save_area *zfcpdump_save_areas[NR_CPUS + 1]; 18 17 19 18 extern int __cpu_up(unsigned int cpu, struct task_struct *tidle); 20 19
+30 -4
arch/s390/kernel/crash_dump.c
··· 22 22 #define PTR_SUB(x, y) (((char *) (x)) - ((unsigned long) (y))) 23 23 #define PTR_DIFF(x, y) ((unsigned long)(((char *) (x)) - ((unsigned long) (y)))) 24 24 25 + struct dump_save_areas dump_save_areas; 26 + 27 + /* 28 + * Allocate and add a save area for a CPU 29 + */ 30 + struct save_area *dump_save_area_create(int cpu) 31 + { 32 + struct save_area **save_areas, *save_area; 33 + 34 + save_area = kmalloc(sizeof(*save_area), GFP_KERNEL); 35 + if (!save_area) 36 + return NULL; 37 + if (cpu + 1 > dump_save_areas.count) { 38 + dump_save_areas.count = cpu + 1; 39 + save_areas = krealloc(dump_save_areas.areas, 40 + dump_save_areas.count * sizeof(void *), 41 + GFP_KERNEL | __GFP_ZERO); 42 + if (!save_areas) { 43 + kfree(save_area); 44 + return NULL; 45 + } 46 + dump_save_areas.areas = save_areas; 47 + } 48 + dump_save_areas.areas[cpu] = save_area; 49 + return save_area; 50 + } 25 51 26 52 /* 27 53 * Return physical address for virtual address ··· 476 450 { 477 451 int i, cpus = 0; 478 452 479 - for (i = 0; zfcpdump_save_areas[i]; i++) { 480 - if (zfcpdump_save_areas[i]->pref_reg == 0) 453 + for (i = 0; i < dump_save_areas.count; i++) { 454 + if (dump_save_areas.areas[i]->pref_reg == 0) 481 455 continue; 482 456 cpus++; 483 457 } ··· 548 522 549 523 ptr = nt_prpsinfo(ptr); 550 524 551 - for (i = 0; zfcpdump_save_areas[i]; i++) { 552 - sa = zfcpdump_save_areas[i]; 525 + for (i = 0; i < dump_save_areas.count; i++) { 526 + sa = dump_save_areas.areas[i]; 553 527 if (sa->pref_reg == 0) 554 528 continue; 555 529 ptr = fill_cpu_elf_notes(ptr, sa);
+1 -10
arch/s390/kernel/smp.c
··· 533 533 534 534 #if defined(CONFIG_ZFCPDUMP) || defined(CONFIG_CRASH_DUMP) 535 535 536 - struct save_area *zfcpdump_save_areas[NR_CPUS + 1]; 537 - EXPORT_SYMBOL_GPL(zfcpdump_save_areas); 538 - 539 536 static void __init smp_get_save_area(int cpu, u16 address) 540 537 { 541 538 void *lc = pcpu_devices[0].lowcore; ··· 543 546 if (!OLDMEM_BASE && (address == boot_cpu_address || 544 547 ipl_info.type != IPL_TYPE_FCP_DUMP)) 545 548 return; 546 - if (cpu >= NR_CPUS) { 547 - pr_warning("CPU %i exceeds the maximum %i and is excluded " 548 - "from the dump\n", cpu, NR_CPUS - 1); 549 - return; 550 - } 551 - save_area = kmalloc(sizeof(struct save_area), GFP_KERNEL); 549 + save_area = dump_save_area_create(cpu); 552 550 if (!save_area) 553 551 panic("could not allocate memory for save area\n"); 554 - zfcpdump_save_areas[cpu] = save_area; 555 552 #ifdef CONFIG_CRASH_DUMP 556 553 if (address == boot_cpu_address) { 557 554 /* Copy the registers of the boot cpu. */
+9 -11
drivers/s390/char/zcore.c
··· 151 151 152 152 /* get info for boot cpu from lowcore, stored in the HSA */ 153 153 154 - sa = kmalloc(sizeof(*sa), GFP_KERNEL); 154 + sa = dump_save_area_create(0); 155 155 if (!sa) 156 156 return -ENOMEM; 157 157 if (memcpy_hsa_kernel(sa, sys_info.sa_base, sys_info.sa_size) < 0) { ··· 159 159 kfree(sa); 160 160 return -EIO; 161 161 } 162 - zfcpdump_save_areas[0] = sa; 163 162 return 0; 164 163 } 165 164 ··· 245 246 static int zcore_add_lc(char __user *buf, unsigned long start, size_t count) 246 247 { 247 248 unsigned long end; 248 - int i = 0; 249 + int i; 249 250 250 251 if (count == 0) 251 252 return 0; 252 253 253 254 end = start + count; 254 - while (zfcpdump_save_areas[i]) { 255 + for (i = 0; i < dump_save_areas.count; i++) { 255 256 unsigned long cp_start, cp_end; /* copy range */ 256 257 unsigned long sa_start, sa_end; /* save area range */ 257 258 unsigned long prefix; 258 259 unsigned long sa_off, len, buf_off; 260 + struct save_area *save_area = dump_save_areas.areas[i]; 259 261 260 - prefix = zfcpdump_save_areas[i]->pref_reg; 262 + prefix = save_area->pref_reg; 261 263 sa_start = prefix + sys_info.sa_base; 262 264 sa_end = prefix + sys_info.sa_base + sys_info.sa_size; 263 265 264 266 if ((end < sa_start) || (start > sa_end)) 265 - goto next; 267 + continue; 266 268 cp_start = max(start, sa_start); 267 269 cp_end = min(end, sa_end); 268 270 ··· 272 272 len = cp_end - cp_start; 273 273 274 274 TRACE("copy_lc for: %lx\n", start); 275 - if (copy_lc(buf + buf_off, zfcpdump_save_areas[i], sa_off, len)) 275 + if (copy_lc(buf + buf_off, save_area, sa_off, len)) 276 276 return -EFAULT; 277 - next: 278 - i++; 279 277 } 280 278 return 0; 281 279 } ··· 635 637 hdr->num_pages = mem_size / PAGE_SIZE; 636 638 hdr->tod = get_tod_clock(); 637 639 get_cpu_id(&hdr->cpu_id); 638 - for (i = 0; zfcpdump_save_areas[i]; i++) { 639 - prefix = zfcpdump_save_areas[i]->pref_reg; 640 + for (i = 0; i < dump_save_areas.count; i++) { 641 + prefix = dump_save_areas.areas[i]->pref_reg; 640 642 hdr->real_cpu_cnt++; 641 643 if (!prefix) 642 644 continue;