Skip to content

Commit 5895294

Browse files
Michael HolzheuMartin Schwidefsky
authored andcommitted
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>
1 parent 05e0baa commit 5895294

5 files changed

Lines changed: 49 additions & 26 deletions

File tree

‎arch/s390/include/asm/ipl.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef _ASM_S390_IPL_H
88
#define _ASM_S390_IPL_H
99

10+
#include <asm/lowcore.h>
1011
#include <asm/types.h>
1112
#include <asm/cio.h>
1213
#include <asm/setup.h>
@@ -88,6 +89,14 @@ extern u32 ipl_flags;
8889
extern u32 dump_prefix_page;
8990
extern unsigned int zfcpdump_prefix_array[];
9091

92+
struct dump_save_areas {
93+
struct save_area **areas;
94+
int count;
95+
};
96+
97+
extern struct dump_save_areas dump_save_areas;
98+
struct save_area *dump_save_area_create(int cpu);
99+
91100
extern void do_reipl(void);
92101
extern void do_halt(void);
93102
extern void do_poff(void);

‎arch/s390/include/asm/smp.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#define raw_smp_processor_id() (S390_lowcore.cpu_nr)
1515

1616
extern struct mutex smp_cpu_state_mutex;
17-
extern struct save_area *zfcpdump_save_areas[NR_CPUS + 1];
1817

1918
extern int __cpu_up(unsigned int cpu, struct task_struct *tidle);
2019

‎arch/s390/kernel/crash_dump.c‎

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,32 @@
2222
#define PTR_SUB(x, y) (((char *) (x)) - ((unsigned long) (y)))
2323
#define PTR_DIFF(x, y) ((unsigned long)(((char *) (x)) - ((unsigned long) (y))))
2424

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+
}
2551

2652
/*
2753
* Return physical address for virtual address
@@ -450,8 +476,8 @@ static int get_cpu_cnt(void)
450476
{
451477
int i, cpus = 0;
452478

453-
for (i = 0; zfcpdump_save_areas[i]; i++) {
454-
if (zfcpdump_save_areas[i]->pref_reg == 0)
479+
for (i = 0; i < dump_save_areas.count; i++) {
480+
if (dump_save_areas.areas[i]->pref_reg == 0)
455481
continue;
456482
cpus++;
457483
}
@@ -522,8 +548,8 @@ static void *notes_init(Elf64_Phdr *phdr, void *ptr, u64 notes_offset)
522548

523549
ptr = nt_prpsinfo(ptr);
524550

525-
for (i = 0; zfcpdump_save_areas[i]; i++) {
526-
sa = zfcpdump_save_areas[i];
551+
for (i = 0; i < dump_save_areas.count; i++) {
552+
sa = dump_save_areas.areas[i];
527553
if (sa->pref_reg == 0)
528554
continue;
529555
ptr = fill_cpu_elf_notes(ptr, sa);

‎arch/s390/kernel/smp.c‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,6 @@ EXPORT_SYMBOL(smp_ctl_clear_bit);
533533

534534
#if defined(CONFIG_ZFCPDUMP) || defined(CONFIG_CRASH_DUMP)
535535

536-
struct save_area *zfcpdump_save_areas[NR_CPUS + 1];
537-
EXPORT_SYMBOL_GPL(zfcpdump_save_areas);
538-
539536
static void __init smp_get_save_area(int cpu, u16 address)
540537
{
541538
void *lc = pcpu_devices[0].lowcore;
@@ -546,15 +543,9 @@ static void __init smp_get_save_area(int cpu, u16 address)
546543
if (!OLDMEM_BASE && (address == boot_cpu_address ||
547544
ipl_info.type != IPL_TYPE_FCP_DUMP))
548545
return;
549-
if (cpu >= NR_CPUS) {
550-
pr_warning("CPU %i exceeds the maximum %i and is excluded "
551-
"from the dump\n", cpu, NR_CPUS - 1);
552-
return;
553-
}
554-
save_area = kmalloc(sizeof(struct save_area), GFP_KERNEL);
546+
save_area = dump_save_area_create(cpu);
555547
if (!save_area)
556548
panic("could not allocate memory for save area\n");
557-
zfcpdump_save_areas[cpu] = save_area;
558549
#ifdef CONFIG_CRASH_DUMP
559550
if (address == boot_cpu_address) {
560551
/* Copy the registers of the boot cpu. */

‎drivers/s390/char/zcore.c‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,14 @@ static int __init init_cpu_info(enum arch_id arch)
151151

152152
/* get info for boot cpu from lowcore, stored in the HSA */
153153

154-
sa = kmalloc(sizeof(*sa), GFP_KERNEL);
154+
sa = dump_save_area_create(0);
155155
if (!sa)
156156
return -ENOMEM;
157157
if (memcpy_hsa_kernel(sa, sys_info.sa_base, sys_info.sa_size) < 0) {
158158
TRACE("could not copy from HSA\n");
159159
kfree(sa);
160160
return -EIO;
161161
}
162-
zfcpdump_save_areas[0] = sa;
163162
return 0;
164163
}
165164

@@ -246,24 +245,25 @@ static int copy_lc(void __user *buf, void *sa, int sa_off, int len)
246245
static int zcore_add_lc(char __user *buf, unsigned long start, size_t count)
247246
{
248247
unsigned long end;
249-
int i = 0;
248+
int i;
250249

251250
if (count == 0)
252251
return 0;
253252

254253
end = start + count;
255-
while (zfcpdump_save_areas[i]) {
254+
for (i = 0; i < dump_save_areas.count; i++) {
256255
unsigned long cp_start, cp_end; /* copy range */
257256
unsigned long sa_start, sa_end; /* save area range */
258257
unsigned long prefix;
259258
unsigned long sa_off, len, buf_off;
259+
struct save_area *save_area = dump_save_areas.areas[i];
260260

261-
prefix = zfcpdump_save_areas[i]->pref_reg;
261+
prefix = save_area->pref_reg;
262262
sa_start = prefix + sys_info.sa_base;
263263
sa_end = prefix + sys_info.sa_base + sys_info.sa_size;
264264

265265
if ((end < sa_start) || (start > sa_end))
266-
goto next;
266+
continue;
267267
cp_start = max(start, sa_start);
268268
cp_end = min(end, sa_end);
269269

@@ -272,10 +272,8 @@ static int zcore_add_lc(char __user *buf, unsigned long start, size_t count)
272272
len = cp_end - cp_start;
273273

274274
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))
276276
return -EFAULT;
277-
next:
278-
i++;
279277
}
280278
return 0;
281279
}
@@ -637,8 +635,8 @@ static void __init zcore_header_init(int arch, struct zcore_header *hdr,
637635
hdr->num_pages = mem_size / PAGE_SIZE;
638636
hdr->tod = get_tod_clock();
639637
get_cpu_id(&hdr->cpu_id);
640-
for (i = 0; zfcpdump_save_areas[i]; i++) {
641-
prefix = zfcpdump_save_areas[i]->pref_reg;
638+
for (i = 0; i < dump_save_areas.count; i++) {
639+
prefix = dump_save_areas.areas[i]->pref_reg;
642640
hdr->real_cpu_cnt++;
643641
if (!prefix)
644642
continue;

0 commit comments

Comments
 (0)