2019-09-15 13:43:39

by Sourabh Jain

[permalink] [raw]
Subject: [PATCH 0/4] reorganize and add FADump sysfs files

Currently, the FADump sysfs files are present inside /sys/kernel directory.
But as the number of FADump sysfs file increases it is not a good idea to
push all of them in /sys/kernel directory. It is better to have separate
directory to keep all the FADump sysfs files.

The patch series reorganizes the FADump sysfs files and avail all the
existing FADump sysfs files present inside /sys/kernel into a new directory
named fadump. Currently, all the FADump sysfs files are replicated into a
new directory to maintain the backward compatibility and will eventually get
removed in future. In addition to this a new FADump sys interface is added
to get the amount of memory reserved by FADump for saving the crash dump.

The series applies on top of:
https://lists.ozlabs.org/pipermail/linuxppc-dev/2019-September/196871.html

Sourabh Jain (4):
powerpc/fadump: replicate /sys/kernel/fadump_* sysfs into
/sys/kernel/fadump/
Documentation/ABI: add ABI documentation for /sys/kernel/fadump_*
Documentation/ABI: mark /sys/kernel/fadump_* sysfs files deprecated
powerpc/fadump: sysfs for fadump memory reservation

.../ABI/obsolete/sysfs-kernel-fadump_enabled | 10 ++++
.../obsolete/sysfs-kernel-fadump_registered | 11 +++++
.../obsolete/sysfs-kernel-fadump_release_mem | 11 +++++
.../sysfs-kernel-fadump_release_opalcore | 10 ++++
Documentation/ABI/testing/sysfs-kernel-fadump | 48 +++++++++++++++++++
.../powerpc/firmware-assisted-dump.rst | 14 ++++++
arch/powerpc/kernel/fadump.c | 43 +++++++++++++++++
arch/powerpc/platforms/powernv/opal-core.c | 7 +++
8 files changed, 154 insertions(+)
create mode 100644 Documentation/ABI/obsolete/sysfs-kernel-fadump_enabled
create mode 100644 Documentation/ABI/obsolete/sysfs-kernel-fadump_registered
create mode 100644 Documentation/ABI/obsolete/sysfs-kernel-fadump_release_mem
create mode 100644 Documentation/ABI/obsolete/sysfs-kernel-fadump_release_opalcore
create mode 100644 Documentation/ABI/testing/sysfs-kernel-fadump

--
2.17.2


2019-09-15 13:47:45

by Sourabh Jain

[permalink] [raw]
Subject: [PATCH 3/4] Documentation/ABI: mark /sys/kernel/fadump_* sysfs files deprecated

The /sys/kernel/fadump_* sysfs files are replicated under
/sys/kernel/fadump/ directory. But we need to keep the old
sysfs files to maintain the backward compatibility.

The sysfs files are scheduled to remove by 2021.

Signed-off-by: Sourabh Jain <[email protected]>
---
.../{testing => obsolete}/sysfs-kernel-fadump_enabled | 3 +++
.../{testing => obsolete}/sysfs-kernel-fadump_registered | 3 +++
.../sysfs-kernel-fadump_release_mem | 3 +++
.../sysfs-kernel-fadump_release_opalcore | 3 +++
Documentation/powerpc/firmware-assisted-dump.rst | 9 +++++++++
5 files changed, 21 insertions(+)
rename Documentation/ABI/{testing => obsolete}/sysfs-kernel-fadump_enabled (66%)
rename Documentation/ABI/{testing => obsolete}/sysfs-kernel-fadump_registered (71%)
rename Documentation/ABI/{testing => obsolete}/sysfs-kernel-fadump_release_mem (73%)
rename Documentation/ABI/{testing => obsolete}/sysfs-kernel-fadump_release_opalcore (70%)

diff --git a/Documentation/ABI/testing/sysfs-kernel-fadump_enabled b/Documentation/ABI/obsolete/sysfs-kernel-fadump_enabled
similarity index 66%
rename from Documentation/ABI/testing/sysfs-kernel-fadump_enabled
rename to Documentation/ABI/obsolete/sysfs-kernel-fadump_enabled
index f73632b1c006..ca35a285905b 100644
--- a/Documentation/ABI/testing/sysfs-kernel-fadump_enabled
+++ b/Documentation/ABI/obsolete/sysfs-kernel-fadump_enabled
@@ -1,3 +1,6 @@
+This ABI is deprecated and will be removed after 2021. It is replaced
+with /sys/kernel/fadump/fadump_enabled.
+
What: /sys/kernel/fadump_enabled
Date: Feb 2012
Contact: [email protected]
diff --git a/Documentation/ABI/testing/sysfs-kernel-fadump_registered b/Documentation/ABI/obsolete/sysfs-kernel-fadump_registered
similarity index 71%
rename from Documentation/ABI/testing/sysfs-kernel-fadump_registered
rename to Documentation/ABI/obsolete/sysfs-kernel-fadump_registered
index 972e8c427ad4..2c1bc4adafb4 100644
--- a/Documentation/ABI/testing/sysfs-kernel-fadump_registered
+++ b/Documentation/ABI/obsolete/sysfs-kernel-fadump_registered
@@ -1,3 +1,6 @@
+This ABI is deprecated and will be removed after 2021. It is replaced
+with /sys/kernel/fadump/fadump_registered.
+
What: /sys/kernel/fadump/fadump_registered
Date: Feb 2012
Contact: [email protected]
diff --git a/Documentation/ABI/testing/sysfs-kernel-fadump_release_mem b/Documentation/ABI/obsolete/sysfs-kernel-fadump_release_mem
similarity index 73%
rename from Documentation/ABI/testing/sysfs-kernel-fadump_release_mem
rename to Documentation/ABI/obsolete/sysfs-kernel-fadump_release_mem
index 9c20d64ab48d..8fef37d9b5ba 100644
--- a/Documentation/ABI/testing/sysfs-kernel-fadump_release_mem
+++ b/Documentation/ABI/obsolete/sysfs-kernel-fadump_release_mem
@@ -1,3 +1,6 @@
+This ABI is deprecated and will be removed after 2021. It is replaced
+with /sys/kernel/fadump/fadump_release_mem.
+
What: /sys/kernel/fadump_release_mem
Date: Feb 2012
Contact: [email protected]
diff --git a/Documentation/ABI/testing/sysfs-kernel-fadump_release_opalcore b/Documentation/ABI/obsolete/sysfs-kernel-fadump_release_opalcore
similarity index 70%
rename from Documentation/ABI/testing/sysfs-kernel-fadump_release_opalcore
rename to Documentation/ABI/obsolete/sysfs-kernel-fadump_release_opalcore
index 53313c1d4e7a..c02be8f4471e 100644
--- a/Documentation/ABI/testing/sysfs-kernel-fadump_release_opalcore
+++ b/Documentation/ABI/obsolete/sysfs-kernel-fadump_release_opalcore
@@ -1,3 +1,6 @@
+This ABI is deprecated and will be removed after 2021. It is replaced
+with /sys/kernel/fadump/fadump_release_opalcore.
+
What: /sys/kernel/fadump_release_opalcore
Date: Sep 2019
Contact: [email protected]
diff --git a/Documentation/powerpc/firmware-assisted-dump.rst b/Documentation/powerpc/firmware-assisted-dump.rst
index 0455a78486d5..4fd7f5eab97d 100644
--- a/Documentation/powerpc/firmware-assisted-dump.rst
+++ b/Documentation/powerpc/firmware-assisted-dump.rst
@@ -292,6 +292,15 @@ Here is the list of files under kernel sysfs:

echo 1 > /sys/kernel/fadump_release_opalcore

+Note: The following FADump sysfs files are deprecated.
+
+ Deprecated Alternative
+ -------------------------------------------------------------------------------
+ /sys/kernel/fadump_enabled /sys/kernel/fadump/fadump_enabled
+ /sys/kernel/fadump_registered /sys/kernel/fadump/fadump_registered
+ /sys/kernel/fadump_release_mem /sys/kernel/fadump/fadump_release_mem
+ /sys/kernel/fadump_release_opalcore /sys/kernel/fadump/fadump_release_opalcore
+
Here is the list of files under powerpc debugfs:
(Assuming debugfs is mounted on /sys/kernel/debug directory.)

--
2.17.2

2019-09-15 15:13:28

by Sourabh Jain

[permalink] [raw]
Subject: [PATCH 1/4] powerpc/fadump: replicate /sys/kernel/fadump_* sysfs into /sys/kernel/fadump/

As the number of FADump sysfs files increases it is hard to manage all of
them inside /sys/kernel directory. It's better to have all the FADump
related sysfs files in a dedicated directory /sys/kernel/fadump. But to
maintain the backward compatibility all the /sys/kernel/fadump_* sysfs
files are replicated inside /sys/kernel/fadump/ and eventually get removed
in future.

Added ABI documentation for all the replicated FADump sysfs file in
Documentation/ABI/testing/sysfs-kernel-fadump.

Signed-off-by: Sourabh Jain <[email protected]>
---
Documentation/ABI/testing/sysfs-kernel-fadump | 41 +++++++++++++++++++
arch/powerpc/kernel/fadump.c | 29 +++++++++++++
arch/powerpc/platforms/powernv/opal-core.c | 7 ++++
3 files changed, 77 insertions(+)
create mode 100644 Documentation/ABI/testing/sysfs-kernel-fadump

diff --git a/Documentation/ABI/testing/sysfs-kernel-fadump b/Documentation/ABI/testing/sysfs-kernel-fadump
new file mode 100644
index 000000000000..ed8eec3d759c
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-kernel-fadump
@@ -0,0 +1,41 @@
+What: /sys/kernel/fadump/fadump_*
+Date: Sep 2019
+Contact: [email protected]
+Description:
+ The /sys/kernel/fadump/fadump_* is a collection of FADump
+ sysfs file provide information about the configuration status
+ of Firmware Assisted Dump (FADump).
+
+What: /sys/kernel/fadump/enabled
+Date: Sep 2019
+Contact: [email protected]
+Description: read only
+ Primarily used to identify whether the FADump is enabled in
+ the kernel or not.
+User: Kdump service
+
+What: /sys/kernel/fadump/registered
+Date: Sep 2019
+Contact: [email protected]
+Description: read/write
+ Helps to control the dump collect feature from userspace.
+ Setting 1 to this file enables the system to collect the
+ dump and 0 to disable it.
+User: Kdump service
+
+What: /sys/kernel/fadump/release_mem
+Date: Sep 2019
+Contact: [email protected]
+Description: write only
+ This is a special sysfs file and only available when
+ the system is booted to capture the vmcore using FADump.
+ It is used to release the memory reserved by FADump to
+ save the crash dump.
+
+What: /sys/kernel/fadump/release_opalcore
+Date: Sep 2019
+Contact: [email protected]
+Description: write only
+ The sysfs file is available when the system is booted to
+ collect the dump on OPAL based machine. It used to release
+ the memory used to collect the opalcore.
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index ed59855430b9..bb70fa208a86 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -1418,6 +1418,9 @@ static int fadump_region_show(struct seq_file *m, void *private)
return 0;
}

+struct kobject *fadump_kobj;
+EXPORT_SYMBOL_GPL(fadump_kobj);
+
static struct kobj_attribute fadump_release_attr = __ATTR(fadump_release_mem,
0200, NULL,
fadump_release_memory_store);
@@ -1435,6 +1438,11 @@ static void fadump_init_files(void)
struct dentry *debugfs_file;
int rc = 0;

+ fadump_kobj = kobject_create_and_add("fadump", kernel_kobj);
+ if (!fadump_kobj) {
+ pr_err("failed to create fadump kobject\n");
+ return;
+ }
rc = sysfs_create_file(kernel_kobj, &fadump_attr.attr);
if (rc)
printk(KERN_ERR "fadump: unable to create sysfs file"
@@ -1458,6 +1466,27 @@ static void fadump_init_files(void)
printk(KERN_ERR "fadump: unable to create sysfs file"
" fadump_release_mem (%d)\n", rc);
}
+ /* Replicating the following sysfs attributes in a new directory
+ * named fadump.
+ *
+ * - fadump_enabled
+ * - fadump_registered
+ * - fadump_release_mem
+ */
+ rc = sysfs_create_file(fadump_kobj, &fadump_attr.attr);
+ if (rc)
+ pr_err("unable to create fadump/fadump_enabled sysfs file (%d)\n",
+ rc);
+ rc = sysfs_create_file(fadump_kobj, &fadump_register_attr.attr);
+ if (rc)
+ pr_err("unable to create fadump/fadump_registered sysfs file (%d)\n",
+ rc);
+ if (fw_dump.dump_active) {
+ rc = sysfs_create_file(fadump_kobj, &fadump_release_attr.attr);
+ if (rc)
+ pr_err("unable to create fadump/fadump_release_mem sysfs file (%d)\n",
+ rc);
+ }
return;
}

diff --git a/arch/powerpc/platforms/powernv/opal-core.c b/arch/powerpc/platforms/powernv/opal-core.c
index ed895d82c048..8c31aefe8814 100644
--- a/arch/powerpc/platforms/powernv/opal-core.c
+++ b/arch/powerpc/platforms/powernv/opal-core.c
@@ -631,6 +631,13 @@ static int __init opalcore_init(void)
rc);
}

+ /* Replicating the fadump_release_opalcore sysfs file */
+ rc = sysfs_create_file(fadump_kobj, &opalcore_rel_attr.attr);
+ if (rc) {
+ pr_warn("unable to create fadump/fadump_release_opalcore sysfs file (%d)\n",
+ rc)
+ }
+
return 0;
}
fs_initcall(opalcore_init);
--
2.17.2

2019-09-15 15:13:28

by Sourabh Jain

[permalink] [raw]
Subject: [PATCH 4/4] powerpc/fadump: sysfs for fadump memory reservation

Add a sys interface to allow querying the memory reserved by FADump for
saving the crash dump.

Also added Documentation/ABI for the new sysfs file.

Signed-off-by: Sourabh Jain <[email protected]>
---
Documentation/ABI/testing/sysfs-kernel-fadump | 7 +++++++
Documentation/powerpc/firmware-assisted-dump.rst | 5 +++++
arch/powerpc/kernel/fadump.c | 14 ++++++++++++++
3 files changed, 26 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-kernel-fadump b/Documentation/ABI/testing/sysfs-kernel-fadump
index ed8eec3d759c..34cb89173872 100644
--- a/Documentation/ABI/testing/sysfs-kernel-fadump
+++ b/Documentation/ABI/testing/sysfs-kernel-fadump
@@ -39,3 +39,10 @@ Description: write only
The sysfs file is available when the system is booted to
collect the dump on OPAL based machine. It used to release
the memory used to collect the opalcore.
+
+What: /sys/kernel/fadump/fadump_mem_reserved
+Date: Sep 2019
+Contact: [email protected]
+Description: read only
+ Provide information about the amount of memory reserved by
+ FADump to save the crash dump in bytes.
diff --git a/Documentation/powerpc/firmware-assisted-dump.rst b/Documentation/powerpc/firmware-assisted-dump.rst
index 4fd7f5eab97d..7e8404052ba7 100644
--- a/Documentation/powerpc/firmware-assisted-dump.rst
+++ b/Documentation/powerpc/firmware-assisted-dump.rst
@@ -268,6 +268,11 @@ Here is the list of files under kernel sysfs:
be handled and vmcore will not be captured. This interface can be
easily integrated with kdump service start/stop.

+ /sys/kernel/fadump/fadump_mem_reserved
+
+ This is used to display the memory reserved by FADump for saving the
+ crash dump.
+
/sys/kernel/fadump_release_mem
This file is available only when FADump is active during
second kernel. This is used to release the reserved memory
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index bb70fa208a86..d970ce2a8a44 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -1357,6 +1357,13 @@ static ssize_t fadump_enabled_show(struct kobject *kobj,
return sprintf(buf, "%d\n", fw_dump.fadump_enabled);
}

+static ssize_t fadump_mem_reserved_show(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ char *buf)
+{
+ return sprintf(buf, "%ld\n", fw_dump.reserve_dump_area_size);
+}
+
static ssize_t fadump_register_show(struct kobject *kobj,
struct kobj_attribute *attr,
char *buf)
@@ -1430,6 +1437,9 @@ static struct kobj_attribute fadump_attr = __ATTR(fadump_enabled,
static struct kobj_attribute fadump_register_attr = __ATTR(fadump_registered,
0644, fadump_register_show,
fadump_register_store);
+static struct kobj_attribute fadump_mem_reserved_attr =
+ __ATTR(fadump_mem_reserved, 0444,
+ fadump_mem_reserved_show, NULL);

DEFINE_SHOW_ATTRIBUTE(fadump_region);

@@ -1487,6 +1497,10 @@ static void fadump_init_files(void)
pr_err("unable to create fadump/fadump_release_mem sysfs file (%d)\n",
rc);
}
+ rc = sysfs_create_file(fadump_kobj, &fadump_mem_reserved_attr.attr);
+ if (rc)
+ pr_err("unable to create fadump_mem_reserved sysfs file (%d)\n",
+ rc);
return;
}

--
2.17.2

2019-09-15 15:14:27

by Sourabh Jain

[permalink] [raw]
Subject: [PATCH 2/4] Documentation/ABI: add ABI documentation for /sys/kernel/fadump_*

Add the missing ABI documentation for the already available fadump
sysfs files.

Signed-off-by: Sourabh Jain <[email protected]>
---
Documentation/ABI/testing/sysfs-kernel-fadump_enabled | 7 +++++++
Documentation/ABI/testing/sysfs-kernel-fadump_registered | 8 ++++++++
Documentation/ABI/testing/sysfs-kernel-fadump_release_mem | 8 ++++++++
.../ABI/testing/sysfs-kernel-fadump_release_opalcore | 7 +++++++
4 files changed, 30 insertions(+)
create mode 100644 Documentation/ABI/testing/sysfs-kernel-fadump_enabled
create mode 100644 Documentation/ABI/testing/sysfs-kernel-fadump_registered
create mode 100644 Documentation/ABI/testing/sysfs-kernel-fadump_release_mem
create mode 100644 Documentation/ABI/testing/sysfs-kernel-fadump_release_opalcore

diff --git a/Documentation/ABI/testing/sysfs-kernel-fadump_enabled b/Documentation/ABI/testing/sysfs-kernel-fadump_enabled
new file mode 100644
index 000000000000..f73632b1c006
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-kernel-fadump_enabled
@@ -0,0 +1,7 @@
+What: /sys/kernel/fadump_enabled
+Date: Feb 2012
+Contact: [email protected]
+Description: read only
+ Primarily used to identify whether the FADump is enabled in
+ the kernel or not.
+User: Kdump service
diff --git a/Documentation/ABI/testing/sysfs-kernel-fadump_registered b/Documentation/ABI/testing/sysfs-kernel-fadump_registered
new file mode 100644
index 000000000000..972e8c427ad4
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-kernel-fadump_registered
@@ -0,0 +1,8 @@
+What: /sys/kernel/fadump/fadump_registered
+Date: Feb 2012
+Contact: [email protected]
+Description: read/write
+ Helps to control the dump collect feature from userspace.
+ Setting 1 to this file enables the system to collect the
+ dump and 0 to disable it.
+User: Kdump service
diff --git a/Documentation/ABI/testing/sysfs-kernel-fadump_release_mem b/Documentation/ABI/testing/sysfs-kernel-fadump_release_mem
new file mode 100644
index 000000000000..9c20d64ab48d
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-kernel-fadump_release_mem
@@ -0,0 +1,8 @@
+What: /sys/kernel/fadump_release_mem
+Date: Feb 2012
+Contact: [email protected]
+Description: write only
+ This is a special sysfs file and only available when
+ the system is booted to capture the vmcore using FADump.
+ It is used to release the memory reserved by FADump to
+ save the crash dump.
diff --git a/Documentation/ABI/testing/sysfs-kernel-fadump_release_opalcore b/Documentation/ABI/testing/sysfs-kernel-fadump_release_opalcore
new file mode 100644
index 000000000000..53313c1d4e7a
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-kernel-fadump_release_opalcore
@@ -0,0 +1,7 @@
+What: /sys/kernel/fadump_release_opalcore
+Date: Sep 2019
+Contact: [email protected]
+Description: write only
+ The sysfs file is available when the system is booted to
+ collect the dump on OPAL based machine. It used to release
+ the memory used to collect the opalcore.
--
2.17.2