LinuxPPC-Dev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v3 0/4] reorganize and add FADump sysfs files
@ 2019-11-09 12:23 Sourabh Jain
  2019-11-09 12:23 ` [PATCH v3 1/4] Documentation/ABI: add ABI documentation for /sys/kernel/fadump_* Sourabh Jain
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Sourabh Jain @ 2019-11-09 12:23 UTC (permalink / raw)
  To: mpe
  Cc: corbet, mahesh, linux-doc, linux-kernel, Sourabh Jain,
	linuxppc-dev, hbathini

Currently, 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 /sys/kernel/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.

Changelog:

v1->v2:
 - Move fadump_release_opalcore sysfs to FADump Kobject instead of
   replicating.
 - Changed the patch order 1,2,3,4 -> 2,1,3,4 (First add the ABI doc for
   exisiting sysfs file then replicate them under FADump kobject).

v2->v3:
 - Remove the fadump_ prefix from replicated FADump sysfs file names.

Sourabh Jain (4):
  Documentation/ABI: add ABI documentation for /sys/kernel/fadump_*
  powerpc/fadump: reorganize /sys/kernel/fadump_* sysfs files
  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      |  9 ++++
 Documentation/ABI/testing/sysfs-kernel-fadump | 48 +++++++++++++++++
 .../powerpc/firmware-assisted-dump.rst        | 20 ++++++-
 arch/powerpc/kernel/fadump.c                  | 53 +++++++++++++++++++
 arch/powerpc/platforms/powernv/opal-core.c    | 10 ++--
 8 files changed, 167 insertions(+), 5 deletions(-)
 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/removed/sysfs-kernel-fadump_release_opalcore
 create mode 100644 Documentation/ABI/testing/sysfs-kernel-fadump

-- 
2.17.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3 1/4] Documentation/ABI: add ABI documentation for /sys/kernel/fadump_*
  2019-11-09 12:23 [PATCH v3 0/4] reorganize and add FADump sysfs files Sourabh Jain
@ 2019-11-09 12:23 ` Sourabh Jain
  2019-11-09 12:23 ` [PATCH v3 2/4] powerpc/fadump: reorganize /sys/kernel/fadump_* sysfs files Sourabh Jain
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Sourabh Jain @ 2019-11-09 12:23 UTC (permalink / raw)
  To: mpe
  Cc: corbet, mahesh, linux-doc, linux-kernel, Sourabh Jain,
	linuxppc-dev, hbathini

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

Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
---
 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:	linuxppc-dev@lists.ozlabs.org
+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..dcf925e53f0f
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-kernel-fadump_registered
@@ -0,0 +1,8 @@
+What:		/sys/kernel/fadump_registered
+Date:		Feb 2012
+Contact:	linuxppc-dev@lists.ozlabs.org
+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:	linuxppc-dev@lists.ozlabs.org
+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:	linuxppc-dev@lists.ozlabs.org
+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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3 2/4] powerpc/fadump: reorganize /sys/kernel/fadump_* sysfs files
  2019-11-09 12:23 [PATCH v3 0/4] reorganize and add FADump sysfs files Sourabh Jain
  2019-11-09 12:23 ` [PATCH v3 1/4] Documentation/ABI: add ABI documentation for /sys/kernel/fadump_* Sourabh Jain
@ 2019-11-09 12:23 ` Sourabh Jain
  2019-11-09 12:59   ` Michal Suchánek
  2019-11-23 11:21   ` kbuild test robot
  2019-11-09 12:23 ` [PATCH v3 3/4] Documentation/ABI: mark /sys/kernel/fadump_* sysfs files deprecated Sourabh Jain
  2019-11-09 12:23 ` [PATCH v3 4/4] powerpc/fadump: sysfs for fadump memory reservation Sourabh Jain
  3 siblings, 2 replies; 11+ messages in thread
From: Sourabh Jain @ 2019-11-09 12:23 UTC (permalink / raw)
  To: mpe
  Cc: corbet, mahesh, linux-doc, linux-kernel, Sourabh Jain,
	linuxppc-dev, hbathini

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 in
order to maintain the backward compatibility the /sys/kernel/fadump_*
sysfs files are replicated inside /sys/kernel/fadump/ and eventually get
removed in future.

As the FADump sysfs files are now part of dedicated directory there is no
need to prefix their name with fadump_, hence sysfs file names are also
updated. For example fadump_enabled sysfs file is now referred as enabled.

Also consolidate ABI documentation for all the FADump sysfs files in a
single file Documentation/ABI/testing/sysfs-kernel-fadump.

Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
---
 Documentation/ABI/testing/sysfs-kernel-fadump | 41 +++++++++++++++++++
 arch/powerpc/kernel/fadump.c                  | 38 +++++++++++++++++
 arch/powerpc/platforms/powernv/opal-core.c    | 10 +++--
 3 files changed, 86 insertions(+), 3 deletions(-)
 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..a77f1a5ba389
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-kernel-fadump
@@ -0,0 +1,41 @@
+What:		/sys/kernel/fadump/*
+Date:		Nov 2019
+Contact:	linuxppc-dev@lists.ozlabs.org
+Description:
+		The /sys/kernel/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:		Nov 2019
+Contact:	linuxppc-dev@lists.ozlabs.org
+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:		Nov 2019
+Contact:	linuxppc-dev@lists.ozlabs.org
+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:		Nov 2019
+Contact:	linuxppc-dev@lists.ozlabs.org
+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:		Nov 2019
+Contact:	linuxppc-dev@lists.ozlabs.org
+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..a9591def0c84 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);
@@ -1428,6 +1431,16 @@ static struct kobj_attribute fadump_register_attr = __ATTR(fadump_registered,
 						0644, fadump_register_show,
 						fadump_register_store);
 
+static struct kobj_attribute release_attr = __ATTR(release_mem,
+						0200, NULL,
+						fadump_release_memory_store);
+static struct kobj_attribute enable_attr = __ATTR(enabled,
+						0444, fadump_enabled_show,
+						NULL);
+static struct kobj_attribute register_attr = __ATTR(registered,
+						0644, fadump_register_show,
+						fadump_register_store);
+
 DEFINE_SHOW_ATTRIBUTE(fadump_region);
 
 static void fadump_init_files(void)
@@ -1435,6 +1448,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 +1476,26 @@ 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 under FADump kobject.
+	 *
+	 *	- fadump_enabled -> enabled
+	 *	- fadump_registered -> registered
+	 *	- fadump_release_mem -> release_mem
+	 */
+	rc = sysfs_create_file(fadump_kobj, &enable_attr.attr);
+	if (rc)
+		pr_err("unable to create enabled sysfs file (%d)\n",
+		       rc);
+	rc = sysfs_create_file(fadump_kobj, &register_attr.attr);
+	if (rc)
+		pr_err("unable to create registered sysfs file (%d)\n",
+		       rc);
+	if (fw_dump.dump_active) {
+		rc = sysfs_create_file(fadump_kobj, &release_attr.attr);
+		if (rc)
+			pr_err("unable to create 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..b001e2242909 100644
--- a/arch/powerpc/platforms/powernv/opal-core.c
+++ b/arch/powerpc/platforms/powernv/opal-core.c
@@ -589,7 +589,7 @@ static ssize_t fadump_release_opalcore_store(struct kobject *kobj,
 	return count;
 }
 
-static struct kobj_attribute opalcore_rel_attr = __ATTR(fadump_release_opalcore,
+static struct kobj_attribute opalcore_rel_attr = __ATTR(release_opalcore,
 						0200, NULL,
 						fadump_release_opalcore_store);
 
@@ -625,9 +625,13 @@ static int __init opalcore_init(void)
 		return rc;
 	}
 
-	rc = sysfs_create_file(kernel_kobj, &opalcore_rel_attr.attr);
+	/*
+	 * Originally fadump_release_opalcore sysfs was part of kernel_kobj
+	 * later moved to fadump_kobj and renamed to release_opalcore.
+	 */
+	rc = sysfs_create_file(fadump_kobj, &opalcore_rel_attr.attr);
 	if (rc) {
-		pr_warn("unable to create sysfs file fadump_release_opalcore (%d)\n",
+		pr_warn("unable to create sysfs file release_opalcore (%d)\n",
 			rc);
 	}
 
-- 
2.17.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3 3/4] Documentation/ABI: mark /sys/kernel/fadump_* sysfs files deprecated
  2019-11-09 12:23 [PATCH v3 0/4] reorganize and add FADump sysfs files Sourabh Jain
  2019-11-09 12:23 ` [PATCH v3 1/4] Documentation/ABI: add ABI documentation for /sys/kernel/fadump_* Sourabh Jain
  2019-11-09 12:23 ` [PATCH v3 2/4] powerpc/fadump: reorganize /sys/kernel/fadump_* sysfs files Sourabh Jain
@ 2019-11-09 12:23 ` Sourabh Jain
  2019-11-09 12:23 ` [PATCH v3 4/4] powerpc/fadump: sysfs for fadump memory reservation Sourabh Jain
  3 siblings, 0 replies; 11+ messages in thread
From: Sourabh Jain @ 2019-11-09 12:23 UTC (permalink / raw)
  To: mpe
  Cc: corbet, mahesh, linux-doc, linux-kernel, Sourabh Jain,
	linuxppc-dev, hbathini

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 <sourabhjain@linux.ibm.com>
---
 .../sysfs-kernel-fadump_enabled                   |  3 +++
 .../sysfs-kernel-fadump_registered                |  3 +++
 .../sysfs-kernel-fadump_release_mem               |  3 +++
 .../sysfs-kernel-fadump_release_opalcore          |  2 ++
 Documentation/powerpc/firmware-assisted-dump.rst  | 15 +++++++++++++--
 5 files changed, 24 insertions(+), 2 deletions(-)
 rename Documentation/ABI/{testing => obsolete}/sysfs-kernel-fadump_enabled (67%)
 rename Documentation/ABI/{testing => obsolete}/sysfs-kernel-fadump_registered (72%)
 rename Documentation/ABI/{testing => obsolete}/sysfs-kernel-fadump_release_mem (74%)
 rename Documentation/ABI/{testing => removed}/sysfs-kernel-fadump_release_opalcore (82%)

diff --git a/Documentation/ABI/testing/sysfs-kernel-fadump_enabled b/Documentation/ABI/obsolete/sysfs-kernel-fadump_enabled
similarity index 67%
rename from Documentation/ABI/testing/sysfs-kernel-fadump_enabled
rename to Documentation/ABI/obsolete/sysfs-kernel-fadump_enabled
index f73632b1c006..96f49f979e9c 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/enabled.
+
 What:		/sys/kernel/fadump_enabled
 Date:		Feb 2012
 Contact:	linuxppc-dev@lists.ozlabs.org
diff --git a/Documentation/ABI/testing/sysfs-kernel-fadump_registered b/Documentation/ABI/obsolete/sysfs-kernel-fadump_registered
similarity index 72%
rename from Documentation/ABI/testing/sysfs-kernel-fadump_registered
rename to Documentation/ABI/obsolete/sysfs-kernel-fadump_registered
index dcf925e53f0f..11ab41c673de 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/registered.
+
 What:		/sys/kernel/fadump_registered
 Date:		Feb 2012
 Contact:	linuxppc-dev@lists.ozlabs.org
diff --git a/Documentation/ABI/testing/sysfs-kernel-fadump_release_mem b/Documentation/ABI/obsolete/sysfs-kernel-fadump_release_mem
similarity index 74%
rename from Documentation/ABI/testing/sysfs-kernel-fadump_release_mem
rename to Documentation/ABI/obsolete/sysfs-kernel-fadump_release_mem
index 9c20d64ab48d..69308b28cb0d 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/release_mem.
+
 What:		/sys/kernel/fadump_release_mem
 Date:		Feb 2012
 Contact:	linuxppc-dev@lists.ozlabs.org
diff --git a/Documentation/ABI/testing/sysfs-kernel-fadump_release_opalcore b/Documentation/ABI/removed/sysfs-kernel-fadump_release_opalcore
similarity index 82%
rename from Documentation/ABI/testing/sysfs-kernel-fadump_release_opalcore
rename to Documentation/ABI/removed/sysfs-kernel-fadump_release_opalcore
index 53313c1d4e7a..fe42956a3f41 100644
--- a/Documentation/ABI/testing/sysfs-kernel-fadump_release_opalcore
+++ b/Documentation/ABI/removed/sysfs-kernel-fadump_release_opalcore
@@ -1,3 +1,5 @@
+This ABI is moved to /sys/kernel/fadump/release_opalcore.
+
 What:		/sys/kernel/fadump_release_opalcore
 Date:		Sep 2019
 Contact:	linuxppc-dev@lists.ozlabs.org
diff --git a/Documentation/powerpc/firmware-assisted-dump.rst b/Documentation/powerpc/firmware-assisted-dump.rst
index 0455a78486d5..fc7b06408cea 100644
--- a/Documentation/powerpc/firmware-assisted-dump.rst
+++ b/Documentation/powerpc/firmware-assisted-dump.rst
@@ -283,14 +283,25 @@ Here is the list of files under kernel sysfs:
     enhanced to use this interface to release the memory reserved for
     dump and continue without 2nd reboot.
 
- /sys/kernel/fadump_release_opalcore
+Note: /sys/kernel/fadump_release_opalcore sysfs has moved to
+      /sys/kernel/fadump/release_opalcore.
+
+ /sys/kernel/fadump/release_opalcore
 
     This file is available only on OPAL based machines when FADump is
     active during capture kernel. This is used to release the memory
     used by the kernel to export /sys/firmware/opal/core file. To
     release this memory, echo '1' to it:
 
-    echo 1  > /sys/kernel/fadump_release_opalcore
+    echo 1  > /sys/kernel/fadump/release_opalcore
+
+Note: The following FADump sysfs files are deprecated.
+
+    Deprecated                           Alternative
+    --------------------------------------------------------------------
+    /sys/kernel/fadump_enabled           /sys/kernel/fadump/enabled
+    /sys/kernel/fadump_registered        /sys/kernel/fadump/registered
+    /sys/kernel/fadump_release_mem       /sys/kernel/fadump/release_mem
 
 Here is the list of files under powerpc debugfs:
 (Assuming debugfs is mounted on /sys/kernel/debug directory.)
-- 
2.17.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3 4/4] powerpc/fadump: sysfs for fadump memory reservation
  2019-11-09 12:23 [PATCH v3 0/4] reorganize and add FADump sysfs files Sourabh Jain
                   ` (2 preceding siblings ...)
  2019-11-09 12:23 ` [PATCH v3 3/4] Documentation/ABI: mark /sys/kernel/fadump_* sysfs files deprecated Sourabh Jain
@ 2019-11-09 12:23 ` Sourabh Jain
  3 siblings, 0 replies; 11+ messages in thread
From: Sourabh Jain @ 2019-11-09 12:23 UTC (permalink / raw)
  To: mpe
  Cc: corbet, mahesh, linux-doc, linux-kernel, Sourabh Jain,
	linuxppc-dev, hbathini

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 <sourabhjain@linux.ibm.com>
---
 Documentation/ABI/testing/sysfs-kernel-fadump    |  7 +++++++
 Documentation/powerpc/firmware-assisted-dump.rst |  5 +++++
 arch/powerpc/kernel/fadump.c                     | 15 +++++++++++++++
 3 files changed, 27 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-kernel-fadump b/Documentation/ABI/testing/sysfs-kernel-fadump
index a77f1a5ba389..c1d87c787b9a 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/mem_reserved
+Date:		Nov 2019
+Contact:	linuxppc-dev@lists.ozlabs.org
+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 fc7b06408cea..01c3c9461cd5 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/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 a9591def0c84..2ed80f7b2652 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)
@@ -1440,6 +1447,10 @@ static struct kobj_attribute enable_attr = __ATTR(enabled,
 static struct kobj_attribute register_attr = __ATTR(registered,
 						0644, fadump_register_show,
 						fadump_register_store);
+static struct kobj_attribute mem_reserved_attr = __ATTR(mem_reserved,
+						0444, fadump_mem_reserved_show,
+						NULL);
+
 
 DEFINE_SHOW_ATTRIBUTE(fadump_region);
 
@@ -1496,6 +1507,10 @@ static void fadump_init_files(void)
 			pr_err("unable to create release_mem sysfs file (%d)\n",
 			       rc);
 	}
+	rc = sysfs_create_file(fadump_kobj, &mem_reserved_attr.attr);
+	if (rc)
+		pr_err("unable to create mem_reserved sysfs file (%d)\n",
+		       rc);
 	return;
 }
 
-- 
2.17.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 2/4] powerpc/fadump: reorganize /sys/kernel/fadump_* sysfs files
  2019-11-09 12:23 ` [PATCH v3 2/4] powerpc/fadump: reorganize /sys/kernel/fadump_* sysfs files Sourabh Jain
@ 2019-11-09 12:59   ` Michal Suchánek
  2019-11-16 14:37     ` Sourabh Jain
  2019-11-23 11:21   ` kbuild test robot
  1 sibling, 1 reply; 11+ messages in thread
From: Michal Suchánek @ 2019-11-09 12:59 UTC (permalink / raw)
  To: Sourabh Jain
  Cc: linux-doc, mahesh, corbet, linux-kernel, linuxppc-dev, hbathini

On Sat, Nov 09, 2019 at 05:53:37PM +0530, Sourabh Jain wrote:
> 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 in
> order to maintain the backward compatibility the /sys/kernel/fadump_*
> sysfs files are replicated inside /sys/kernel/fadump/ and eventually get
> removed in future.
> 
> As the FADump sysfs files are now part of dedicated directory there is no
> need to prefix their name with fadump_, hence sysfs file names are also
> updated. For example fadump_enabled sysfs file is now referred as enabled.
> 
> Also consolidate ABI documentation for all the FADump sysfs files in a
> single file Documentation/ABI/testing/sysfs-kernel-fadump.
> 
> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
> ---
>  Documentation/ABI/testing/sysfs-kernel-fadump | 41 +++++++++++++++++++
>  arch/powerpc/kernel/fadump.c                  | 38 +++++++++++++++++
>  arch/powerpc/platforms/powernv/opal-core.c    | 10 +++--
>  3 files changed, 86 insertions(+), 3 deletions(-)
>  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..a77f1a5ba389
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-kernel-fadump
> @@ -0,0 +1,41 @@
> +What:		/sys/kernel/fadump/*
> +Date:		Nov 2019
> +Contact:	linuxppc-dev@lists.ozlabs.org
> +Description:
> +		The /sys/kernel/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:		Nov 2019
> +Contact:	linuxppc-dev@lists.ozlabs.org
> +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:		Nov 2019
> +Contact:	linuxppc-dev@lists.ozlabs.org
> +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:		Nov 2019
> +Contact:	linuxppc-dev@lists.ozlabs.org
> +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:		Nov 2019
> +Contact:	linuxppc-dev@lists.ozlabs.org
> +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..a9591def0c84 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);
> @@ -1428,6 +1431,16 @@ static struct kobj_attribute fadump_register_attr = __ATTR(fadump_registered,
>  						0644, fadump_register_show,
>  						fadump_register_store);
>  
> +static struct kobj_attribute release_attr = __ATTR(release_mem,
> +						0200, NULL,
> +						fadump_release_memory_store);
> +static struct kobj_attribute enable_attr = __ATTR(enabled,
> +						0444, fadump_enabled_show,
> +						NULL);
> +static struct kobj_attribute register_attr = __ATTR(registered,
> +						0644, fadump_register_show,
> +						fadump_register_store);
> +
>  DEFINE_SHOW_ATTRIBUTE(fadump_region);
>  
>  static void fadump_init_files(void)
> @@ -1435,6 +1448,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 +1476,26 @@ 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 under FADump kobject.
> +	 *
> +	 *	- fadump_enabled -> enabled
> +	 *	- fadump_registered -> registered
> +	 *	- fadump_release_mem -> release_mem
> +	 */
> +	rc = sysfs_create_file(fadump_kobj, &enable_attr.attr);
> +	if (rc)
> +		pr_err("unable to create enabled sysfs file (%d)\n",
> +		       rc);
> +	rc = sysfs_create_file(fadump_kobj, &register_attr.attr);
> +	if (rc)
> +		pr_err("unable to create registered sysfs file (%d)\n",
> +		       rc);
> +	if (fw_dump.dump_active) {
> +		rc = sysfs_create_file(fadump_kobj, &release_attr.attr);
> +		if (rc)
> +			pr_err("unable to create release_mem sysfs file (%d)\n",
> +			       rc);
> +	}
>  	return;
>  }
Hello,

wouldn't it make more sense to create the files in the new location and
add a symlink at the old location?

Also your error messages aren't really readeable. Without the fadump_
prefix it's not clear what's going on here. Perhaps quoting the file
name and saying fadump somewhere in the message would be useful.

Thanks

Michal

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 2/4] powerpc/fadump: reorganize /sys/kernel/fadump_* sysfs files
  2019-11-09 12:59   ` Michal Suchánek
@ 2019-11-16 14:37     ` Sourabh Jain
  2019-11-24 18:40       ` Michal Suchánek
  0 siblings, 1 reply; 11+ messages in thread
From: Sourabh Jain @ 2019-11-16 14:37 UTC (permalink / raw)
  To: Michal Suchánek
  Cc: linux-doc, mahesh, corbet, linux-kernel, linuxppc-dev, hbathini



On 11/9/19 6:29 PM, Michal Suchánek wrote:
> On Sat, Nov 09, 2019 at 05:53:37PM +0530, Sourabh Jain wrote:
>> 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 in
>> order to maintain the backward compatibility the /sys/kernel/fadump_*
>> sysfs files are replicated inside /sys/kernel/fadump/ and eventually get
>> removed in future.
>>
>> As the FADump sysfs files are now part of dedicated directory there is no
>> need to prefix their name with fadump_, hence sysfs file names are also
>> updated. For example fadump_enabled sysfs file is now referred as enabled.
>>
>> Also consolidate ABI documentation for all the FADump sysfs files in a
>> single file Documentation/ABI/testing/sysfs-kernel-fadump.
>>
>> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
>> ---
>>  Documentation/ABI/testing/sysfs-kernel-fadump | 41 +++++++++++++++++++
>>  arch/powerpc/kernel/fadump.c                  | 38 +++++++++++++++++
>>  arch/powerpc/platforms/powernv/opal-core.c    | 10 +++--
>>  3 files changed, 86 insertions(+), 3 deletions(-)
>>  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..a77f1a5ba389
>> --- /dev/null
>> +++ b/Documentation/ABI/testing/sysfs-kernel-fadump
>> @@ -0,0 +1,41 @@
>> +What:		/sys/kernel/fadump/*
>> +Date:		Nov 2019
>> +Contact:	linuxppc-dev@lists.ozlabs.org
>> +Description:
>> +		The /sys/kernel/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:		Nov 2019
>> +Contact:	linuxppc-dev@lists.ozlabs.org
>> +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:		Nov 2019
>> +Contact:	linuxppc-dev@lists.ozlabs.org
>> +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:		Nov 2019
>> +Contact:	linuxppc-dev@lists.ozlabs.org
>> +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:		Nov 2019
>> +Contact:	linuxppc-dev@lists.ozlabs.org
>> +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..a9591def0c84 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);
>> @@ -1428,6 +1431,16 @@ static struct kobj_attribute fadump_register_attr = __ATTR(fadump_registered,
>>  						0644, fadump_register_show,
>>  						fadump_register_store);
>>  
>> +static struct kobj_attribute release_attr = __ATTR(release_mem,
>> +						0200, NULL,
>> +						fadump_release_memory_store);
>> +static struct kobj_attribute enable_attr = __ATTR(enabled,
>> +						0444, fadump_enabled_show,
>> +						NULL);
>> +static struct kobj_attribute register_attr = __ATTR(registered,
>> +						0644, fadump_register_show,
>> +						fadump_register_store);
>> +
>>  DEFINE_SHOW_ATTRIBUTE(fadump_region);
>>  
>>  static void fadump_init_files(void)
>> @@ -1435,6 +1448,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 +1476,26 @@ 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 under FADump kobject.
>> +	 *
>> +	 *	- fadump_enabled -> enabled
>> +	 *	- fadump_registered -> registered
>> +	 *	- fadump_release_mem -> release_mem
>> +	 */
>> +	rc = sysfs_create_file(fadump_kobj, &enable_attr.attr);
>> +	if (rc)
>> +		pr_err("unable to create enabled sysfs file (%d)\n",
>> +		       rc);
>> +	rc = sysfs_create_file(fadump_kobj, &register_attr.attr);
>> +	if (rc)
>> +		pr_err("unable to create registered sysfs file (%d)\n",
>> +		       rc);
>> +	if (fw_dump.dump_active) {
>> +		rc = sysfs_create_file(fadump_kobj, &release_attr.attr);
>> +		if (rc)
>> +			pr_err("unable to create release_mem sysfs file (%d)\n",
>> +			       rc);
>> +	}
>>  	return;
>>  }
> Hello,
> 

I’m so sorry for taking this long to write you back. 

> wouldn't it make more sense to create the files in the new location and
> add a symlink at the old location?

There are APIs which allow to create a symlink for an entire kobject but
I did not find a way to create symlink of an individual sysfs file.

Do you have any approach in mind to achieve the same?


> Also your error messages aren't really readeable. Without the fadump_
> prefix it's not clear what's going on here. Perhaps quoting the file
> name and saying fadump somewhere in the message would be useful.

The pr_err function will prefix the error message with fadump: string.
I think that will solve the above issue.


Thanks,

Sourabh Jain


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 2/4] powerpc/fadump: reorganize /sys/kernel/fadump_* sysfs files
  2019-11-09 12:23 ` [PATCH v3 2/4] powerpc/fadump: reorganize /sys/kernel/fadump_* sysfs files Sourabh Jain
  2019-11-09 12:59   ` Michal Suchánek
@ 2019-11-23 11:21   ` kbuild test robot
  1 sibling, 0 replies; 11+ messages in thread
From: kbuild test robot @ 2019-11-23 11:21 UTC (permalink / raw)
  To: Sourabh Jain
  Cc: kbuild-all, corbet, linux-doc, linux-kernel, Sourabh Jain,
	linuxppc-dev, mahesh, hbathini

[-- Attachment #1: Type: text/plain, Size: 3069 bytes --]

Hi Sourabh,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on v5.4-rc8 next-20191122]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Sourabh-Jain/reorganize-and-add-FADump-sysfs-files/20191110-091753
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-rhel-kconfig (attached as .config)
compiler: powerpc64le-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   arch/powerpc/platforms/powernv/opal-core.c: In function 'opalcore_init':
>> arch/powerpc/platforms/powernv/opal-core.c:632:25: error: 'fadump_kobj' undeclared (first use in this function); did you mean 'fadump_ops'?
     rc = sysfs_create_file(fadump_kobj, &opalcore_rel_attr.attr);
                            ^~~~~~~~~~~
                            fadump_ops
   arch/powerpc/platforms/powernv/opal-core.c:632:25: note: each undeclared identifier is reported only once for each function it appears in

vim +632 arch/powerpc/platforms/powernv/opal-core.c

   591	
   592	static struct kobj_attribute opalcore_rel_attr = __ATTR(release_opalcore,
   593							0200, NULL,
   594							fadump_release_opalcore_store);
   595	
   596	static int __init opalcore_init(void)
   597	{
   598		int rc = -1;
   599	
   600		opalcore_config_init();
   601	
   602		if (oc_conf == NULL)
   603			return rc;
   604	
   605		create_opalcore();
   606	
   607		/*
   608		 * If oc_conf->opalcorebuf= is set in the 2nd kernel,
   609		 * then capture the dump.
   610		 */
   611		if (!(is_opalcore_usable())) {
   612			pr_err("Failed to export /sys/firmware/opal/core\n");
   613			opalcore_cleanup();
   614			return rc;
   615		}
   616	
   617		/* Set OPAL core file size */
   618		opal_core_attr.size = oc_conf->opalcore_size;
   619	
   620		/* Export OPAL core sysfs file */
   621		rc = sysfs_create_bin_file(opal_kobj, &opal_core_attr);
   622		if (rc != 0) {
   623			pr_err("Failed to export /sys/firmware/opal/core\n");
   624			opalcore_cleanup();
   625			return rc;
   626		}
   627	
   628		/*
   629		 * Originally fadump_release_opalcore sysfs was part of kernel_kobj
   630		 * later moved to fadump_kobj and renamed to release_opalcore.
   631		 */
 > 632		rc = sysfs_create_file(fadump_kobj, &opalcore_rel_attr.attr);

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 15036 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 2/4] powerpc/fadump: reorganize /sys/kernel/fadump_* sysfs files
  2019-11-16 14:37     ` Sourabh Jain
@ 2019-11-24 18:40       ` Michal Suchánek
  2019-11-27  4:54         ` Sourabh Jain
  2019-12-03 11:20         ` Sourabh Jain
  0 siblings, 2 replies; 11+ messages in thread
From: Michal Suchánek @ 2019-11-24 18:40 UTC (permalink / raw)
  To: Sourabh Jain
  Cc: corbet, mahesh, linux-doc, linux-kernel, linuxppc-dev, hbathini

On Sat, Nov 16, 2019 at 08:07:29PM +0530, Sourabh Jain wrote:
> 
> 
> On 11/9/19 6:29 PM, Michal Suchánek wrote:
> > On Sat, Nov 09, 2019 at 05:53:37PM +0530, Sourabh Jain wrote:
> >> 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 in
> >> order to maintain the backward compatibility the /sys/kernel/fadump_*
> >> sysfs files are replicated inside /sys/kernel/fadump/ and eventually get
> >> removed in future.
> >>
> >> As the FADump sysfs files are now part of dedicated directory there is no
> >> need to prefix their name with fadump_, hence sysfs file names are also
> >> updated. For example fadump_enabled sysfs file is now referred as enabled.
> >>
> >> Also consolidate ABI documentation for all the FADump sysfs files in a
> >> single file Documentation/ABI/testing/sysfs-kernel-fadump.
> >>
> >> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
> >> ---
> >>  Documentation/ABI/testing/sysfs-kernel-fadump | 41 +++++++++++++++++++
> >>  arch/powerpc/kernel/fadump.c                  | 38 +++++++++++++++++
> >>  arch/powerpc/platforms/powernv/opal-core.c    | 10 +++--
> >>  3 files changed, 86 insertions(+), 3 deletions(-)
> >>  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..a77f1a5ba389
> >> --- /dev/null
> >> +++ b/Documentation/ABI/testing/sysfs-kernel-fadump
> >> @@ -0,0 +1,41 @@
> >> +What:		/sys/kernel/fadump/*
> >> +Date:		Nov 2019
> >> +Contact:	linuxppc-dev@lists.ozlabs.org
> >> +Description:
> >> +		The /sys/kernel/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:		Nov 2019
> >> +Contact:	linuxppc-dev@lists.ozlabs.org
> >> +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:		Nov 2019
> >> +Contact:	linuxppc-dev@lists.ozlabs.org
> >> +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:		Nov 2019
> >> +Contact:	linuxppc-dev@lists.ozlabs.org
> >> +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:		Nov 2019
> >> +Contact:	linuxppc-dev@lists.ozlabs.org
> >> +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..a9591def0c84 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);
> >> @@ -1428,6 +1431,16 @@ static struct kobj_attribute fadump_register_attr = __ATTR(fadump_registered,
> >>  						0644, fadump_register_show,
> >>  						fadump_register_store);
> >>  
> >> +static struct kobj_attribute release_attr = __ATTR(release_mem,
> >> +						0200, NULL,
> >> +						fadump_release_memory_store);
> >> +static struct kobj_attribute enable_attr = __ATTR(enabled,
> >> +						0444, fadump_enabled_show,
> >> +						NULL);
> >> +static struct kobj_attribute register_attr = __ATTR(registered,
> >> +						0644, fadump_register_show,
> >> +						fadump_register_store);
> >> +
> >>  DEFINE_SHOW_ATTRIBUTE(fadump_region);
> >>  
> >>  static void fadump_init_files(void)
> >> @@ -1435,6 +1448,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 +1476,26 @@ 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 under FADump kobject.
> >> +	 *
> >> +	 *	- fadump_enabled -> enabled
> >> +	 *	- fadump_registered -> registered
> >> +	 *	- fadump_release_mem -> release_mem
> >> +	 */
> >> +	rc = sysfs_create_file(fadump_kobj, &enable_attr.attr);
> >> +	if (rc)
> >> +		pr_err("unable to create enabled sysfs file (%d)\n",
> >> +		       rc);
> >> +	rc = sysfs_create_file(fadump_kobj, &register_attr.attr);
> >> +	if (rc)
> >> +		pr_err("unable to create registered sysfs file (%d)\n",
> >> +		       rc);
> >> +	if (fw_dump.dump_active) {
> >> +		rc = sysfs_create_file(fadump_kobj, &release_attr.attr);
> >> +		if (rc)
> >> +			pr_err("unable to create release_mem sysfs file (%d)\n",
> >> +			       rc);
> >> +	}
> >>  	return;
> >>  }
> > Hello,
> > 
> 
> I’m so sorry for taking this long to write you back. 
> 
> > wouldn't it make more sense to create the files in the new location and
> > add a symlink at the old location?
> 
> There are APIs which allow to create a symlink for an entire kobject but
> I did not find a way to create symlink of an individual sysfs file.
> 
> Do you have any approach in mind to achieve the same?

There is at least one example of plain symlink:

find /sys -type l -xtype f
/sys/kernel/security/evm

If there is no interface to do one sanely duplicationg the files is
better than nothing.

Thanks

Michal

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 2/4] powerpc/fadump: reorganize /sys/kernel/fadump_* sysfs files
  2019-11-24 18:40       ` Michal Suchánek
@ 2019-11-27  4:54         ` Sourabh Jain
  2019-12-03 11:20         ` Sourabh Jain
  1 sibling, 0 replies; 11+ messages in thread
From: Sourabh Jain @ 2019-11-27  4:54 UTC (permalink / raw)
  To: Michal Suchánek
  Cc: linux-doc, mahesh, corbet, linux-kernel, linuxppc-dev, hbathini



On 11/25/19 12:10 AM, Michal Suchánek wrote:
> On Sat, Nov 16, 2019 at 08:07:29PM +0530, Sourabh Jain wrote:
>>
>>
>> On 11/9/19 6:29 PM, Michal Suchánek wrote:
>>> On Sat, Nov 09, 2019 at 05:53:37PM +0530, Sourabh Jain wrote:
>>>> 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 in
>>>> order to maintain the backward compatibility the /sys/kernel/fadump_*
>>>> sysfs files are replicated inside /sys/kernel/fadump/ and eventually get
>>>> removed in future.
>>>>
>>>> As the FADump sysfs files are now part of dedicated directory there is no
>>>> need to prefix their name with fadump_, hence sysfs file names are also
>>>> updated. For example fadump_enabled sysfs file is now referred as enabled.
>>>>
>>>> Also consolidate ABI documentation for all the FADump sysfs files in a
>>>> single file Documentation/ABI/testing/sysfs-kernel-fadump.
>>>>
>>>> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
>>>> ---
>>>>  Documentation/ABI/testing/sysfs-kernel-fadump | 41 +++++++++++++++++++
>>>>  arch/powerpc/kernel/fadump.c                  | 38 +++++++++++++++++
>>>>  arch/powerpc/platforms/powernv/opal-core.c    | 10 +++--
>>>>  3 files changed, 86 insertions(+), 3 deletions(-)
>>>>  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..a77f1a5ba389
>>>> --- /dev/null
>>>> +++ b/Documentation/ABI/testing/sysfs-kernel-fadump
>>>> @@ -0,0 +1,41 @@
>>>> +What:		/sys/kernel/fadump/*
>>>> +Date:		Nov 2019
>>>> +Contact:	linuxppc-dev@lists.ozlabs.org
>>>> +Description:
>>>> +		The /sys/kernel/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:		Nov 2019
>>>> +Contact:	linuxppc-dev@lists.ozlabs.org
>>>> +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:		Nov 2019
>>>> +Contact:	linuxppc-dev@lists.ozlabs.org
>>>> +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:		Nov 2019
>>>> +Contact:	linuxppc-dev@lists.ozlabs.org
>>>> +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:		Nov 2019
>>>> +Contact:	linuxppc-dev@lists.ozlabs.org
>>>> +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..a9591def0c84 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);
>>>> @@ -1428,6 +1431,16 @@ static struct kobj_attribute fadump_register_attr = __ATTR(fadump_registered,
>>>>  						0644, fadump_register_show,
>>>>  						fadump_register_store);
>>>>  
>>>> +static struct kobj_attribute release_attr = __ATTR(release_mem,
>>>> +						0200, NULL,
>>>> +						fadump_release_memory_store);
>>>> +static struct kobj_attribute enable_attr = __ATTR(enabled,
>>>> +						0444, fadump_enabled_show,
>>>> +						NULL);
>>>> +static struct kobj_attribute register_attr = __ATTR(registered,
>>>> +						0644, fadump_register_show,
>>>> +						fadump_register_store);
>>>> +
>>>>  DEFINE_SHOW_ATTRIBUTE(fadump_region);
>>>>  
>>>>  static void fadump_init_files(void)
>>>> @@ -1435,6 +1448,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 +1476,26 @@ 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 under FADump kobject.
>>>> +	 *
>>>> +	 *	- fadump_enabled -> enabled
>>>> +	 *	- fadump_registered -> registered
>>>> +	 *	- fadump_release_mem -> release_mem
>>>> +	 */
>>>> +	rc = sysfs_create_file(fadump_kobj, &enable_attr.attr);
>>>> +	if (rc)
>>>> +		pr_err("unable to create enabled sysfs file (%d)\n",
>>>> +		       rc);
>>>> +	rc = sysfs_create_file(fadump_kobj, &register_attr.attr);
>>>> +	if (rc)
>>>> +		pr_err("unable to create registered sysfs file (%d)\n",
>>>> +		       rc);
>>>> +	if (fw_dump.dump_active) {
>>>> +		rc = sysfs_create_file(fadump_kobj, &release_attr.attr);
>>>> +		if (rc)
>>>> +			pr_err("unable to create release_mem sysfs file (%d)\n",
>>>> +			       rc);
>>>> +	}
>>>>  	return;
>>>>  }
>>> Hello,
>>>
>>
>> I’m so sorry for taking this long to write you back. 
>>
>>> wouldn't it make more sense to create the files in the new location and
>>> add a symlink at the old location?
>>
>> There are APIs which allow to create a symlink for an entire kobject but
>> I did not find a way to create symlink of an individual sysfs file.
>>
>> Do you have any approach in mind to achieve the same?
> 
> There is at least one example of plain symlink:
> 
> find /sys -type l -xtype f
> /sys/kernel/security/evm

Yes, there are APIs available in debugfs and securityfs that allow creatinga symlink of sysfs files. But I did not find a generic API at sysfs level tocreate symlink.

Let's wait for others to put in their view on this. Meanwhile, I'll start
exploring how we can replace the older FADump sysfs files with symlink.

Thanks,
Sourabh Jain


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 2/4] powerpc/fadump: reorganize /sys/kernel/fadump_* sysfs files
  2019-11-24 18:40       ` Michal Suchánek
  2019-11-27  4:54         ` Sourabh Jain
@ 2019-12-03 11:20         ` Sourabh Jain
  1 sibling, 0 replies; 11+ messages in thread
From: Sourabh Jain @ 2019-12-03 11:20 UTC (permalink / raw)
  To: Michal Suchánek
  Cc: linux-doc, mahesh, corbet, linux-kernel, linuxppc-dev, hbathini

>>>>  DEFINE_SHOW_ATTRIBUTE(fadump_region);
>>>>  
>>>>  static void fadump_init_files(void)
>>>> @@ -1435,6 +1448,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 +1476,26 @@ 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 under FADump kobject.
>>>> +	 *
>>>> +	 *	- fadump_enabled -> enabled
>>>> +	 *	- fadump_registered -> registered
>>>> +	 *	- fadump_release_mem -> release_mem
>>>> +	 */
>>>> +	rc = sysfs_create_file(fadump_kobj, &enable_attr.attr);
>>>> +	if (rc)
>>>> +		pr_err("unable to create enabled sysfs file (%d)\n",
>>>> +		       rc);
>>>> +	rc = sysfs_create_file(fadump_kobj, &register_attr.attr);
>>>> +	if (rc)
>>>> +		pr_err("unable to create registered sysfs file (%d)\n",
>>>> +		       rc);
>>>> +	if (fw_dump.dump_active) {
>>>> +		rc = sysfs_create_file(fadump_kobj, &release_attr.attr);
>>>> +		if (rc)
>>>> +			pr_err("unable to create release_mem sysfs file (%d)\n",
>>>> +			       rc);
>>>> +	}
>>>>  	return;
>>>>  }
>>> Hello,
>>>
>>
>> I’m so sorry for taking this long to write you back. 
>>
>>> wouldn't it make more sense to create the files in the new location and
>>> add a symlink at the old location?
>>
>> There are APIs which allow to create a symlink for an entire kobject but
>> I did not find a way to create symlink of an individual sysfs file.
>>
>> Do you have any approach in mind to achieve the same?
> 
> There is at least one example of plain symlink:
> 
> find /sys -type l -xtype f
> /sys/kernel/security/evm
> 
> If there is no interface to do one sanely duplicationg the files is
> better than nothing.

Hello Michal,

I found a function (__compat_only_sysfs_link_entry_to_kobj) that adds a symlink
to a kobject.

But the problem is __compat_only_sysfs_link_entry_to_kobj function keeps the
symlink file name similar to sysfs file and has no option to change it.

We can't use the __compat_only_sysfs_link_entry_to_kobj function directly because
our symlink file name must be different from the target file name.

	fadump_enabled -> fadump/enabled

But the good thing is we can tweak the __compat_only_sysfs_link_entry_to_kobj
function and allow the caller to change the sysmlink file name.

So I am writing a separate patch that adds a wrapper function around the __compat_only_sysfs_link_entry_to_kobj function which will allow to have a custom symlink file name.

Thanks,
Sourabh Jain


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, back to index

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-09 12:23 [PATCH v3 0/4] reorganize and add FADump sysfs files Sourabh Jain
2019-11-09 12:23 ` [PATCH v3 1/4] Documentation/ABI: add ABI documentation for /sys/kernel/fadump_* Sourabh Jain
2019-11-09 12:23 ` [PATCH v3 2/4] powerpc/fadump: reorganize /sys/kernel/fadump_* sysfs files Sourabh Jain
2019-11-09 12:59   ` Michal Suchánek
2019-11-16 14:37     ` Sourabh Jain
2019-11-24 18:40       ` Michal Suchánek
2019-11-27  4:54         ` Sourabh Jain
2019-12-03 11:20         ` Sourabh Jain
2019-11-23 11:21   ` kbuild test robot
2019-11-09 12:23 ` [PATCH v3 3/4] Documentation/ABI: mark /sys/kernel/fadump_* sysfs files deprecated Sourabh Jain
2019-11-09 12:23 ` [PATCH v3 4/4] powerpc/fadump: sysfs for fadump memory reservation Sourabh Jain

LinuxPPC-Dev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linuxppc-dev/0 linuxppc-dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linuxppc-dev linuxppc-dev/ https://lore.kernel.org/linuxppc-dev \
		linuxppc-dev@lists.ozlabs.org linuxppc-dev@ozlabs.org
	public-inbox-index linuxppc-dev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.ozlabs.lists.linuxppc-dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git