mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Moger, Babu" <babu.moger@amd.com>
To: Reinette Chatre <reinette.chatre@intel.com>,
	corbet@lwn.net, fenghua.yu@intel.com, tglx@linutronix.de,
	mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com
Cc: x86@kernel.org, hpa@zytor.com, paulmck@kernel.org,
	rdunlap@infradead.org, tj@kernel.org, peterz@infradead.org,
	yanjiewtw@gmail.com, kim.phillips@amd.com,
	lukas.bulwahn@gmail.com, seanjc@google.com, jmattson@google.com,
	leitao@debian.org, jpoimboe@kernel.org,
	rick.p.edgecombe@intel.com, kirill.shutemov@linux.intel.com,
	jithu.joseph@intel.com, kai.huang@intel.com,
	kan.liang@linux.intel.com, daniel.sneddon@linux.intel.com,
	pbonzini@redhat.com, sandipan.das@amd.com,
	ilpo.jarvinen@linux.intel.com, peternewman@google.com,
	maciej.wieczor-retman@intel.com, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, eranian@google.com,
	james.morse@arm.com
Subject: Re: [RFC PATCH v3 07/17] x86/resctrl: Add support to enable/disable ABMC feature
Date: Tue, 7 May 2024 14:12:31 -0500	[thread overview]
Message-ID: <54ec73f9-6c9e-44f4-8ee9-a683bfcee607@amd.com> (raw)
In-Reply-To: <54b1fe8f-13e5-440b-bb36-4100c1d283d0@intel.com>

Hi Reinette,

On 5/3/24 18:30, Reinette Chatre wrote:
> Hi Babu,
> 
> On 3/28/2024 6:06 PM, Babu Moger wrote:
>> Add the functionality to enable/disable ABMC feature.
>>
>> ABMC is enabled by setting enabled bit(0) in MSR L3_QOS_EXT_CFG. When the
>> state of ABMC is changed, it must be changed to the updated value on all
>> logical processors in the QOS Domain.
> 
> This patch does much more than enable what is mentioned above. There is little
> information about what this patch aims to accomplish. Without this it makes
> review difficult.

Sure. Also I need to add details about why resctrl_arch_reset_rmid_all()
is required. Will do.

> 
>>
>> The ABMC feature details are documented in APM listed below [1].
>> [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming
>> Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth
>> Monitoring (ABMC).
>>
>> Signed-off-by: Babu Moger <babu.moger@amd.com>
>> Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537
>> ---
>> v3: No changes.
>>
>> v2: Few text changes in commit message.
>> ---
>>  arch/x86/include/asm/msr-index.h       |  1 +
>>  arch/x86/kernel/cpu/resctrl/internal.h | 12 ++++
>>  arch/x86/kernel/cpu/resctrl/rdtgroup.c | 76 +++++++++++++++++++++++++-
>>  3 files changed, 88 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
>> index 05956bd8bacf..f16ee50b1a23 100644
>> --- a/arch/x86/include/asm/msr-index.h
>> +++ b/arch/x86/include/asm/msr-index.h
>> @@ -1165,6 +1165,7 @@
>>  #define MSR_IA32_MBA_BW_BASE		0xc0000200
>>  #define MSR_IA32_SMBA_BW_BASE		0xc0000280
>>  #define MSR_IA32_EVT_CFG_BASE		0xc0000400
>> +#define MSR_IA32_L3_QOS_EXT_CFG		0xc00003ff
>>  
>>  /* MSR_IA32_VMX_MISC bits */
>>  #define MSR_IA32_VMX_MISC_INTEL_PT                 (1ULL << 14)
>> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
>> index 722388621403..8238ee437369 100644
>> --- a/arch/x86/kernel/cpu/resctrl/internal.h
>> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
>> @@ -96,6 +96,9 @@ cpumask_any_housekeeping(const struct cpumask *mask, int exclude_cpu)
>>  	return cpu;
>>  }
>>  
>> +/* ABMC ENABLE */
> 
> Can this comment be made more useful?

How about?
/* Setting bit 0 in L3_QOS_EXT_CFG enables ABMC features */

Or I can remove it totally.

> 
>> +#define ABMC_ENABLE			BIT(0)
>> +
>>  struct rdt_fs_context {
>>  	struct kernfs_fs_context	kfc;
>>  	bool				enable_cdpl2;
>> @@ -433,6 +436,7 @@ struct rdt_parse_data {
>>   * @mbm_cfg_mask:	Bandwidth sources that can be tracked when Bandwidth
>>   *			Monitoring Event Configuration (BMEC) is supported.
>>   * @cdp_enabled:	CDP state of this resource
>> + * @abmc_enabled:	ABMC feature is enabled
>>   *
>>   * Members of this structure are either private to the architecture
>>   * e.g. mbm_width, or accessed via helpers that provide abstraction. e.g.
>> @@ -448,6 +452,7 @@ struct rdt_hw_resource {
>>  	unsigned int		mbm_width;
>>  	unsigned int		mbm_cfg_mask;
>>  	bool			cdp_enabled;
>> +	bool			abmc_enabled;
>>  };
>>  
>>  static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resource *r)
>> @@ -491,6 +496,13 @@ static inline bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level l)
>>  
>>  int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable);
>>  
>> +static inline bool resctrl_arch_get_abmc_enabled(enum resctrl_res_level l)
>> +{
>> +	return rdt_resources_all[l].abmc_enabled;
>> +}
>> +
>> +int resctrl_arch_set_abmc_enabled(enum resctrl_res_level l, bool enable);
>> +
>>  /*
>>   * To return the common struct rdt_resource, which is contained in struct
>>   * rdt_hw_resource, walk the resctrl member of struct rdt_hw_resource.
>> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> index 05f551bc316e..f49073c86884 100644
>> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> @@ -850,9 +850,15 @@ static int rdtgroup_mbm_assign_show(struct kernfs_open_file *of,
>>  				    struct seq_file *s, void *v)
>>  {
>>  	struct rdt_resource *r = of->kn->parent->priv;
>> +	struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
>>  
>> -	if (r->mbm_assign_capable)
>> +	if (r->mbm_assign_capable && hw_res->abmc_enabled) {
>> +		seq_puts(s, "[abmc]\n");
>> +		seq_puts(s, "legacy_mbm\n");
>> +	} else if (r->mbm_assign_capable) {
>>  		seq_puts(s, "abmc\n");
>> +		seq_puts(s, "[legacy_mbm]\n");
>> +	}
>>  
>>  	return 0;
>>  }
>> @@ -2433,6 +2439,74 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable)
>>  	return 0;
>>  }
>>  
>> +static void resctrl_abmc_msrwrite(void *arg)
>> +{
>> +	bool *enable = arg;
>> +	u64 msrval;
>> +
>> +	rdmsrl(MSR_IA32_L3_QOS_EXT_CFG, msrval);
>> +
>> +	if (*enable)
>> +		msrval |= ABMC_ENABLE;
>> +	else
>> +		msrval &= ~ABMC_ENABLE;
>> +
>> +	wrmsrl(MSR_IA32_L3_QOS_EXT_CFG, msrval);
>> +}
>> +
>> +static int resctrl_abmc_setup(enum resctrl_res_level l, bool enable)
>> +{
>> +	struct rdt_resource *r = &rdt_resources_all[l].r_resctrl;
>> +	struct rdt_domain *d;
>> +
>> +	/* Update QOS_CFG MSR on all the CPUs in cpu_mask */
> 
> "all the CPUs in cpu_mask" -> "all the CPUs associated with the resource"?

Sure.

> 
>> +	list_for_each_entry(d, &r->domains, list) {
>> +		on_each_cpu_mask(&d->cpu_mask, resctrl_abmc_msrwrite, &enable, 1);
>> +		resctrl_arch_reset_rmid_all(r, d);
> 
> Could the changelog please explain why this is needed and what the impact of
> this is?

Sure.

> 
>> +	}
>> +
>> +	return 0;
>> +}
> 
> I think the naming can be changed to make these easier to understand. For example,
> resctrl_abmc_msrwrite() -> resctrl_abmc_set_one()
> resctrl_abmc_setup() -> resctrl_abmc_set_all()

Sure.

> 
>> +
>> +static int resctrl_abmc_enable(enum resctrl_res_level l)
>> +{
>> +	struct rdt_hw_resource *hw_res = &rdt_resources_all[l];
>> +	int ret = 0;
>> +
>> +	if (!hw_res->abmc_enabled) {
>> +		ret = resctrl_abmc_setup(l, true);
>> +		if (!ret)
>> +			hw_res->abmc_enabled = true;
>> +	}
>> +
>> +	return ret;
>> +}
>> +
>> +static void resctrl_abmc_disable(enum resctrl_res_level l)
>> +{
>> +	struct rdt_hw_resource *hw_res = &rdt_resources_all[l];
>> +
>> +	if (hw_res->abmc_enabled) {
>> +		resctrl_abmc_setup(l, false);
>> +		hw_res->abmc_enabled = false;
>> +	}
>> +}
>> +
>> +int resctrl_arch_set_abmc_enabled(enum resctrl_res_level l, bool enable)
>> +{
>> +	struct rdt_hw_resource *hw_res = &rdt_resources_all[l];
>> +
>> +	if (!hw_res->r_resctrl.mbm_assign_capable)
>> +		return -EINVAL;
>> +
>> +	if (enable)
>> +		return resctrl_abmc_enable(l);
>> +
>> +	resctrl_abmc_disable(l);
>> +
>> +	return 0;
>> +}
> 
> Why is resctrl_arch_set_abmc_enabled() necessary? It seem to add an unnecessary
> layer of abstraction.
> 

I feel it is better to keep it that way. It is consistent with definition
of resctrl_arch_set_cdp_enabled. It handles both enable and disable.
Otherwise we have add those checks from the caller.

-- 
Thanks
Babu Moger

  reply	other threads:[~2024-05-07 19:12 UTC|newest]

Thread overview: 108+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-29  1:06 [RFC PATCH v3 00/17] x86/resctrl : Support AMD Assignable Bandwidth Monitoring Counters (ABMC) Babu Moger
2024-03-29  1:06 ` [RFC PATCH v3 01/17] x86/resctrl: Add support for " Babu Moger
2024-05-03 23:25   ` Reinette Chatre
2024-05-06 17:57     ` Moger, Babu
2024-03-29  1:06 ` [RFC PATCH v3 02/17] x86/resctrl: Add ABMC feature in the command line options Babu Moger
2024-03-29  1:06 ` [RFC PATCH v3 03/17] x86/resctrl: Detect Assignable Bandwidth Monitoring feature details Babu Moger
2024-05-03 23:26   ` Reinette Chatre
2024-05-06 19:09     ` Moger, Babu
2024-05-07 20:27       ` Reinette Chatre
2024-05-09 22:34         ` Moger, Babu
2024-05-10  3:18           ` Reinette Chatre
2024-05-10 17:01             ` Moger, Babu
2024-05-10 18:34               ` Reinette Chatre
2024-05-11  1:40                 ` Moger, Babu
2024-03-29  1:06 ` [RFC PATCH v3 04/17] x86/resctrl: Introduce resctrl_file_fflags_init Babu Moger
2024-05-03 23:26   ` Reinette Chatre
2024-05-06 20:23     ` Moger, Babu
2024-05-07 20:27       ` Reinette Chatre
2024-05-10  0:23         ` Moger, Babu
2024-03-29  1:06 ` [RFC PATCH v3 05/17] x86/resctrl: Introduce the interface to display the assignment state Babu Moger
2024-05-03 23:28   ` Reinette Chatre
2024-05-07 16:28     ` Moger, Babu
2024-05-07 20:32       ` Reinette Chatre
2024-03-29  1:06 ` [RFC PATCH v3 06/17] x86/resctrl: Introduce interface to display number of ABMC counters Babu Moger
2024-03-29  1:06 ` [RFC PATCH v3 07/17] x86/resctrl: Add support to enable/disable ABMC feature Babu Moger
2024-04-04  0:30   ` Peter Newman
2024-04-04 15:16     ` Moger, Babu
2024-04-04 17:36       ` Peter Newman
2024-04-04 18:35         ` Moger, Babu
2024-04-04 18:43     ` Reinette Chatre
2024-04-04 19:01       ` Peter Newman
2024-05-16 20:03     ` Moger, Babu
2024-05-03 23:30   ` Reinette Chatre
2024-05-07 19:12     ` Moger, Babu [this message]
2024-05-07 20:32       ` Reinette Chatre
2024-05-09 21:45         ` Moger, Babu
2024-03-29  1:06 ` [RFC PATCH v3 08/17] x86/resctrl: Initialize assignable counters bitmap Babu Moger
2024-05-03 23:31   ` Reinette Chatre
2024-05-07 20:03     ` Moger, Babu
2024-03-29  1:06 ` [RFC PATCH v3 09/17] x86/resctrl: Introduce assign state for the mon group Babu Moger
2024-04-16 18:52   ` Peter Newman
2024-04-16 19:52     ` Moger, Babu
2024-03-29  1:06 ` [RFC PATCH v3 10/17] x86/resctrl: Add data structures for ABMC assignment Babu Moger
2024-05-03 23:32   ` Reinette Chatre
2024-05-07 20:40     ` Moger, Babu
2024-05-07 23:06       ` Reinette Chatre
2024-05-10  0:28         ` Moger, Babu
2024-03-29  1:06 ` [RFC PATCH v3 11/17] x86/resctrl: Introduce mbm_total_cfg and mbm_local_cfg Babu Moger
2024-05-03 23:33   ` Reinette Chatre
2024-05-08 15:57     ` Moger, Babu
2024-03-29  1:06 ` [RFC PATCH v3 12/17] x86/resctrl: Add the functionality to assign the RMID Babu Moger
2024-05-03 23:33   ` Reinette Chatre
2024-05-08 17:40     ` Moger, Babu
2024-03-29  1:06 ` [RFC PATCH v3 13/17] x86/resctrl: Add the functionality to unassign " Babu Moger
2024-03-29  1:06 ` [RFC PATCH v3 14/17] x86/resctrl: Enable ABMC by default on resctrl mount Babu Moger
2024-03-29  1:06 ` [RFC PATCH v3 15/17] x86/resctrl: Introduce the interface switch between ABMC and legacy_mbm Babu Moger
2024-03-29  1:06 ` [RFC PATCH v3 16/17] x86/resctrl: Introduce interface to list assignment states of all the groups Babu Moger
2024-03-29  1:06 ` [RFC PATCH v3 17/17] x86/resctrl: Introduce interface to modify assignment states of " Babu Moger
2024-04-17 17:45   ` Peter Newman
2024-04-17 19:39     ` Moger, Babu
2024-04-17 20:56       ` Peter Newman
2024-04-17 22:52         ` Moger, Babu
2024-05-02 23:00           ` Reinette Chatre
2024-05-03 16:14             ` Moger, Babu
2024-05-03 21:16               ` Reinette Chatre
2024-05-06 18:09                 ` Moger, Babu
2024-05-02 16:21   ` Dave Martin
2024-05-02 17:52     ` Reinette Chatre
2024-05-02 18:11       ` Moger, Babu
2024-05-03 14:53       ` Dave Martin
2024-05-03 21:15         ` Reinette Chatre
2024-04-04 19:08 ` [RFC PATCH v3 00/17] x86/resctrl : Support AMD Assignable Bandwidth Monitoring Counters (ABMC) Peter Newman
2024-04-04 20:02   ` Moger, Babu
2024-04-22 16:34     ` Dave Martin
2024-04-22 20:44       ` Moger, Babu
2024-04-23 12:37         ` Dave Martin
2024-04-24  4:15           ` Reinette Chatre
2024-04-24 14:16             ` Dave Martin
2024-04-24 19:10               ` Moger, Babu
2024-04-22 16:33 ` Dave Martin
2024-04-22 18:23   ` Peter Newman
2024-04-23 12:38     ` Dave Martin
2024-04-23 15:43       ` Moger, Babu
2024-04-23 16:17         ` Dave Martin
2024-05-01 17:48 ` Peter Newman
2024-05-02 16:25   ` Moger, Babu
2024-05-02 17:50     ` Peter Newman
2024-05-02 20:14       ` Moger, Babu
2024-05-02 23:21         ` Reinette Chatre
2024-05-03  0:57           ` Peter Newman
2024-05-03 20:44             ` Moger, Babu
2024-05-03 21:00               ` Peter Newman
2024-05-03 21:15                 ` Reinette Chatre
2024-05-17 21:51                   ` Peter Newman
2024-05-20 14:25                     ` Moger, Babu
2024-05-20 16:00                       ` Peter Newman
2024-05-20 18:03                         ` Moger, Babu
2024-05-10  0:57               ` Moger, Babu
2024-05-10  2:47                 ` Reinette Chatre
2024-05-03 21:14             ` Reinette Chatre
2024-05-03 23:24 ` Reinette Chatre
2024-05-06 17:18   ` Moger, Babu
2024-05-07 20:26     ` Reinette Chatre
2024-05-08 20:07       ` Moger, Babu
2024-05-08 20:41         ` Reinette Chatre
2024-05-08 23:29           ` Moger, Babu
2024-05-09 18:07             ` Reinette Chatre
2024-05-09 20:34               ` Moger, Babu

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=54ec73f9-6c9e-44f4-8ee9-a683bfcee607@amd.com \
    --to=babu.moger@amd.com \
    --cc=bp@alien8.de \
    --cc=corbet@lwn.net \
    --cc=daniel.sneddon@linux.intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=eranian@google.com \
    --cc=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=james.morse@arm.com \
    --cc=jithu.joseph@intel.com \
    --cc=jmattson@google.com \
    --cc=jpoimboe@kernel.org \
    --cc=kai.huang@intel.com \
    --cc=kan.liang@linux.intel.com \
    --cc=kim.phillips@amd.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=leitao@debian.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    --cc=maciej.wieczor-retman@intel.com \
    --cc=mingo@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peternewman@google.com \
    --cc=peterz@infradead.org \
    --cc=rdunlap@infradead.org \
    --cc=reinette.chatre@intel.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=sandipan.das@amd.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=x86@kernel.org \
    --cc=yanjiewtw@gmail.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

Powered by JetHome