LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
To: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org
Cc: nfont@linux.vnet.ibm.com, naveen.n.rao@linux.vnet.ibm.com,
	aravinda@linux.vnet.ibm.com
Subject: [PATCH] powerpc/pseries: Export raw per-CPU VPA data via debugfs
Date: Thu, 20 Sep 2018 15:45:47 +0530	[thread overview]
Message-ID: <153743854746.12332.9507208773294249019.stgit@aravinda> (raw)

This patch exports the raw per-CPU VPA data via debugfs.
A per-CPU file is created which exports the VPA data of
that CPU to help debug some of the VPA related issues or
to analyze the per-CPU VPA related statistics.

Signed-off-by: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/pseries/lpar.c |   85 +++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index d3992ce..cc12c12 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -48,6 +48,7 @@
 #include <asm/kexec.h>
 #include <asm/fadump.h>
 #include <asm/asm-prototypes.h>
+#include <asm/debugfs.h>
 
 #include "pseries.h"
 
@@ -64,6 +65,16 @@ EXPORT_SYMBOL(plpar_hcall);
 EXPORT_SYMBOL(plpar_hcall9);
 EXPORT_SYMBOL(plpar_hcall_norets);
 
+#ifdef CONFIG_DEBUG_FS
+struct vpa {
+	struct dentry	*file;
+	int		cpu;
+};
+static DEFINE_PER_CPU(struct vpa, cpu_vpa);
+
+static struct dentry *vpa_dir;
+#endif
+
 void vpa_init(int cpu)
 {
 	int hwcpu = get_hard_smp_processor_id(cpu);
@@ -1028,3 +1039,77 @@ static int __init reserve_vrma_context_id(void)
 	return 0;
 }
 machine_device_initcall(pseries, reserve_vrma_context_id);
+
+#ifdef CONFIG_DEBUG_FS
+/* debugfs file interface for vpa data */
+static ssize_t vpa_file_read(struct file *filp, char __user *buf, size_t len,
+		loff_t *pos)
+{
+	long int rc;
+	struct vpa *vpa = filp->private_data;
+	struct lppaca *lppaca = &lppaca_of(vpa->cpu);
+
+	if (len < sizeof(struct lppaca))
+		return -EINVAL;
+
+	rc = copy_to_user(buf, lppaca, sizeof(struct lppaca));
+	if (rc)
+		return -EFAULT;
+
+	return 0;
+}
+
+static int vpa_file_open(struct inode *inode, struct file *filp)
+{
+	struct vpa *vpa = inode->i_private;
+
+	filp->private_data = vpa;
+	return 0;
+}
+
+static int vpa_file_release(struct inode *inode, struct file *filp)
+{
+	return 0;
+}
+
+static const struct file_operations vpa_fops = {
+	.open		= vpa_file_open,
+	.release	= vpa_file_release,
+	.read		= vpa_file_read,
+	.llseek		= no_llseek,
+};
+
+static int __init vpa_debugfs_init(void)
+{
+	char name[10];
+	int i;
+
+	if (!firmware_has_feature(FW_FEATURE_SPLPAR))
+		return 0;
+
+	vpa_dir = debugfs_create_dir("vpa", powerpc_debugfs_root);
+	if (!vpa_dir) {
+		pr_warn("%s: can't create vpa root dir\n", __func__);
+		return -ENOMEM;
+	}
+
+	/* set up the per-cpu vpa file*/
+	for_each_possible_cpu(i) {
+		struct vpa *vpa = &per_cpu(cpu_vpa, i);
+
+		vpa->cpu = i;
+		sprintf(name, "cpu-%d", i);
+
+		vpa->file = debugfs_create_file(name, 0400, vpa_dir, vpa,
+					&vpa_fops);
+		if (!vpa->file) {
+			pr_warn("%s: can't create per-cpu vpa file\n",
+					__func__);
+			return -ENOMEM;
+		}
+	}
+
+	return 0;
+}
+machine_arch_initcall(pseries, vpa_debugfs_init);
+#endif /* CONFIG_DEBUG_FS */

             reply	other threads:[~2018-09-20 10:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-20 10:15 Aravinda Prasad [this message]
2018-09-24 11:42 ` [PATCH] powerpc/pseries: Export raw per-CPU VPA data via debugfs Michael Ellerman
2018-09-25  6:24   ` Aravinda Prasad

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=153743854746.12332.9507208773294249019.stgit@aravinda \
    --to=aravinda@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=nfont@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox