mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Horgan <ben.horgan@arm.com>
To: Zeng Heng <zengheng4@huawei.com>,
	gshan@redhat.com, reinette.chatre@intel.com, fenghuay@nvidia.com,
	james.morse@arm.com, jonathan.cameron@huawei.com,
	tan.shaopeng@jp.fujitsu.com
Cc: linux-kernel@vger.kernel.org, jic23@kernel.org,
	wangkefeng.wang@huawei.com
Subject: Re: [PATCH next] arm_mpam: Fix MBA alloc_capable handling
Date: Fri, 17 Apr 2026 10:52:59 +0100	[thread overview]
Message-ID: <8c47b769-dd97-4e52-8c9e-496156850a3d@arm.com> (raw)
In-Reply-To: <20260413090041.1174485-1-zengheng4@huawei.com>

Hi Zeng,

On 4/13/26 10:00, Zeng Heng wrote:
> The resctrl_arch_set_cdp_enabled() is never invoked with RDT_RESOURCE_MBA
> as the rid parameter. Consequently,
> mpam_resctrl_controls[RDT_RESOURCE_MBA].cdp_enabled always remains false,
> making it unreliable for conditional checks.
> 
> The original logic uses this field to determine MBA state, causing a bug
> where MBA allocation is permanently disabled after the mount with CDP
> option. Remounting without CDP cannot restore the MBA partition capability.

Ah, I see. Thanks for spotting this and sending a patch.

> 
> Fix by using the cdp_enabled global parameter directly. Enable MBA
> partition only when CDP is disabled and the MBA resource class is
> present. Disable MBA partition otherwise.
> 
> Fixes: 6789fb99282c ("arm_mpam: resctrl: Add CDP emulation")
> Signed-off-by: Zeng Heng <zengheng4@huawei.com>
> ---
>  drivers/resctrl/mpam_resctrl.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
> index a9938006d0e6..161fb8905e28 100644
> --- a/drivers/resctrl/mpam_resctrl.c
> +++ b/drivers/resctrl/mpam_resctrl.c
> @@ -217,12 +217,10 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level rid, bool enable)
>  		l3->mon.num_rmid = resctrl_arch_system_num_rmid_idx();
>  
>  	/* The mbw_max feature can't hide cdp as it's a per-partid maximum. */
> -	if (cdp_enabled && !mpam_resctrl_controls[RDT_RESOURCE_MBA].cdp_enabled)
> -		mpam_resctrl_controls[RDT_RESOURCE_MBA].resctrl_res.alloc_capable = false;
> -
> -	if (mpam_resctrl_controls[RDT_RESOURCE_MBA].cdp_enabled &&
> -	    mpam_resctrl_controls[RDT_RESOURCE_MBA].class)
> +	if (!cdp_enabled && mpam_resctrl_controls[RDT_RESOURCE_MBA].class)
>  		mpam_resctrl_controls[RDT_RESOURCE_MBA].resctrl_res.alloc_capable = true;
> +	else
> +		mpam_resctrl_controls[RDT_RESOURCE_MBA].resctrl_res.alloc_capable = false;

Isn't it more that the existing checks are correct (if not totally necessary) and guard against
resctrl_arch_set_cdp_enabled() being called with RDT_RESOURCE_MBA but that re-enable on unmount is missing?

Does just adding this check make sense? As already commented in the function we assume that
resctrl_arch_set_cdp_enabled() is only called with enable=false on error or unmount.

--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -224,6 +224,9 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level rid, bool enable)
            mpam_resctrl_controls[RDT_RESOURCE_MBA].class)
                mpam_resctrl_controls[RDT_RESOURCE_MBA].resctrl_res.alloc_capable = true;

+       if (!cdp_enabled && mpam_resctrl_controls[RDT_RESOURCE_MBA].class)
+               mpam_resctrl_controls[RDT_RESOURCE_MBA].resctrl_res.alloc_capable = true;
+
        if (enable) {
                if (mpam_partid_max < 1)
                        return -EINVAL;

Thanks,

Ben


>  
>  	if (enable) {
>  		if (mpam_partid_max < 1)


  reply	other threads:[~2026-04-17  9:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-13  9:00 Zeng Heng
2026-04-17  9:52 ` Ben Horgan [this message]
2026-04-17 16:07   ` James Morse
2026-04-17 16:31     ` Ben Horgan
2026-04-18  6:14     ` Zeng Heng

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=8c47b769-dd97-4e52-8c9e-496156850a3d@arm.com \
    --to=ben.horgan@arm.com \
    --cc=fenghuay@nvidia.com \
    --cc=gshan@redhat.com \
    --cc=james.morse@arm.com \
    --cc=jic23@kernel.org \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=reinette.chatre@intel.com \
    --cc=tan.shaopeng@jp.fujitsu.com \
    --cc=wangkefeng.wang@huawei.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

all inboxes | Powered by JetHome®