linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/2] Interface to expose VPHN information
@ 2018-12-10 18:14 Naveen N. Rao
  2018-12-10 18:14 ` [PATCH v1 1/2] powerpc/pseries: Generalize hcall_vphn() Naveen N. Rao
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Naveen N. Rao @ 2018-12-10 18:14 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

This is an alternate way to provide statistics around vcpu dispatches in 
a SPLPAR environment. By obtaining access to the VPHN information, and 
in concert with the existing debugfs dtl interface, we can derive 
different statistics related to how vcpus are dispatched by the 
hypervisor.

- Naveen

Naveen N. Rao (2):
  powerpc/pseries: Generalize hcall_vphn()
  powerpc/pseries: Add debugfs interface to retrieve VPHN info

 arch/powerpc/mm/numa.c | 132 ++++++++++++++++++++++++++++++++++++-----
 1 file changed, 118 insertions(+), 14 deletions(-)

-- 
2.19.2


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

* [PATCH v1 1/2] powerpc/pseries: Generalize hcall_vphn()
  2018-12-10 18:14 [PATCH v1 0/2] Interface to expose VPHN information Naveen N. Rao
@ 2018-12-10 18:14 ` Naveen N. Rao
  2018-12-10 18:14 ` [PATCH v1 2/2] powerpc/pseries: Add debugfs interface to retrieve VPHN info Naveen N. Rao
       [not found] ` <e308130fe45a8930743cec9aba83d4885ac8d30d.1544459267.git.naveen.n.rao__35218.1831411601$1544472513$gmane$org@linux.ibm.com>
  2 siblings, 0 replies; 5+ messages in thread
From: Naveen N. Rao @ 2018-12-10 18:14 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

H_HOME_NODE_ASSOCIATIVITY hcall can take two different flags and return
different associativity information in each case. Generalize the
existing hcall_vphn() function to take flags as an argument and to
return the result. Update the only existing user to pass the proper
arguments.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
---
 arch/powerpc/mm/numa.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 87f0dd004295..6677a578f18d 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -1078,6 +1078,17 @@ static void reset_topology_timer(void);
 static int topology_timer_secs = 1;
 static int topology_inited;
 
+static long hcall_vphn(unsigned long cpu, u64 flags, __be32 *associativity)
+{
+	long rc;
+	long retbuf[PLPAR_HCALL9_BUFSIZE] = {0};
+
+	rc = plpar_hcall9(H_HOME_NODE_ASSOCIATIVITY, retbuf, flags, cpu);
+	vphn_unpack_associativity(retbuf, associativity);
+
+	return rc;
+}
+
 /*
  * Change polling interval for associativity changes.
  */
@@ -1156,25 +1167,13 @@ static int update_cpu_associativity_changes_mask(void)
  * Retrieve the new associativity information for a virtual processor's
  * home node.
  */
-static long hcall_vphn(unsigned long cpu, __be32 *associativity)
-{
-	long rc;
-	long retbuf[PLPAR_HCALL9_BUFSIZE] = {0};
-	u64 flags = 1;
-	int hwcpu = get_hard_smp_processor_id(cpu);
-
-	rc = plpar_hcall9(H_HOME_NODE_ASSOCIATIVITY, retbuf, flags, hwcpu);
-	vphn_unpack_associativity(retbuf, associativity);
-
-	return rc;
-}
-
 static long vphn_get_associativity(unsigned long cpu,
 					__be32 *associativity)
 {
 	long rc;
+	int hwcpu = get_hard_smp_processor_id(cpu);
 
-	rc = hcall_vphn(cpu, associativity);
+	rc = hcall_vphn(hwcpu, 1, associativity);
 
 	switch (rc) {
 	case H_FUNCTION:
-- 
2.19.2


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

* [PATCH v1 2/2] powerpc/pseries: Add debugfs interface to retrieve VPHN info
  2018-12-10 18:14 [PATCH v1 0/2] Interface to expose VPHN information Naveen N. Rao
  2018-12-10 18:14 ` [PATCH v1 1/2] powerpc/pseries: Generalize hcall_vphn() Naveen N. Rao
@ 2018-12-10 18:14 ` Naveen N. Rao
       [not found] ` <e308130fe45a8930743cec9aba83d4885ac8d30d.1544459267.git.naveen.n.rao__35218.1831411601$1544472513$gmane$org@linux.ibm.com>
  2 siblings, 0 replies; 5+ messages in thread
From: Naveen N. Rao @ 2018-12-10 18:14 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

Add debugfs interface to retrieve associativity information for lpar
vcpus (debugfs/vphn/lpar) and the hypervisor cpus (debugfs/vphn/hyp).
This information is useful to derive various metrics, including the vcpu
dispatch statistics in a SPLPAR environment.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
---
 arch/powerpc/mm/numa.c | 105 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 105 insertions(+)

diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 6677a578f18d..f0b0e87016e6 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -40,6 +40,7 @@
 #include <asm/setup.h>
 #include <asm/vdso.h>
 #include <asm/drmem.h>
+#include <asm/debugfs.h>
 
 static int numa_enabled = 1;
 
@@ -1089,6 +1090,107 @@ static long hcall_vphn(unsigned long cpu, u64 flags, __be32 *associativity)
 	return rc;
 }
 
+#ifdef CONFIG_DEBUG_FS
+static ssize_t vphn_lpar_cpu_file_read(struct file *filp, char __user *buf,
+		size_t len, loff_t *pos)
+{
+	int cpu = (long)filp->private_data;
+	__be32 associativity[VPHN_ASSOC_BUFSIZE] = {0};
+	int hwcpu = get_hard_smp_processor_id(cpu);
+	long int rc;
+
+	if (len != sizeof(associativity))
+		return -EINVAL;
+
+	rc = hcall_vphn(hwcpu, 1, associativity);
+	if (rc)
+		return -EFAULT;
+
+	rc = copy_to_user(buf, &associativity, sizeof(associativity));
+	if (rc)
+		return -EFAULT;
+
+	return sizeof(associativity);
+}
+
+static ssize_t vphn_hyp_cpu_file_read(struct file *filp, char __user *buf,
+		size_t len, loff_t *pos)
+{
+	int cpu = (long)filp->private_data;
+	__be32 associativity[VPHN_ASSOC_BUFSIZE] = {0};
+	long int rc;
+
+	if (len != sizeof(associativity))
+		return -EINVAL;
+
+	rc = hcall_vphn(cpu, 2, associativity);
+	if (rc)
+		return -EFAULT;
+
+	rc = copy_to_user(buf, &associativity, sizeof(associativity));
+	if (rc)
+		return -EFAULT;
+
+	return sizeof(associativity);
+}
+
+static const struct file_operations vphn_lpar_cpu_fops = {
+	.open		= simple_open,
+	.read		= vphn_lpar_cpu_file_read,
+	.llseek		= no_llseek,
+};
+
+static const struct file_operations vphn_hyp_cpu_fops = {
+	.open		= simple_open,
+	.read		= vphn_hyp_cpu_file_read,
+	.llseek		= no_llseek,
+};
+
+static int debug_init_vphn_entries(void)
+{
+	struct dentry *vphn_dir, *vphn_lpar_dir, *vphn_hyp_dir;
+	struct dentry *vphn_lpar_cpu_file, *vphn_hyp_cpu_file;
+	long cpu;
+	char name[10];
+
+	if (!firmware_has_feature(FW_FEATURE_SPLPAR))
+		return 0;
+
+	vphn_dir = debugfs_create_dir("vphn", powerpc_debugfs_root);
+	if (!vphn_dir) {
+		pr_warn("%s: can't create vphn debugfs root dir\n", __func__);
+		return -ENOMEM;
+	}
+
+	vphn_lpar_dir = debugfs_create_dir("lpar", vphn_dir);
+	vphn_hyp_dir = debugfs_create_dir("hyp", vphn_dir);
+	if (!vphn_lpar_dir || !vphn_hyp_dir) {
+		pr_warn("%s: can't create vphn dir\n", __func__);
+		goto err_remove_dir;
+	}
+
+	for_each_possible_cpu(cpu) {
+		sprintf(name, "cpu-%ld", cpu);
+		vphn_lpar_cpu_file = debugfs_create_file(name, 0400,
+				vphn_lpar_dir, (void *)cpu, &vphn_lpar_cpu_fops);
+		vphn_hyp_cpu_file = debugfs_create_file(name, 0400,
+				vphn_hyp_dir, (void *)cpu, &vphn_hyp_cpu_fops);
+		if (!vphn_lpar_cpu_file || !vphn_hyp_cpu_file) {
+			pr_warn("%s: can't create vphn cpu file\n", __func__);
+			goto err_remove_dir;
+		}
+	}
+
+	return 0;
+
+err_remove_dir:
+	debugfs_remove_recursive(vphn_dir);
+	return -ENOMEM;
+}
+#else
+static int debug_init_vphn_entries(void) { return 0; }
+#endif /* CONFIG_DEBUG_FS */
+
 /*
  * Change polling interval for associativity changes.
  */
@@ -1619,6 +1721,9 @@ static int topology_update_init(void)
 	if (!proc_create("powerpc/topology_updates", 0644, NULL, &topology_ops))
 		return -ENOMEM;
 
+	if (!debug_init_vphn_entries())
+		return -ENOMEM;
+
 	topology_inited = 1;
 	return 0;
 }
-- 
2.19.2


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

* Re: [PATCH v1 2/2] powerpc/pseries: Add debugfs interface to retrieve VPHN info
       [not found]   ` <e308130fe45a8930743cec9aba83d4885ac8d30d.1544459267.git.naveen.n.rao__35218. 1831411601$1544472513$gmane$org@linux.ibm.com>
@ 2018-12-13 10:52     ` Naveen N. Rao
  2018-12-14  0:33       ` Michael Ellerman
  0 siblings, 1 reply; 5+ messages in thread
From: Naveen N. Rao @ 2018-12-13 10:52 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

Hi Michael,

Naveen N. Rao wrote:
> Add debugfs interface to retrieve associativity information for lpar
> vcpus (debugfs/vphn/lpar) and the hypervisor cpus (debugfs/vphn/hyp).
> This information is useful to derive various metrics, including the vcpu
> dispatch statistics in a SPLPAR environment.

Any thoughts on this approach vs. adding a tracepoint?


Thanks,
Naveen

> 
> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
> ---
>  arch/powerpc/mm/numa.c | 105 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 105 insertions(+)
> 
> diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
> index 6677a578f18d..f0b0e87016e6 100644
> --- a/arch/powerpc/mm/numa.c
> +++ b/arch/powerpc/mm/numa.c
> @@ -40,6 +40,7 @@
>  #include <asm/setup.h>
>  #include <asm/vdso.h>
>  #include <asm/drmem.h>
> +#include <asm/debugfs.h>
>  
>  static int numa_enabled = 1;
>  
> @@ -1089,6 +1090,107 @@ static long hcall_vphn(unsigned long cpu, u64 flags, __be32 *associativity)
>  	return rc;
>  }
>  
> +#ifdef CONFIG_DEBUG_FS
> +static ssize_t vphn_lpar_cpu_file_read(struct file *filp, char __user *buf,
> +		size_t len, loff_t *pos)
> +{
> +	int cpu = (long)filp->private_data;
> +	__be32 associativity[VPHN_ASSOC_BUFSIZE] = {0};
> +	int hwcpu = get_hard_smp_processor_id(cpu);
> +	long int rc;
> +
> +	if (len != sizeof(associativity))
> +		return -EINVAL;
> +
> +	rc = hcall_vphn(hwcpu, 1, associativity);
> +	if (rc)
> +		return -EFAULT;
> +
> +	rc = copy_to_user(buf, &associativity, sizeof(associativity));
> +	if (rc)
> +		return -EFAULT;
> +
> +	return sizeof(associativity);
> +}
> +
> +static ssize_t vphn_hyp_cpu_file_read(struct file *filp, char __user *buf,
> +		size_t len, loff_t *pos)
> +{
> +	int cpu = (long)filp->private_data;
> +	__be32 associativity[VPHN_ASSOC_BUFSIZE] = {0};
> +	long int rc;
> +
> +	if (len != sizeof(associativity))
> +		return -EINVAL;
> +
> +	rc = hcall_vphn(cpu, 2, associativity);
> +	if (rc)
> +		return -EFAULT;
> +
> +	rc = copy_to_user(buf, &associativity, sizeof(associativity));
> +	if (rc)
> +		return -EFAULT;
> +
> +	return sizeof(associativity);
> +}
> +
> +static const struct file_operations vphn_lpar_cpu_fops = {
> +	.open		= simple_open,
> +	.read		= vphn_lpar_cpu_file_read,
> +	.llseek		= no_llseek,
> +};
> +
> +static const struct file_operations vphn_hyp_cpu_fops = {
> +	.open		= simple_open,
> +	.read		= vphn_hyp_cpu_file_read,
> +	.llseek		= no_llseek,
> +};
> +
> +static int debug_init_vphn_entries(void)
> +{
> +	struct dentry *vphn_dir, *vphn_lpar_dir, *vphn_hyp_dir;
> +	struct dentry *vphn_lpar_cpu_file, *vphn_hyp_cpu_file;
> +	long cpu;
> +	char name[10];
> +
> +	if (!firmware_has_feature(FW_FEATURE_SPLPAR))
> +		return 0;
> +
> +	vphn_dir = debugfs_create_dir("vphn", powerpc_debugfs_root);
> +	if (!vphn_dir) {
> +		pr_warn("%s: can't create vphn debugfs root dir\n", __func__);
> +		return -ENOMEM;
> +	}
> +
> +	vphn_lpar_dir = debugfs_create_dir("lpar", vphn_dir);
> +	vphn_hyp_dir = debugfs_create_dir("hyp", vphn_dir);
> +	if (!vphn_lpar_dir || !vphn_hyp_dir) {
> +		pr_warn("%s: can't create vphn dir\n", __func__);
> +		goto err_remove_dir;
> +	}
> +
> +	for_each_possible_cpu(cpu) {
> +		sprintf(name, "cpu-%ld", cpu);
> +		vphn_lpar_cpu_file = debugfs_create_file(name, 0400,
> +				vphn_lpar_dir, (void *)cpu, &vphn_lpar_cpu_fops);
> +		vphn_hyp_cpu_file = debugfs_create_file(name, 0400,
> +				vphn_hyp_dir, (void *)cpu, &vphn_hyp_cpu_fops);
> +		if (!vphn_lpar_cpu_file || !vphn_hyp_cpu_file) {
> +			pr_warn("%s: can't create vphn cpu file\n", __func__);
> +			goto err_remove_dir;
> +		}
> +	}
> +
> +	return 0;
> +
> +err_remove_dir:
> +	debugfs_remove_recursive(vphn_dir);
> +	return -ENOMEM;
> +}
> +#else
> +static int debug_init_vphn_entries(void) { return 0; }
> +#endif /* CONFIG_DEBUG_FS */
> +
>  /*
>   * Change polling interval for associativity changes.
>   */
> @@ -1619,6 +1721,9 @@ static int topology_update_init(void)
>  	if (!proc_create("powerpc/topology_updates", 0644, NULL, &topology_ops))
>  		return -ENOMEM;
>  
> +	if (!debug_init_vphn_entries())
> +		return -ENOMEM;
> +
>  	topology_inited = 1;
>  	return 0;
>  }
> -- 
> 2.19.2
> 
> 
> 


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

* Re: [PATCH v1 2/2] powerpc/pseries: Add debugfs interface to retrieve VPHN info
  2018-12-13 10:52     ` Naveen N. Rao
@ 2018-12-14  0:33       ` Michael Ellerman
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2018-12-14  0:33 UTC (permalink / raw)
  To: Naveen N. Rao; +Cc: linuxppc-dev

Hi Naveen,

"Naveen N. Rao" <naveen.n.rao@linux.ibm.com> writes:
> Hi Michael,
>
> Naveen N. Rao wrote:
>> Add debugfs interface to retrieve associativity information for lpar
>> vcpus (debugfs/vphn/lpar) and the hypervisor cpus (debugfs/vphn/hyp).
>> This information is useful to derive various metrics, including the vcpu
>> dispatch statistics in a SPLPAR environment.
>
> Any thoughts on this approach vs. adding a tracepoint?

Sorry I've been unresponsive on this stuff, I don't know this area that
well.

I guess I'm not opposed to adding some stuff to debugfs, but only if
it's for debugging.

We don't want customers running tools or scripts that rely on this stuff
in debugfs.

If we need to expose more information to be used by production tools
then I think we need to look at sysfs or something like taskstats as a
proper API.

cheers

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

end of thread, other threads:[~2018-12-14  0:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-10 18:14 [PATCH v1 0/2] Interface to expose VPHN information Naveen N. Rao
2018-12-10 18:14 ` [PATCH v1 1/2] powerpc/pseries: Generalize hcall_vphn() Naveen N. Rao
2018-12-10 18:14 ` [PATCH v1 2/2] powerpc/pseries: Add debugfs interface to retrieve VPHN info Naveen N. Rao
     [not found] ` <e308130fe45a8930743cec9aba83d4885ac8d30d.1544459267.git.naveen.n.rao__35218.1831411601$1544472513$gmane$org@linux.ibm.com>
     [not found]   ` <e308130fe45a8930743cec9aba83d4885ac8d30d.1544459267.git.naveen.n.rao__35218. 1831411601$1544472513$gmane$org@linux.ibm.com>
2018-12-13 10:52     ` Naveen N. Rao
2018-12-14  0:33       ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).