Commit 51be5606d9ff9eb27ed6514f6172fbd7578a25d6
Committed by
Linus Torvalds
1 parent
cc57165874
Exists in
master
and in
7 other branches
[PATCH] kdump: export per cpu crash notes pointer through sysfs
- Kexec on panic functionality allocates memory for saving cpu registers in case of system crash event. Address of this allocated memory needs to be exported to user space, which is used by kexec-tools. - Previously, a single /sys/kernel/crash_notes entry was being exported as memory allocated was a single continuous array. Now memory allocation being dyanmic and per cpu based, address of per cpu buffer is exported through "/sys/devices/system/cpu/cpuX/crash_notes" Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com> Cc: Greg KH <greg@kroah.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 2 changed files with 32 additions and 13 deletions Side-by-side Diff
drivers/base/cpu.c
... | ... | @@ -83,6 +83,33 @@ |
83 | 83 | } |
84 | 84 | #endif /* CONFIG_HOTPLUG_CPU */ |
85 | 85 | |
86 | +#ifdef CONFIG_KEXEC | |
87 | +#include <linux/kexec.h> | |
88 | + | |
89 | +static ssize_t show_crash_notes(struct sys_device *dev, char *buf) | |
90 | +{ | |
91 | + struct cpu *cpu = container_of(dev, struct cpu, sysdev); | |
92 | + ssize_t rc; | |
93 | + unsigned long long addr; | |
94 | + int cpunum; | |
95 | + | |
96 | + cpunum = cpu->sysdev.id; | |
97 | + | |
98 | + /* | |
99 | + * Might be reading other cpu's data based on which cpu read thread | |
100 | + * has been scheduled. But cpu data (memory) is allocated once during | |
101 | + * boot up and this data does not change there after. Hence this | |
102 | + * operation should be safe. No locking required. | |
103 | + */ | |
104 | + get_cpu(); | |
105 | + addr = __pa(per_cpu_ptr(crash_notes, cpunum)); | |
106 | + rc = sprintf(buf, "%Lx\n", addr); | |
107 | + put_cpu(); | |
108 | + return rc; | |
109 | +} | |
110 | +static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL); | |
111 | +#endif | |
112 | + | |
86 | 113 | /* |
87 | 114 | * register_cpu - Setup a driverfs device for a CPU. |
88 | 115 | * @cpu - Callers can set the cpu->no_control field to 1, to indicate not to |
... | ... | @@ -108,6 +135,11 @@ |
108 | 135 | register_cpu_control(cpu); |
109 | 136 | if (!error) |
110 | 137 | cpu_sys_devices[num] = &cpu->sysdev; |
138 | + | |
139 | +#ifdef CONFIG_KEXEC | |
140 | + if (!error) | |
141 | + error = sysdev_create_file(&cpu->sysdev, &attr_crash_notes); | |
142 | +#endif | |
111 | 143 | return error; |
112 | 144 | } |
113 | 145 |
kernel/ksysfs.c
... | ... | @@ -51,16 +51,6 @@ |
51 | 51 | KERNEL_ATTR_RW(uevent_helper); |
52 | 52 | #endif |
53 | 53 | |
54 | -#ifdef CONFIG_KEXEC | |
55 | -#include <asm/kexec.h> | |
56 | - | |
57 | -static ssize_t crash_notes_show(struct subsystem *subsys, char *page) | |
58 | -{ | |
59 | - return sprintf(page, "%p\n", (void *)crash_notes); | |
60 | -} | |
61 | -KERNEL_ATTR_RO(crash_notes); | |
62 | -#endif | |
63 | - | |
64 | 54 | decl_subsys(kernel, NULL, NULL); |
65 | 55 | EXPORT_SYMBOL_GPL(kernel_subsys); |
66 | 56 | |
... | ... | @@ -68,9 +58,6 @@ |
68 | 58 | #ifdef CONFIG_HOTPLUG |
69 | 59 | &uevent_seqnum_attr.attr, |
70 | 60 | &uevent_helper_attr.attr, |
71 | -#endif | |
72 | -#ifdef CONFIG_KEXEC | |
73 | - &crash_notes_attr.attr, | |
74 | 61 | #endif |
75 | 62 | NULL |
76 | 63 | }; |