Commit 51be5606 authored by Vivek Goyal's avatar Vivek Goyal Committed by Linus Torvalds
Browse files

[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
Signed-off-by: default avatarVivek Goyal <>
Cc: Greg KH <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent cc571658
......@@ -83,6 +83,33 @@ static inline void register_cpu_control(struct cpu *cpu)
#include <linux/kexec.h>
static ssize_t show_crash_notes(struct sys_device *dev, char *buf)
struct cpu *cpu = container_of(dev, struct cpu, sysdev);
ssize_t rc;
unsigned long long addr;
int cpunum;
cpunum = cpu->;
* Might be reading other cpu's data based on which cpu read thread
* has been scheduled. But cpu data (memory) is allocated once during
* boot up and this data does not change there after. Hence this
* operation should be safe. No locking required.
addr = __pa(per_cpu_ptr(crash_notes, cpunum));
rc = sprintf(buf, "%Lx\n", addr);
return rc;
static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
* register_cpu - Setup a driverfs device for a CPU.
* @cpu - Callers can set the cpu->no_control field to 1, to indicate not to
......@@ -108,6 +135,11 @@ int __devinit register_cpu(struct cpu *cpu, int num, struct node *root)
if (!error)
cpu_sys_devices[num] = &cpu->sysdev;
if (!error)
error = sysdev_create_file(&cpu->sysdev, &attr_crash_notes);
return error;
......@@ -51,16 +51,6 @@ static ssize_t uevent_helper_store(struct subsystem *subsys, const char *page, s
#include <asm/kexec.h>
static ssize_t crash_notes_show(struct subsystem *subsys, char *page)
return sprintf(page, "%p\n", (void *)crash_notes);
decl_subsys(kernel, NULL, NULL);
......@@ -68,9 +58,6 @@ static struct attribute * kernel_attrs[] = {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment