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>,
	"Moger, Babu" <bmoger@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 22/24] x86/resctrl: Update assignments on event configuration changes
Date: Mon, 13 Jan 2025 14:03:34 -0600	[thread overview]
Message-ID: <527b1b69-bbd8-497f-afb2-94e865af2255@amd.com> (raw)
In-Reply-To: <f53a0de4-32b8-4648-a036-108e4369f31d@intel.com>

Hi Reinette,

On 12/23/24 10:20, Reinette Chatre wrote:
> Hi Babu,
> 
> On 12/21/24 6:59 AM, Moger, Babu wrote:
>> Hi Reinette,
>>
>> On 12/19/2024 9:12 PM, Reinette Chatre wrote:
>>> Hi Babu,
>>>
>>> On 12/12/24 12:15 PM, Babu Moger wrote:
>>>> Resctrl provides option to configure events by writing to the interfaces
>>>> /sys/fs/resctrl/info/L3_MON/mbm_total_bytes_config or
>>>> /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config when BMEC (Bandwidth
>>>> Monitoring Event Configuration) is supported.
>>>>
>>>> Whenever the event configuration is updated, MBM assignments must be
>>>> revised across all monitor groups within the impacted domains.
>>>
>>> This needs imperative tone description of what this patch does.
>>
>> Sure.
>>
>>>
>>>   ...
>>>
>>>> @@ -1825,6 +1825,54 @@ static int mbm_local_bytes_config_show(struct kernfs_open_file *of,
>>>>       return 0;
>>>>   }
>>>>   +/*
>>>> + * Review the cntr_cfg domain configuration. If a matching assignment is found,
>>>> + * update the counter assignment accordingly. This is within the IPI Context,
>>>
>>> This "Review the cntr_cfg domain configuration. If a matching assignment is found,"
>>> is too vague for me to make sense of what it is trying to do. Can this be made more specific?
>>
>> Does this look ok?
>>
>> Check the counter configuration in the domain. If the specific event is configured, then update the assignment with the new event configuration value. This is within the IPI Context,  so call resctrl_abmc_config_one_amd directly"
> 
> I think it will be easier to understand what this function does if the
> comment is made more specific. For example:
> 	Update hardware counter configuration after event configuration change.         
>                                                                                 
> 	Walk the hardware counters of domain @d to reconfigure all assigned
> 	counters that are monitoring @evtid with the event's new configuration
> 	@mon_config (or @config_val).                                     
>                                                                                 
> 	This is run on a CPU belonging to domain @d so call                             
> 	resctrl_abmc_config_one_amd() directly.    

Looks good.  Thanks

> 
> Looking closer at architecture specific resctrl_arch_update_cntr() the
> reset of non-arch state (get_mbm_state()->memset()) seems out of place.
> There is a resctrl_arch_reset_rmid_all() within mbm_config_write_domain() that
> resets all architectural state after the event configuration is changed,
> should the non-architectural state not also be reset at that time? It looks

Moved the reset of non-arch state inside mbm_config_write_domain(). It
seems to work fine. Also I can simplify the IPI code further.


diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 5f5cf9b3a053..ce08fb718e2e 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -2076,9 +2076,6 @@ static void resctrl_abmc_config_one_amd(void *info)
        abmc_cfg.split.bw_type = config->val;

        wrmsrl(MSR_IA32_L3_QOS_ABMC_CFG, abmc_cfg.full);
-
-       resctrl_arch_reset_rmid(config->r, config->d, config->closid,
-                               config->rmid, config->evtid);
 }

 static int mbm_config_show(struct seq_file *s, struct rdt_resource *r,
u32 evtid)
@@ -2153,10 +2150,6 @@ static void resctrl_arch_update_cntr(struct
rdt_resource *r, struct rdt_mon_doma
                        config.assign = 1;

                        resctrl_abmc_config_one_amd(&config);
-
-                       m = get_mbm_state(d, rdtgrp->closid,
rdtgrp->mon.rmid, evtid);
-                       if (m)
-                               memset(m, 0, sizeof(struct mbm_state));
                }
        }
 }
@@ -2178,6 +2171,7 @@ static void resctrl_mon_event_config_set(void *info)
 static void mbm_config_write_domain(struct rdt_resource *r,
                                    struct rdt_mon_domain *d, u32 evtid,
u32 val)
 {
+       u32 idx_limit = resctrl_arch_system_num_rmid_idx();
        struct mon_config_info mon_info = {0};
        u32 config_val;

@@ -2214,6 +2208,12 @@ static void mbm_config_write_domain(struct
rdt_resource *r,
         * mbm_local and mbm_total counts for all the RMIDs.
         */
        resctrl_arch_reset_rmid_all(r, d);
+
+       if (is_mbm_total_enabled())
+               memset(d->mbm_total, 0, sizeof(struct mbm_state) * idx_limit);
+
+       if (is_mbm_local_enabled())
+               memset(d->mbm_local, 0, sizeof(struct mbm_state) * idx_limit);
 }

 static int mon_config_write(struct rdt_resource *r, char *tok, u32 evtid)



> to me like it is something that may be needed for existing event
> configuration (but not an issue until Peter's new feature lands) and when done,
> the reset done within resctrl_arch_update_cntr() will no longer be necessary.
> 
> Something else to consider is the resctrl_arch_reset_rmid() within
> resctrl_abmc_config_one_amd() seems redundant on this call path since
> it is followed by resctrl_arch_reset_rmid_all(). resctrl_arch_reset_rmid() 
> does one MSR write and one MSR read for every counter that needs to be
> reconfigured and if that is unnecessary it may be worthwhile to optimize
> out?

Yes. Removed the resctrl_arch_reset_rmid() within
resctrl_abmc_config_one_amd().

Tested the code and seems to  work fine.

-- 
Thanks
Babu Moger

  reply	other threads:[~2025-01-13 20:03 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
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 [this message]
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=527b1b69-bbd8-497f-afb2-94e865af2255@amd.com \
    --to=babu.moger@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=bmoger@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=reinette.chatre@intel.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®