linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] powerpc/kernel/sysfs: Export ldbar spr to sysfs
@ 2017-11-09 12:13 Anju T Sudhakar
  2017-11-09 12:47 ` Anju T Sudhakar
  0 siblings, 1 reply; 5+ messages in thread
From: Anju T Sudhakar @ 2017-11-09 12:13 UTC (permalink / raw)
  To: mpe; +Cc: linuxppc-dev, linux-kernel, maddy, anju

Add ldbar spr to sysfs. The spr holds thread level In-Memory Collection (IMC)                       
counter configuration data. Exposing this will help to understand the current
configuration of thread-level counters in the system.
Primarily, Bit 0 of ldbar says whether the counters are enabled or not.
And bit 1 indicates the mode (if 0-Accumulation Mode/if 1-Trace Mode). 

Signed-off-by: Anju T Sudhakar <anju@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/sysfs.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 4437c70..f8caee0 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -485,6 +485,7 @@ SYSFS_PMCSETUP(mmcra, SPRN_MMCRA);
 SYSFS_SPRSETUP(purr, SPRN_PURR);
 SYSFS_SPRSETUP(spurr, SPRN_SPURR);
 SYSFS_SPRSETUP(pir, SPRN_PIR);
+SYSFS_SPRSETUP(ldbar, SPRN_LDBAR);
 
 /*
   Lets only enable read for phyp resources and
@@ -492,6 +493,7 @@ SYSFS_SPRSETUP(pir, SPRN_PIR);
   Lets be conservative and default to pseries.
 */
 static DEVICE_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
+static DEVICE_ATTR(ldbar, 0400, show_ldbar, store_ldbar);
 static DEVICE_ATTR(spurr, 0400, show_spurr, NULL);
 static DEVICE_ATTR(purr, 0400, show_purr, store_purr);
 static DEVICE_ATTR(pir, 0400, show_pir, NULL);
@@ -757,6 +759,9 @@ static int register_cpu_online(unsigned int cpu)
 			device_create_file(s, &pmc_attrs[i]);
 
 #ifdef CONFIG_PPC64
+	if (cpu_has_feature(CPU_FTR_ARCH_300))
+		device_create_file(s, &dev_attr_ldbar);
+
 	if (cpu_has_feature(CPU_FTR_MMCRA))
 		device_create_file(s, &dev_attr_mmcra);
 
@@ -842,6 +847,9 @@ static int unregister_cpu_online(unsigned int cpu)
 			device_remove_file(s, &pmc_attrs[i]);
 
 #ifdef CONFIG_PPC64
+	if (cpu_has_feature(CPU_FTR_ARCH_300))
+		device_remove_file(s, &dev_attr_ldbar);
+
 	if (cpu_has_feature(CPU_FTR_MMCRA))
 		device_remove_file(s, &dev_attr_mmcra);
 
-- 
2.7.4

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

* Re: [PATCH v3] powerpc/kernel/sysfs: Export ldbar spr to sysfs
  2017-11-09 12:13 [PATCH v3] powerpc/kernel/sysfs: Export ldbar spr to sysfs Anju T Sudhakar
@ 2017-11-09 12:47 ` Anju T Sudhakar
  0 siblings, 0 replies; 5+ messages in thread
From: Anju T Sudhakar @ 2017-11-09 12:47 UTC (permalink / raw)
  To: mpe; +Cc: linuxppc-dev, linux-kernel, maddy

Hi,

Kindly ignore this patch, I send a wrong version. Will send out the 
right one.


Thanks,

Anju


On Thursday 09 November 2017 05:43 PM, Anju T Sudhakar wrote:
> Add ldbar spr to sysfs. The spr holds thread level In-Memory Collection (IMC)
> counter configuration data. Exposing this will help to understand the current
> configuration of thread-level counters in the system.
> Primarily, Bit 0 of ldbar says whether the counters are enabled or not.
> And bit 1 indicates the mode (if 0-Accumulation Mode/if 1-Trace Mode).
>
> Signed-off-by: Anju T Sudhakar <anju@linux.vnet.ibm.com>
> ---
>   arch/powerpc/kernel/sysfs.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
> index 4437c70..f8caee0 100644
> --- a/arch/powerpc/kernel/sysfs.c
> +++ b/arch/powerpc/kernel/sysfs.c
> @@ -485,6 +485,7 @@ SYSFS_PMCSETUP(mmcra, SPRN_MMCRA);
>   SYSFS_SPRSETUP(purr, SPRN_PURR);
>   SYSFS_SPRSETUP(spurr, SPRN_SPURR);
>   SYSFS_SPRSETUP(pir, SPRN_PIR);
> +SYSFS_SPRSETUP(ldbar, SPRN_LDBAR);
>
>   /*
>     Lets only enable read for phyp resources and
> @@ -492,6 +493,7 @@ SYSFS_SPRSETUP(pir, SPRN_PIR);
>     Lets be conservative and default to pseries.
>   */
>   static DEVICE_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
> +static DEVICE_ATTR(ldbar, 0400, show_ldbar, store_ldbar);
>   static DEVICE_ATTR(spurr, 0400, show_spurr, NULL);
>   static DEVICE_ATTR(purr, 0400, show_purr, store_purr);
>   static DEVICE_ATTR(pir, 0400, show_pir, NULL);
> @@ -757,6 +759,9 @@ static int register_cpu_online(unsigned int cpu)
>   			device_create_file(s, &pmc_attrs[i]);
>
>   #ifdef CONFIG_PPC64
> +	if (cpu_has_feature(CPU_FTR_ARCH_300))
> +		device_create_file(s, &dev_attr_ldbar);
> +
>   	if (cpu_has_feature(CPU_FTR_MMCRA))
>   		device_create_file(s, &dev_attr_mmcra);
>
> @@ -842,6 +847,9 @@ static int unregister_cpu_online(unsigned int cpu)
>   			device_remove_file(s, &pmc_attrs[i]);
>
>   #ifdef CONFIG_PPC64
> +	if (cpu_has_feature(CPU_FTR_ARCH_300))
> +		device_remove_file(s, &dev_attr_ldbar);
> +
>   	if (cpu_has_feature(CPU_FTR_MMCRA))
>   		device_remove_file(s, &dev_attr_mmcra);
>

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

* Re: [PATCH v3] powerpc/kernel/sysfs: Export ldbar spr to sysfs
  2018-03-06 11:05 ` Michael Ellerman
@ 2018-03-13  5:43   ` Anju T Sudhakar
  0 siblings, 0 replies; 5+ messages in thread
From: Anju T Sudhakar @ 2018-03-13  5:43 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, linux-kernel, maddy

Hi,


On Tuesday 06 March 2018 04:35 PM, Michael Ellerman wrote:
> Anju T Sudhakar <anju@linux.vnet.ibm.com> writes:
>
>> diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
>> index 4437c70..caefb64 100644
>> --- a/arch/powerpc/kernel/sysfs.c
>> +++ b/arch/powerpc/kernel/sysfs.c
>> @@ -757,6 +759,9 @@ static int register_cpu_online(unsigned int cpu)
>>   			device_create_file(s, &pmc_attrs[i]);
>>   
>>   #ifdef CONFIG_PPC64
>> +	if (cpu_has_feature(CPU_FTR_ARCH_300))
>> +		device_create_file(s, &dev_attr_ldbar);
> Is this register readable in supervisor state?

This is a nice catch, thanks. :)
The guest kernel can not access the register, it is only readable in the 
hypervisor state.
I will resend the patch with a condition check so that this spr will not 
get registered for guest kernel.


Regards,
Anju
>
> cheers
>

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

* Re: [PATCH v3] powerpc/kernel/sysfs: Export ldbar spr to sysfs
  2017-11-09 13:00 Anju T Sudhakar
@ 2018-03-06 11:05 ` Michael Ellerman
  2018-03-13  5:43   ` Anju T Sudhakar
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Ellerman @ 2018-03-06 11:05 UTC (permalink / raw)
  To: Anju T Sudhakar; +Cc: linuxppc-dev, linux-kernel, maddy, anju

Anju T Sudhakar <anju@linux.vnet.ibm.com> writes:

> diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
> index 4437c70..caefb64 100644
> --- a/arch/powerpc/kernel/sysfs.c
> +++ b/arch/powerpc/kernel/sysfs.c
> @@ -757,6 +759,9 @@ static int register_cpu_online(unsigned int cpu)
>  			device_create_file(s, &pmc_attrs[i]);
>  
>  #ifdef CONFIG_PPC64
> +	if (cpu_has_feature(CPU_FTR_ARCH_300))
> +		device_create_file(s, &dev_attr_ldbar);

Is this register readable in supervisor state?

cheers

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

* [PATCH v3] powerpc/kernel/sysfs: Export ldbar spr to sysfs
@ 2017-11-09 13:00 Anju T Sudhakar
  2018-03-06 11:05 ` Michael Ellerman
  0 siblings, 1 reply; 5+ messages in thread
From: Anju T Sudhakar @ 2017-11-09 13:00 UTC (permalink / raw)
  To: mpe; +Cc: linuxppc-dev, linux-kernel, maddy, anju

Add ldbar spr to sysfs. The spr holds thread level In-Memory Collection (IMC)                       
counter configuration data. Exposing this will help to understand the current
configuration of thread-level counters in the system.
Primarily, Bit 0 of ldbar says whether the counters are enabled or not.
And bit 1 indicates the mode (if 0-Accumulation Mode/if 1-Trace Mode). 

Signed-off-by: Anju T Sudhakar <anju@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/sysfs.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 4437c70..caefb64 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -485,6 +485,7 @@ SYSFS_PMCSETUP(mmcra, SPRN_MMCRA);
 SYSFS_SPRSETUP(purr, SPRN_PURR);
 SYSFS_SPRSETUP(spurr, SPRN_SPURR);
 SYSFS_SPRSETUP(pir, SPRN_PIR);
+SYSFS_SPRSETUP(ldbar, SPRN_LDBAR);
 
 /*
   Lets only enable read for phyp resources and
@@ -492,6 +493,7 @@ SYSFS_SPRSETUP(pir, SPRN_PIR);
   Lets be conservative and default to pseries.
 */
 static DEVICE_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
+static DEVICE_ATTR(ldbar, 0400, show_ldbar, NULL);
 static DEVICE_ATTR(spurr, 0400, show_spurr, NULL);
 static DEVICE_ATTR(purr, 0400, show_purr, store_purr);
 static DEVICE_ATTR(pir, 0400, show_pir, NULL);
@@ -757,6 +759,9 @@ static int register_cpu_online(unsigned int cpu)
 			device_create_file(s, &pmc_attrs[i]);
 
 #ifdef CONFIG_PPC64
+	if (cpu_has_feature(CPU_FTR_ARCH_300))
+		device_create_file(s, &dev_attr_ldbar);
+
 	if (cpu_has_feature(CPU_FTR_MMCRA))
 		device_create_file(s, &dev_attr_mmcra);
 
@@ -842,6 +847,9 @@ static int unregister_cpu_online(unsigned int cpu)
 			device_remove_file(s, &pmc_attrs[i]);
 
 #ifdef CONFIG_PPC64
+	if (cpu_has_feature(CPU_FTR_ARCH_300))
+		device_remove_file(s, &dev_attr_ldbar);
+
 	if (cpu_has_feature(CPU_FTR_MMCRA))
 		device_remove_file(s, &dev_attr_mmcra);
 
-- 
2.7.4

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

end of thread, other threads:[~2018-03-13  5:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-09 12:13 [PATCH v3] powerpc/kernel/sysfs: Export ldbar spr to sysfs Anju T Sudhakar
2017-11-09 12:47 ` Anju T Sudhakar
2017-11-09 13:00 Anju T Sudhakar
2018-03-06 11:05 ` Michael Ellerman
2018-03-13  5:43   ` Anju T Sudhakar

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).