From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19D0F33A9F3 for ; Fri, 17 Apr 2026 16:31:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776443491; cv=none; b=oea+aarBOLeHt5vJXlcUdPhsI+0E7cSPaVMDI1C63PJcN+UVcA0oAKLB/T2vTHsIp8L6mEhejyp0NaCd2El8Et7W0G+2hnF5+zwmPb2hkYY0y454k/qu09daEDs6DO8Oe3jdPXiGWMRxVkzGC/6j5L7cHanhc5/ajlahqvQSe4I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776443491; c=relaxed/simple; bh=MDFzOHChoDQrJI8Q+j+iyWTbrSscYBNmM79kM/k29Ac=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FDP5LmHL6MCu7X2lZ98ZWiNB6fGjw16RlQWyqWs4JuUVrDtoyoGPdBhikeN5C/9HZF7nBq5lecwnGSSMCfAKcPL7VDh332TE6aigBKqVrBNCao6tKcX6AxbtITXE3DdPjVF4AnBQkpxpqJJQsOz7svp/rK+SmUzec83yLJBKIqg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=ETjA54Lz; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="ETjA54Lz" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 745DF1DB5; Fri, 17 Apr 2026 09:31:21 -0700 (PDT) Received: from [10.1.196.46] (e134344.arm.com [10.1.196.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E1D9B3F641; Fri, 17 Apr 2026 09:31:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1776443487; bh=MDFzOHChoDQrJI8Q+j+iyWTbrSscYBNmM79kM/k29Ac=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ETjA54Lzc8R1z41zPf3vcZABHvncWklN7LqecPd+pU+X/7wx0JmL0Pe3KjiK9JFRu guEY53OHHW9/t4/W0r2UIuBjTp/PJseiS8yFPurXoFGiL0YZIJYx09YoI4e+cwIbwP 4cdrOCwzZOUAJkojZUJnOj6WJZuXDqRC/NBD0xnM= Message-ID: Date: Fri, 17 Apr 2026 17:31:24 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Thunderbird Daily Subject: Re: [PATCH next] arm_mpam: Fix MBA alloc_capable handling To: James Morse , Zeng Heng , gshan@redhat.com, reinette.chatre@intel.com, fenghuay@nvidia.com, jonathan.cameron@huawei.com, tan.shaopeng@jp.fujitsu.com Cc: linux-kernel@vger.kernel.org, jic23@kernel.org, wangkefeng.wang@huawei.com References: <20260413090041.1174485-1-zengheng4@huawei.com> <8c47b769-dd97-4e52-8c9e-496156850a3d@arm.com> <2ebfdf08-8752-431d-82e4-9567ec71d38c@arm.com> Content-Language: en-US From: Ben Horgan In-Reply-To: <2ebfdf08-8752-431d-82e4-9567ec71d38c@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi James, On 4/17/26 17:07, James Morse wrote: > Hi Zeng, Ben, > > On 17/04/2026 10:52, Ben Horgan wrote: >> 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. > > This shape of bug is likely - I've not had access to a platform with bandwidth > monitors! > > >>> 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. > >>> 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; > > My reading of the original: > | if (mpam_resctrl_controls[RDT_RESOURCE_MBA].cdp_enabled && > | mpam_resctrl_controls[RDT_RESOURCE_MBA].class) > | mpam_resctrl_controls[RDT_RESOURCE_MBA].resctrl_res.alloc_capable = true; > > is that it was trying to do this reset - but never running. (as Zeng's commit message > describes). > > I've spoken to Ben - and the intent here is a bit more complicated... > > if resctrl does start calling: > | resctrl_arch_set_cdp_enabled(RDT_RESOURCE_MBA, true) > > then we expect to receive two configurations, one for code and one for data, so the > aliasing controls problem goes away. The above original code is re-enabling MBA in this > case. It needs to ignore the global 'cdp_enabled' to be immune to the order of > resctrl_arch_set_cdp_enabled() calls. > > While this might seem odd, as resctrl doesn't do this today - it is a valid enum value, > and this is in the woolly "are we Xeon shaped" area. > > I think long term we need a list of non-aliasing controls (min and max etc) which need > disabling when CDP enabled. But re-enabling them when called explicitly makes sense as > we have to handle those enum value anyway. > > >> 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; > > > I'll add a comment above the original code quoted above describing what it does, and > take your hunk here, (with a comment that its for umount): > -------------%<------------- > arm_mpam: resctrl: Fix MBA CDP alloc_capable handling on unmount > > The code to set MBA's alloc_capable to true appears to be trying to > restore alloc_capable on unmount. This can never work because > 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. > > The alloc_capable setting in resctrl_arch_set_cdp_enabled() is to > re-enable MBA if the caller opts in to separate control values using > CDP for this resource. This doesn't happen today. > > Add a comment to describe this. > > However a bug remains where MBA allocation is permanently disabled after > the mount with CDP option. Remounting without CDP cannot restore the MBA > partition capability. > > Add a check to re-enable MBA when CDP is disabled, which happens on > unmount. > --- > @@ -220,10 +220,18 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level rid, bool > enable) > if (cdp_enabled && !mpam_resctrl_controls[RDT_RESOURCE_MBA].cdp_enabled) > mpam_resctrl_controls[RDT_RESOURCE_MBA].resctrl_res.alloc_capable = false; > > + /* > + * if resctrl has attempted to enable CDP on MBA, re-enable MBA as two if -> If> + * configurations will provided so there is no aliasing problem. will -> will be> + */ > if (mpam_resctrl_controls[RDT_RESOURCE_MBA].cdp_enabled && > mpam_resctrl_controls[RDT_RESOURCE_MBA].class) > mpam_resctrl_controls[RDT_RESOURCE_MBA].resctrl_res.alloc_capable = true; > > + /* On unmount when CDP is disabled, re-enable MBA */ > + 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; > -------------%<------------- > > Ben - do you want a Co-developed by for this? No need. The additional comments and updated commit message make sense to me. Reviewed-by: Ben Horgan Thanks, Ben > > While I'm at it: > Reviewed-by: James Morse > > > Thanks, > > James