[v9,09/13] x86/resctrl: Add sysfs interface to read mbm_local_bytes_config

Message ID 166990902305.17806.9650262646704189221.stgit@bmoger-ubuntu
State New
Headers
Series Support for AMD QoS new features |

Commit Message

Moger, Babu Dec. 1, 2022, 3:37 p.m. UTC
  The current event configuration can be viewed by the user by reading
the configuration file /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config.
The event configuration settings are domain specific and will affect
all the CPUs in the domain.

Following are the types of events supported:
====  ===========================================================
Bits   Description
====  ===========================================================
6      Dirty Victims from the QOS domain to all types of memory
5      Reads to slow memory in the non-local NUMA domain
4      Reads to slow memory in the local NUMA domain
3      Non-temporal writes to non-local NUMA domain
2      Non-temporal writes to local NUMA domain
1      Reads to memory in the non-local NUMA domain
0      Reads to memory in the local NUMA domain
====  ===========================================================

By default, the mbm_local_bytes_config is set to 0x15 to count all the
local event types.

For example:
    $cat /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config
    0=0x15;1=0x15;2=0x15;3=0x15

    In this case, the event mbm_local_bytes is currently configured with
    0x15 on domains 0 to 3.

Signed-off-by: Babu Moger <babu.moger@amd.com>
---
 arch/x86/kernel/cpu/resctrl/monitor.c  |    4 +++-
 arch/x86/kernel/cpu/resctrl/rdtgroup.c |   16 ++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
  

Comments

Reinette Chatre Dec. 15, 2022, 5:43 p.m. UTC | #1
Hi Babu,

Same as other commits the subject can be shortened:
x86/resctrl: Add interface to read mbm_local_bytes_config

On 12/1/2022 7:37 AM, Babu Moger wrote:
> The current event configuration can be viewed by the user by reading
> the configuration file /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config.
> The event configuration settings are domain specific and will affect
> all the CPUs in the domain.
> 
> Following are the types of events supported:
> ====  ===========================================================
> Bits   Description
> ====  ===========================================================
> 6      Dirty Victims from the QOS domain to all types of memory
> 5      Reads to slow memory in the non-local NUMA domain
> 4      Reads to slow memory in the local NUMA domain
> 3      Non-temporal writes to non-local NUMA domain
> 2      Non-temporal writes to local NUMA domain
> 1      Reads to memory in the non-local NUMA domain
> 0      Reads to memory in the local NUMA domain
> ====  ===========================================================
> 
> By default, the mbm_local_bytes_config is set to 0x15 to count all the
> local event types.
> 
> For example:
>     $cat /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config
>     0=0x15;1=0x15;2=0x15;3=0x15
> 
>     In this case, the event mbm_local_bytes is currently configured with
>     0x15 on domains 0 to 3.

"currently" can be removed

> 
> Signed-off-by: Babu Moger <babu.moger@amd.com>
> ---
>  arch/x86/kernel/cpu/resctrl/monitor.c  |    4 +++-
>  arch/x86/kernel/cpu/resctrl/rdtgroup.c |   16 ++++++++++++++++
>  2 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
> index 2afddebc8636..7c8a3a745041 100644
> --- a/arch/x86/kernel/cpu/resctrl/monitor.c
> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c
> @@ -788,8 +788,10 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
>  			mbm_total_event.configurable = true;
>  			mbm_config_rftype_init("mbm_total_bytes_config");
>  		}
> -		if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL))
> +		if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) {
>  			mbm_local_event.configurable = true;
> +			mbm_config_rftype_init("mbm_local_bytes_config");
> +		}
>  	}
>  
>  	l3_mon_evt_init(r);
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index e93b1c206116..580f3cce19e2 100644
> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> @@ -1507,6 +1507,16 @@ static int mbm_total_bytes_config_show(struct kernfs_open_file *of,
>  	return 0;
>  }
>  
> +static int mbm_local_bytes_config_show(struct kernfs_open_file *of,
> +				       struct seq_file *seq, void *v)
> +{
> +	struct rdt_resource *r = of->kn->parent->priv;
> +
> +	mbm_config_show(seq, r, QOS_L3_MBM_LOCAL_EVENT_ID);
> +
> +	return 0;
> +}
> +
>  /* rdtgroup information files for one cache resource. */
>  static struct rftype res_common_files[] = {
>  	{
> @@ -1611,6 +1621,12 @@ static struct rftype res_common_files[] = {
>  		.kf_ops		= &rdtgroup_kf_single_ops,
>  		.seq_show	= mbm_total_bytes_config_show,
>  	},
> +	{
> +		.name		= "mbm_local_bytes_config",
> +		.mode		= 0444,
> +		.kf_ops		= &rdtgroup_kf_single_ops,
> +		.seq_show	= mbm_local_bytes_config_show,
> +	},
>  	{
>  		.name		= "cpus",
>  		.mode		= 0644,
> 
> 

With the subject and changelog changes addressed:

Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>

Reinette
  
Moger, Babu Dec. 19, 2022, 6:27 p.m. UTC | #2
[AMD Official Use Only - General]

Hi Reinette,

> -----Original Message-----
> From: Reinette Chatre <reinette.chatre@intel.com>
> Sent: Thursday, December 15, 2022 11:43 AM
> To: Moger, Babu <Babu.Moger@amd.com>; corbet@lwn.net;
> tglx@linutronix.de; mingo@redhat.com; bp@alien8.de
> Cc: fenghua.yu@intel.com; dave.hansen@linux.intel.com; x86@kernel.org;
> hpa@zytor.com; paulmck@kernel.org; akpm@linux-foundation.org;
> quic_neeraju@quicinc.com; rdunlap@infradead.org;
> damien.lemoal@opensource.wdc.com; songmuchun@bytedance.com;
> peterz@infradead.org; jpoimboe@kernel.org; pbonzini@redhat.com;
> chang.seok.bae@intel.com; pawan.kumar.gupta@linux.intel.com;
> jmattson@google.com; daniel.sneddon@linux.intel.com; Das1, Sandipan
> <Sandipan.Das@amd.com>; tony.luck@intel.com; james.morse@arm.com;
> linux-doc@vger.kernel.org; linux-kernel@vger.kernel.org;
> bagasdotme@gmail.com; eranian@google.com; christophe.leroy@csgroup.eu;
> jarkko@kernel.org; adrian.hunter@intel.com; quic_jiles@quicinc.com;
> peternewman@google.com
> Subject: Re: [PATCH v9 09/13] x86/resctrl: Add sysfs interface to read
> mbm_local_bytes_config
> 
> Hi Babu,
> 
> Same as other commits the subject can be shortened:
> x86/resctrl: Add interface to read mbm_local_bytes_config

Sure.
> 
> On 12/1/2022 7:37 AM, Babu Moger wrote:
> > The current event configuration can be viewed by the user by reading
> > the configuration file /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config.
> > The event configuration settings are domain specific and will affect
> > all the CPUs in the domain.
> >
> > Following are the types of events supported:
> > ====
> ===========================================================
> > Bits   Description
> > ====
> ===========================================================
> > 6      Dirty Victims from the QOS domain to all types of memory
> > 5      Reads to slow memory in the non-local NUMA domain
> > 4      Reads to slow memory in the local NUMA domain
> > 3      Non-temporal writes to non-local NUMA domain
> > 2      Non-temporal writes to local NUMA domain
> > 1      Reads to memory in the non-local NUMA domain
> > 0      Reads to memory in the local NUMA domain
> > ====
> ===========================================================
> >
> > By default, the mbm_local_bytes_config is set to 0x15 to count all the
> > local event types.
> >
> > For example:
> >     $cat /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config
> >     0=0x15;1=0x15;2=0x15;3=0x15
> >
> >     In this case, the event mbm_local_bytes is currently configured with
> >     0x15 on domains 0 to 3.
> 
> "currently" can be removed

Sure.
> 
> >
> > Signed-off-by: Babu Moger <babu.moger@amd.com>
> > ---
> >  arch/x86/kernel/cpu/resctrl/monitor.c  |    4 +++-
> >  arch/x86/kernel/cpu/resctrl/rdtgroup.c |   16 ++++++++++++++++
> >  2 files changed, 19 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c
> > b/arch/x86/kernel/cpu/resctrl/monitor.c
> > index 2afddebc8636..7c8a3a745041 100644
> > --- a/arch/x86/kernel/cpu/resctrl/monitor.c
> > +++ b/arch/x86/kernel/cpu/resctrl/monitor.c
> > @@ -788,8 +788,10 @@ int __init rdt_get_mon_l3_config(struct
> rdt_resource *r)
> >  			mbm_total_event.configurable = true;
> >  			mbm_config_rftype_init("mbm_total_bytes_config");
> >  		}
> > -		if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL))
> > +		if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) {
> >  			mbm_local_event.configurable = true;
> > +			mbm_config_rftype_init("mbm_local_bytes_config");
> > +		}
> >  	}
> >
> >  	l3_mon_evt_init(r);
> > diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> > b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> > index e93b1c206116..580f3cce19e2 100644
> > --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> > +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> > @@ -1507,6 +1507,16 @@ static int mbm_total_bytes_config_show(struct
> kernfs_open_file *of,
> >  	return 0;
> >  }
> >
> > +static int mbm_local_bytes_config_show(struct kernfs_open_file *of,
> > +				       struct seq_file *seq, void *v) {
> > +	struct rdt_resource *r = of->kn->parent->priv;
> > +
> > +	mbm_config_show(seq, r, QOS_L3_MBM_LOCAL_EVENT_ID);
> > +
> > +	return 0;
> > +}
> > +
> >  /* rdtgroup information files for one cache resource. */  static
> > struct rftype res_common_files[] = {
> >  	{
> > @@ -1611,6 +1621,12 @@ static struct rftype res_common_files[] = {
> >  		.kf_ops		= &rdtgroup_kf_single_ops,
> >  		.seq_show	= mbm_total_bytes_config_show,
> >  	},
> > +	{
> > +		.name		= "mbm_local_bytes_config",
> > +		.mode		= 0444,
> > +		.kf_ops		= &rdtgroup_kf_single_ops,
> > +		.seq_show	= mbm_local_bytes_config_show,
> > +	},
> >  	{
> >  		.name		= "cpus",
> >  		.mode		= 0644,
> >
> >
> 
> With the subject and changelog changes addressed:
> 
> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>

Thanks
Babu
> 
> Reinette
  

Patch

diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index 2afddebc8636..7c8a3a745041 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -788,8 +788,10 @@  int __init rdt_get_mon_l3_config(struct rdt_resource *r)
 			mbm_total_event.configurable = true;
 			mbm_config_rftype_init("mbm_total_bytes_config");
 		}
-		if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL))
+		if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) {
 			mbm_local_event.configurable = true;
+			mbm_config_rftype_init("mbm_local_bytes_config");
+		}
 	}
 
 	l3_mon_evt_init(r);
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index e93b1c206116..580f3cce19e2 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -1507,6 +1507,16 @@  static int mbm_total_bytes_config_show(struct kernfs_open_file *of,
 	return 0;
 }
 
+static int mbm_local_bytes_config_show(struct kernfs_open_file *of,
+				       struct seq_file *seq, void *v)
+{
+	struct rdt_resource *r = of->kn->parent->priv;
+
+	mbm_config_show(seq, r, QOS_L3_MBM_LOCAL_EVENT_ID);
+
+	return 0;
+}
+
 /* rdtgroup information files for one cache resource. */
 static struct rftype res_common_files[] = {
 	{
@@ -1611,6 +1621,12 @@  static struct rftype res_common_files[] = {
 		.kf_ops		= &rdtgroup_kf_single_ops,
 		.seq_show	= mbm_total_bytes_config_show,
 	},
+	{
+		.name		= "mbm_local_bytes_config",
+		.mode		= 0444,
+		.kf_ops		= &rdtgroup_kf_single_ops,
+		.seq_show	= mbm_local_bytes_config_show,
+	},
 	{
 		.name		= "cpus",
 		.mode		= 0644,