[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <16263da0-603a-44a5-b6be-58c66b8dd863@amd.com>
Date: Mon, 19 Aug 2024 13:18:21 -0500
From: "Moger, Babu" <babu.moger@....com>
To: Reinette Chatre <reinette.chatre@...el.com>, corbet@....net,
fenghua.yu@...el.com, tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com
Cc: x86@...nel.org, hpa@...or.com, paulmck@...nel.org, rdunlap@...radead.org,
tj@...nel.org, peterz@...radead.org, yanjiewtw@...il.com,
kim.phillips@....com, lukas.bulwahn@...il.com, seanjc@...gle.com,
jmattson@...gle.com, leitao@...ian.org, jpoimboe@...nel.org,
rick.p.edgecombe@...el.com, kirill.shutemov@...ux.intel.com,
jithu.joseph@...el.com, kai.huang@...el.com, kan.liang@...ux.intel.com,
daniel.sneddon@...ux.intel.com, pbonzini@...hat.com, sandipan.das@....com,
ilpo.jarvinen@...ux.intel.com, peternewman@...gle.com,
maciej.wieczor-retman@...el.com, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, eranian@...gle.com, james.morse@....com
Subject: Re: [PATCH v6 20/22] x86/resctrl: Enable AMD ABMC feature by default
when supported
Hi Reinette,
On 8/16/24 17:33, Reinette Chatre wrote:
> Hi Babu,
>
> On 8/6/24 3:00 PM, Babu Moger wrote:
>> Enable ABMC by default when supported during the boot up.
>>
>> Users will not see any difference in the behavior when resctrl is
>> mounted. With automatic assignment everything will work as running
>> in the legacy monitor mode.
>>
>> Signed-off-by: Babu Moger <babu.moger@....com>
>> ---
>> v6 : Keeping the default enablement in arch init code for now.
>> This may need some discussion.
>> Renamed resctrl_arch_configure_abmc to
>> resctrl_arch_mbm_cntr_assign_configure.
>>
>> v5: New patch to enable ABMC by default.
>> ---
>> arch/x86/kernel/cpu/resctrl/core.c | 2 ++
>> arch/x86/kernel/cpu/resctrl/internal.h | 1 +
>> arch/x86/kernel/cpu/resctrl/rdtgroup.c | 17 +++++++++++++++++
>> 3 files changed, 20 insertions(+)
>>
>> diff --git a/arch/x86/kernel/cpu/resctrl/core.c
>> b/arch/x86/kernel/cpu/resctrl/core.c
>> index 6fb0cfdb5529..a7980f84c487 100644
>> --- a/arch/x86/kernel/cpu/resctrl/core.c
>> +++ b/arch/x86/kernel/cpu/resctrl/core.c
>> @@ -599,6 +599,7 @@ static void domain_add_cpu_mon(int cpu, struct
>> rdt_resource *r)
>> d = container_of(hdr, struct rdt_mon_domain, hdr);
>> cpumask_set_cpu(cpu, &d->hdr.cpu_mask);
>> + resctrl_arch_mbm_cntr_assign_configure();
>> return;
>> }
>> @@ -620,6 +621,7 @@ static void domain_add_cpu_mon(int cpu, struct
>> rdt_resource *r)
>> arch_mon_domain_online(r, d);
>> resctrl_mbm_evt_config_init(hw_dom);
>> + resctrl_arch_mbm_cntr_assign_configure();
>> if (arch_domain_mbm_alloc(r->mon.num_rmid, hw_dom)) {
>> mon_domain_free(hw_dom);
>> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h
>> b/arch/x86/kernel/cpu/resctrl/internal.h
>> index cc832955b787..ba3012f8f940 100644
>> --- a/arch/x86/kernel/cpu/resctrl/internal.h
>> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
>> @@ -685,6 +685,7 @@ int mbm_cntr_alloc(struct rdt_resource *r);
>> void mbm_cntr_free(u32 cntr_id);
>> void resctrl_mbm_evt_config_init(struct rdt_hw_mon_domain *hw_dom);
>> unsigned int mon_event_config_index_get(u32 evtid);
>> +void resctrl_arch_mbm_cntr_assign_configure(void);
>> int resctrl_arch_assign_cntr(struct rdt_mon_domain *d, enum
>> resctrl_event_id evtid,
>> u32 rmid, u32 cntr_id, u32 closid, bool assign);
>> int rdtgroup_assign_cntr(struct rdtgroup *rdtgrp, enum
>> resctrl_event_id evtid);
>> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> index 66febff2a3d3..d15fd1bde5f4 100644
>> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> @@ -2756,6 +2756,23 @@ void resctrl_arch_mbm_cntr_assign_disable(void)
>> }
>> }
>> +void resctrl_arch_mbm_cntr_assign_configure(void)
>> +{
>> + struct rdt_resource *r =
>> &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
>> + struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
>> + bool enable = true;
>> +
>> + mutex_lock(&rdtgroup_mutex);
>> +
>> + if (r->mon.mbm_cntr_assignable) {
>> + if (!hw_res->mbm_cntr_assign_enabled)
>> + hw_res->mbm_cntr_assign_enabled = true;
>> + resctrl_abmc_set_one_amd(&enable);
>
> Earlier changelogs mentioned that counters are reset when ABMC is enabled.
> How does that behave here when one CPU comes online? Consider the scenario
> where
> a system is booted without all CPUs online. ABMC is initially enabled on
> all online
> CPUs with this flow ... user space could start using resctrl fs and create
> monitor groups that start accumulating architectural state. If the remaining
> CPUs come online at this point and this snippet enables ABMC, would it reset
> all counters? Should the architectural state be cleared?
When new cpu comes online, it should inherit the abmc state which is set
already. it should not force it either way. In that case, it is not
required to reset the architectural state.
Responded to your earlier comment.
https://lore.kernel.org/lkml/0256b457-175d-4923-aa49-00e8e52b865b@amd.com/
>
> Also, it still does not look right that the architecture decides the policy.
> Could this enabling be moved to resctrl_online_cpu() for resctrl fs to
> request architecture to enable assignable counters if it is supported?
Sure. Will move the resctrl_arch_mbm_cntr_assign_configure() here with
changes just to update the abmc state which is set during the init.
>
>> + }
>> +
>> + mutex_unlock(&rdtgroup_mutex);
>> +}
>> +
>> /*
>> * We don't allow rdtgroup directories to be created anywhere
>> * except the root directory. Thus when looking for the rdtgroup
>
> Reinette
>
--
Thanks
Babu Moger
Powered by blists - more mailing lists