mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fenghua Yu <fenghuay@nvidia.com>
To: Ben Horgan <ben.horgan@arm.com>
Cc: amitsinght@marvell.com, baisheng.gao@unisoc.com,
	baolin.wang@linux.alibaba.com, carl@os.amperecomputing.com,
	dave.martin@arm.com, david@kernel.org, dfustini@baylibre.com,
	gshan@redhat.com, james.morse@arm.com, jic23@kernel.org,
	kobak@nvidia.com, lcherian@marvell.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, peternewman@google.com,
	punit.agrawal@oss.qualcomm.com, quic_jiles@quicinc.com,
	reinette.chatre@intel.com, rohit.mathew@arm.com,
	scott@os.amperecomputing.com, sdonthineni@nvidia.com,
	tan.shaopeng@fujitsu.com, xhao@linux.alibaba.com,
	zengheng4@huawei.com, x86@kernel.org,
	Jonathan Cameron <jonathan.cameron@huawei.com>
Subject: Re: [PATCH v4 3/5] arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
Date: Thu, 2 Jul 2026 22:23:16 -0700	[thread overview]
Message-ID: <7cc07877-3318-44bc-8122-f8d493be833d@nvidia.com> (raw)
In-Reply-To: <20260520212458.1797221-4-ben.horgan@arm.com>

Hi, Ben,

On 5/20/26 14:24, Ben Horgan wrote:
> From: James Morse <james.morse@arm.com>
> 
> ABMC, mbm_event mode, has a helper resctrl_arch_config_cntr() for changing
> the mapping between 'cntr_id' and a CLOSID/RMID pair.
> 
> Add the helper.
> 
> For MPAM this is done by updating the mon->mbwu_idx_to_mon[] array, and as
> usual CDP means it needs doing in three different ways.
> 
> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> Signed-off-by: James Morse <james.morse@arm.com>
> Signed-off-by: Ben Horgan <ben.horgan@arm.com>

Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>

Please check following nits.

> ---
> Changes since new rfc:
> Mention mbm_event mode in commit message
> 
> Changes since v3:
> Warning bound (Sashiko)
> ---
>   drivers/resctrl/mpam_resctrl.c | 44 +++++++++++++++++++++++++++++-----
>   1 file changed, 38 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
> index a13eb232a19d..1f9a8ae157ca 100644
> --- a/drivers/resctrl/mpam_resctrl.c
> +++ b/drivers/resctrl/mpam_resctrl.c
> @@ -127,12 +127,6 @@ void resctrl_arch_reset_cntr(struct rdt_resource *r, struct rdt_l3_mon_domain *d
>   {
>   }
>   
> -void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_l3_mon_domain *d,
> -			      enum resctrl_event_id evtid, u32 rmid, u32 closid,
> -			      u32 cntr_id, bool assign)
> -{
> -}
> -
>   int resctrl_arch_cntr_read(struct rdt_resource *r, struct rdt_l3_mon_domain *d,
>   			   u32 unused, u32 rmid, int cntr_id,
>   			   enum resctrl_event_id eventid, u64 *val)
> @@ -1076,6 +1070,44 @@ static void mpam_resctrl_pick_counters(void)
>   	}
>   }
>   
> +static void __config_cntr(struct mpam_resctrl_mon *mon, u32 cntr_id,
> +			  enum resctrl_conf_type cdp_type, u32 closid, u32 rmid,
> +			  bool assign)
> +{
> +	u32 mbwu_idx, mon_idx = resctrl_get_config_index(cntr_id, cdp_type);

Nit:

Reuse resctrl_get_config_index() to get cntr_id->mon_idx which 
resctrl_get_config_index() handles closid:
/* For use by arch code to remap resctrl's smaller CDP CLOSID range */
static inline u32 resctrl_get_config_index(u32 closid,
                                            enum resctrl_conf_type type)

Logically it's correct. It's just a little confusing when reading it.

Maybe adding a comment to make reading easier?
+       /* Same CDP index remap as closid; maps cntr_id to 
assigned_counters[]. */

But it's up to you.

> +
> +	WARN_ON_ONCE(mon_idx >= l3_num_allocated_mbwu);> +
> +	closid = resctrl_get_config_index(closid, cdp_type);
> +	mbwu_idx = resctrl_arch_rmid_idx_encode(closid, rmid);
> +
> +	if (assign)
> +		mon->mbwu_idx_to_mon[mbwu_idx] = mon->assigned_counters[mon_idx];
> +	else
> +		mon->mbwu_idx_to_mon[mbwu_idx] = -1;
> +}
> +
> +void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_l3_mon_domain *d,
> +			      enum resctrl_event_id evtid, u32 rmid, u32 closid,
> +			      u32 cntr_id, bool assign)
> +{
> +	struct mpam_resctrl_mon *mon = &mpam_resctrl_counters[evtid];

Add a sanity checking on evtid == QOS_L3_MBM_TOTAL_EVENT_ID here? To 
make sure this helper is not for llc occupancy event. And the sanity 
checking matches other functions in mpam_resctrl.c.

> +
> +	if (!mon->mbwu_idx_to_mon || !mon->assigned_counters) {
> +		pr_debug("monitor arrays not allocated\n");
> +		return;
> +	}
> +
> +	if (cdp_enabled) {
> +		__config_cntr(mon, cntr_id, CDP_CODE, closid, rmid, assign);
> +		__config_cntr(mon, cntr_id, CDP_DATA, closid, rmid, assign);
> +	} else {
> +		__config_cntr(mon, cntr_id, CDP_NONE, closid, rmid, assign);
> +	}
> +
> +	resctrl_arch_reset_rmid(r, d, closid, rmid, evtid);
> +}
> +
>   static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
>   {
>   	struct mpam_class *class = res->class;

Thanks.

-Fenghua

  reply	other threads:[~2026-07-03  5:23 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20 21:24 [PATCH v4 0/5] arm_mpam: resctrl: Counter Assignment (ABMC) Ben Horgan
2026-05-20 21:24 ` [PATCH v4 1/5] arm_mpam: resctrl: Pick classes for use as MBM counters Ben Horgan
2026-07-02 16:30   ` Fenghua Yu
2026-07-03 14:01     ` Ben Horgan
2026-07-03 16:36       ` Fenghua Yu
2026-05-20 21:24 ` [PATCH v4 2/5] arm_mpam: resctrl: Pre-allocate assignable monitors Ben Horgan
2026-05-26  2:50   ` Koba Ko
2026-05-26  8:47     ` Ben Horgan
2026-07-03  5:30   ` Fenghua Yu
2026-07-06 13:16     ` Ben Horgan
2026-05-20 21:24 ` [PATCH v4 3/5] arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use Ben Horgan
2026-07-03  5:23   ` Fenghua Yu [this message]
2026-05-20 21:24 ` [PATCH v4 4/5] arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() Ben Horgan
2026-07-03  5:35   ` Fenghua Yu
2026-05-20 21:24 ` [PATCH v4 5/5] arm64: mpam: Add memory bandwidth usage (MBWU) documentation Ben Horgan
2026-07-01 22:38   ` Reinette Chatre
2026-07-02  9:20     ` Ben Horgan
2026-07-02 14:46       ` Reinette Chatre
2026-07-02 14:58         ` Ben Horgan
2026-07-02 15:46           ` Fenghua Yu
2026-07-06 13:34             ` Ben Horgan
2026-05-27  0:42 ` [PATCH v4 0/5] arm_mpam: resctrl: Counter Assignment (ABMC) Shaopeng Tan (Fujitsu)
2026-05-27 14:36   ` Ben Horgan
2026-07-03  5:38 ` Fenghua Yu

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=7cc07877-3318-44bc-8122-f8d493be833d@nvidia.com \
    --to=fenghuay@nvidia.com \
    --cc=amitsinght@marvell.com \
    --cc=baisheng.gao@unisoc.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=ben.horgan@arm.com \
    --cc=carl@os.amperecomputing.com \
    --cc=dave.martin@arm.com \
    --cc=david@kernel.org \
    --cc=dfustini@baylibre.com \
    --cc=gshan@redhat.com \
    --cc=james.morse@arm.com \
    --cc=jic23@kernel.org \
    --cc=jonathan.cameron@huawei.com \
    --cc=kobak@nvidia.com \
    --cc=lcherian@marvell.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peternewman@google.com \
    --cc=punit.agrawal@oss.qualcomm.com \
    --cc=quic_jiles@quicinc.com \
    --cc=reinette.chatre@intel.com \
    --cc=rohit.mathew@arm.com \
    --cc=scott@os.amperecomputing.com \
    --cc=sdonthineni@nvidia.com \
    --cc=tan.shaopeng@fujitsu.com \
    --cc=x86@kernel.org \
    --cc=xhao@linux.alibaba.com \
    --cc=zengheng4@huawei.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