mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: Babu Moger <babu.moger@amd.com>, <corbet@lwn.net>,
	<tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
	<dave.hansen@linux.intel.com>, <tony.luck@intel.com>,
	<peternewman@google.com>
Cc: <fenghua.yu@intel.com>, <x86@kernel.org>, <hpa@zytor.com>,
	<paulmck@kernel.org>, <akpm@linux-foundation.org>,
	<thuth@redhat.com>, <rostedt@goodmis.org>,
	<xiongwei.song@windriver.com>,
	<pawan.kumar.gupta@linux.intel.com>,
	<daniel.sneddon@linux.intel.com>, <jpoimboe@kernel.org>,
	<perry.yuan@amd.com>, <sandipan.das@amd.com>,
	<kai.huang@intel.com>, <xiaoyao.li@intel.com>,
	<seanjc@google.com>, <xin3.li@intel.com>,
	<andrew.cooper3@citrix.com>, <ebiggers@google.com>,
	<mario.limonciello@amd.com>, <james.morse@arm.com>,
	<tan.shaopeng@fujitsu.com>, <linux-doc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <maciej.wieczor-retman@intel.com>,
	<eranian@google.com>
Subject: Re: [PATCH v10 18/24] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled
Date: Thu, 19 Dec 2024 15:39:20 -0800	[thread overview]
Message-ID: <6bc0816c-d926-45de-ba97-459fb0fca9ff@intel.com> (raw)
In-Reply-To: <35e1b0915fe08bb0ef093e23ca3d520fc6aa32ab.1734034524.git.babu.moger@amd.com>

Hi Babu,

On 12/12/24 12:15 PM, Babu Moger wrote:
> Assign/unassign counters on resctrl group creation/deletion. Two counters
> are required per group, one for MBM total event and one for MBM local
> event.
> 
> There are a limited number of counters available for assignment. If these
> counters are exhausted, the kernel will display the error message: "Out of
> MBM assignable counters". However, it is not necessary to fail the
> creation of a group due to assignment failures. Users have the flexibility
> to modify the assignments at a later time.
> 
> Signed-off-by: Babu Moger <babu.moger@amd.com>
> ---
> ---
>  arch/x86/kernel/cpu/resctrl/rdtgroup.c | 81 +++++++++++++++++++++++++-
>  1 file changed, 79 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index a71a8389b649..5acae525881a 100644
> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> @@ -920,6 +920,25 @@ static int rdtgroup_available_mbm_cntrs_show(struct kernfs_open_file *of,
>  	return ret;
>  }
>  
> +static void mbm_cntr_reset(struct rdt_resource *r)
> +{
> +	struct rdt_mon_domain *dom;
> +
> +	/*
> +	 * Hardware counters will reset after switching the monitor mode.
> +	 * Reset the architectural state so that reading of hardware
> +	 * counter is not considered as an overflow in the next update.
> +	 * Also reset the domain counter bitmap.
> +	 */
> +	if (is_mbm_enabled() && r->mon.mbm_cntr_assignable) {
> +		list_for_each_entry(dom, &r->mon_domains, hdr.list) {
> +			memset(dom->cntr_cfg, 0,
> +			       sizeof(*dom->cntr_cfg) * r->mon.num_mbm_cntrs);
> +			resctrl_arch_reset_rmid_all(r, dom);

This looks to be missing reset of resctrl monitor state (from get_mbm_state()).

...

>  static int rdt_get_tree(struct fs_context *fc)
>  {
>  	struct rdt_fs_context *ctx = rdt_fc2context(fc);
> @@ -3023,6 +3082,8 @@ static int rdt_get_tree(struct fs_context *fc)
>  		if (ret < 0)
>  			goto out_info;
>  
> +		rdtgroup_assign_cntrs(&rdtgroup_default);
> +
>  		ret = mkdir_mondata_all(rdtgroup_default.kn,
>  					&rdtgroup_default, &kn_mondata);
>  		if (ret < 0)

If this mkdir_mondata_all() fails it calls "goto out_mongrp" ...

> @@ -3058,8 +3119,10 @@ static int rdt_get_tree(struct fs_context *fc)
>  out_psl:
>  	rdt_pseudo_lock_release();
>  out_mondata:
> -	if (resctrl_arch_mon_capable())
> +	if (resctrl_arch_mon_capable()) {
>  		kernfs_remove(kn_mondata);
> +		rdtgroup_unassign_cntrs(&rdtgroup_default);
> +	}
>  out_mongrp:
>  	if (resctrl_arch_mon_capable())
>  		kernfs_remove(kn_mongrp);

Looks like this will miss counter cleanup on failure of mkdir_mondata_all().

> @@ -3238,6 +3301,7 @@ static void free_all_child_rdtgrp(struct rdtgroup *rdtgrp)
>  
>  	head = &rdtgrp->mon.crdtgrp_list;
>  	list_for_each_entry_safe(sentry, stmp, head, mon.crdtgrp_list) {
> +		rdtgroup_unassign_cntrs(sentry);
>  		free_rmid(sentry->closid, sentry->mon.rmid);
>  		list_del(&sentry->mon.crdtgrp_list);
>  
> @@ -3278,6 +3342,8 @@ static void rmdir_all_sub(void)
>  		cpumask_or(&rdtgroup_default.cpu_mask,
>  			   &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask);
>  
> +		rdtgroup_unassign_cntrs(rdtgrp);
> +
>  		free_rmid(rdtgrp->closid, rdtgrp->mon.rmid);
>  
>  		kernfs_remove(rdtgrp->kn);
> @@ -3309,6 +3375,8 @@ static void rdt_kill_sb(struct super_block *sb)
>  	for_each_alloc_capable_rdt_resource(r)
>  		reset_all_ctrls(r);
>  	rmdir_all_sub();
> +	rdtgroup_unassign_cntrs(&rdtgroup_default);
> +	mbm_cntr_reset(&rdt_resources_all[RDT_RESOURCE_L3].r_resctrl);
>  	rdt_pseudo_lock_release();
>  	rdtgroup_default.mode = RDT_MODE_SHAREABLE;
>  	schemata_list_destroy();
> @@ -3772,6 +3840,8 @@ static int mkdir_rdt_prepare_rmid_alloc(struct rdtgroup *rdtgrp)
>  	}
>  	rdtgrp->mon.rmid = ret;
>  
> +	rdtgroup_assign_cntrs(rdtgrp);
> +
>  	ret = mkdir_mondata_all(rdtgrp->kn, rdtgrp, &rdtgrp->mon.mon_data_kn);
>  	if (ret) {
>  		rdt_last_cmd_puts("kernfs subdir error\n");

Cleanup of assigned counters if mkdir_mondata_all() fails seems to be missing here also.

> @@ -3784,8 +3854,10 @@ static int mkdir_rdt_prepare_rmid_alloc(struct rdtgroup *rdtgrp)
>  
>  static void mkdir_rdt_prepare_rmid_free(struct rdtgroup *rgrp)
>  {
> -	if (resctrl_arch_mon_capable())
> +	if (resctrl_arch_mon_capable()) {
> +		rdtgroup_unassign_cntrs(rgrp);
>  		free_rmid(rgrp->closid, rgrp->mon.rmid);
> +	}
>  }
>  
>  static int mkdir_rdt_prepare(struct kernfs_node *parent_kn,
> @@ -4044,6 +4116,9 @@ static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)
>  	update_closid_rmid(tmpmask, NULL);
>  
>  	rdtgrp->flags = RDT_DELETED;
> +
> +	rdtgroup_unassign_cntrs(rdtgrp);
> +
>  	free_rmid(rdtgrp->closid, rdtgrp->mon.rmid);
>  
>  	/*
> @@ -4090,6 +4165,8 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)
>  	cpumask_or(tmpmask, tmpmask, &rdtgrp->cpu_mask);
>  	update_closid_rmid(tmpmask, NULL);
>  
> +	rdtgroup_unassign_cntrs(rdtgrp);
> +
>  	free_rmid(rdtgrp->closid, rdtgrp->mon.rmid);
>  	closid_free(rdtgrp->closid);
>  

Reinette

  reply	other threads:[~2024-12-19 23:39 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-12 20:15 [PATCH v10 00/24] x86/resctrl : Support AMD Assignable Bandwidth Monitoring Counters (ABMC) Babu Moger
2024-12-12 20:15 ` [PATCH v10 01/24] x86/resctrl: Add __init attribute to functions called from resctrl_late_init() Babu Moger
2024-12-12 20:15 ` [PATCH v10 02/24] x86/cpufeatures: Add support for Assignable Bandwidth Monitoring Counters (ABMC) Babu Moger
2024-12-12 20:15 ` [PATCH v10 03/24] x86/resctrl: Add ABMC feature in the command line options Babu Moger
2024-12-12 20:15 ` [PATCH v10 04/24] x86/resctrl: Consolidate monitoring related data from rdt_resource Babu Moger
2024-12-12 20:15 ` [PATCH v10 05/24] x86/resctrl: Detect Assignable Bandwidth Monitoring feature details Babu Moger
2024-12-12 20:15 ` [PATCH v10 06/24] x86/resctrl: Introduce resctrl_file_fflags_init() to initialize fflags Babu Moger
2024-12-12 20:15 ` [PATCH v10 07/24] x86/resctrl: Add support to enable/disable AMD ABMC feature Babu Moger
2024-12-19 21:48   ` Reinette Chatre
2024-12-20 15:14     ` Moger, Babu
2024-12-20 17:16       ` Reinette Chatre
2024-12-12 20:15 ` [PATCH v10 08/24] x86/resctrl: Introduce the interface to display monitor mode Babu Moger
2024-12-19 21:59   ` Reinette Chatre
2024-12-20 15:31     ` Moger, Babu
2024-12-12 20:15 ` [PATCH v10 09/24] x86/resctrl: Introduce interface to display number of monitoring counters Babu Moger
2024-12-19 22:03   ` Reinette Chatre
2024-12-20 15:41     ` Moger, Babu
2024-12-12 20:15 ` [PATCH v10 10/24] x86/resctrl: Introduce mbm_total_cfg and mbm_local_cfg in struct rdt_hw_mon_domain Babu Moger
2024-12-12 20:15 ` [PATCH v10 11/24] x86/resctrl: Remove MSR reading of event configuration value Babu Moger
2024-12-19 22:12   ` Reinette Chatre
2024-12-20 16:09     ` Moger, Babu
2024-12-12 20:15 ` [PATCH v10 12/24] x86/resctrl: Introduce cntr_cfg to track assignable counters at domain Babu Moger
2024-12-19 22:33   ` Reinette Chatre
2024-12-20 17:33     ` Moger, Babu
2024-12-20 20:58       ` Reinette Chatre
2024-12-12 20:15 ` [PATCH v10 13/24] x86/resctrl: Introduce interface to display number of free counters Babu Moger
2024-12-19 22:50   ` Reinette Chatre
2024-12-20 18:05     ` Moger, Babu
2024-12-20 18:32     ` Moger, Babu
2024-12-12 20:15 ` [PATCH v10 14/24] x86/resctrl: Add data structures and definitions for ABMC assignment Babu Moger
2024-12-12 20:15 ` [PATCH v10 15/24] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC Babu Moger
2024-12-19 23:04   ` Reinette Chatre
2024-12-20 19:22     ` Moger, Babu
2024-12-20 21:41       ` Reinette Chatre
2024-12-20 22:28         ` Moger, Babu
2024-12-20 23:47           ` Reinette Chatre
2024-12-21 13:40             ` Moger, Babu
2024-12-12 20:15 ` [PATCH v10 16/24] x86/resctrl: Add interface to the assign counter Babu Moger
2024-12-12 23:37   ` Luck, Tony
2024-12-13 15:57     ` Moger, Babu
2024-12-13 16:24       ` Luck, Tony
2024-12-13 16:54         ` Moger, Babu
2024-12-18 22:01           ` Reinette Chatre
2024-12-19 19:45             ` Moger, Babu
2024-12-19 21:12               ` Reinette Chatre
2024-12-19 21:38                 ` Moger, Babu
2024-12-19 21:45                   ` Luck, Tony
2024-12-19 22:33                     ` Moger, Babu
2024-12-19 23:22   ` Reinette Chatre
2024-12-20 20:34     ` Moger, Babu
2024-12-12 20:15 ` [PATCH v10 17/24] x86/resctrl: Add the interface to unassign a counter Babu Moger
2024-12-19 23:32   ` Reinette Chatre
2024-12-20 21:38     ` Moger, Babu
2024-12-12 20:15 ` [PATCH v10 18/24] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled Babu Moger
2024-12-19 23:39   ` Reinette Chatre [this message]
2024-12-21 13:45     ` Moger, Babu
2024-12-12 20:15 ` [PATCH v10 19/24] x86/resctrl: Report "Unassigned" for MBM events in mbm_cntr_assign mode Babu Moger
2024-12-19 23:59   ` Reinette Chatre
2024-12-21 14:04     ` Moger, Babu
2024-12-12 20:15 ` [PATCH v10 20/24] x86/resctrl: Introduce the interface to switch between monitor modes Babu Moger
2024-12-20  2:56   ` Reinette Chatre
2024-12-21 14:20     ` Moger, Babu
2024-12-12 20:15 ` [PATCH v10 21/24] x86/resctrl: Configure mbm_cntr_assign mode if supported Babu Moger
2024-12-20  3:03   ` Reinette Chatre
2024-12-21 14:33     ` Moger, Babu
2024-12-12 20:15 ` [PATCH v10 22/24] x86/resctrl: Update assignments on event configuration changes Babu Moger
2024-12-20  3:12   ` Reinette Chatre
2024-12-21 14:59     ` Moger, Babu
2024-12-23 16:20       ` Reinette Chatre
2025-01-13 20:03         ` Moger, Babu
2024-12-12 20:15 ` [PATCH v10 23/24] x86/resctrl: Introduce interface to list assignment states of all the groups Babu Moger
2024-12-12 22:57   ` Luck, Tony
2024-12-13 15:23     ` Moger, Babu
2024-12-12 20:15 ` [PATCH v10 24/24] x86/resctrl: Introduce interface to modify assignment states of " Babu Moger
2024-12-20  3:23   ` Reinette Chatre
2024-12-21 15:28     ` 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=6bc0816c-d926-45de-ba97-459fb0fca9ff@intel.com \
    --to=reinette.chatre@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=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=ebiggers@google.com \
    --cc=eranian@google.com \
    --cc=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=james.morse@arm.com \
    --cc=jpoimboe@kernel.org \
    --cc=kai.huang@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maciej.wieczor-retman@intel.com \
    --cc=mario.limonciello@amd.com \
    --cc=mingo@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=perry.yuan@amd.com \
    --cc=peternewman@google.com \
    --cc=rostedt@goodmis.org \
    --cc=sandipan.das@amd.com \
    --cc=seanjc@google.com \
    --cc=tan.shaopeng@fujitsu.com \
    --cc=tglx@linutronix.de \
    --cc=thuth@redhat.com \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    --cc=xiaoyao.li@intel.com \
    --cc=xin3.li@intel.com \
    --cc=xiongwei.song@windriver.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

all inboxes | Powered by JetHome®