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 6A1FC13C9C4 for ; Fri, 17 Apr 2026 09:53:03 +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=1776419586; cv=none; b=RJ6VrVTejfPTYWmXd0Mnx7LWclSx6tThZdkJX9OZLxqhLu3+0IjDOho8LQNfE1vpj2wheFZDSjJFLE6MsNdFrw85IaRRCOkwYbuKyGuv+TZkduEql9m5fOS75Xpwb50lYwmcydujePTX335+/vuP0IUfq2XuyMbuxZf0qsIPM3w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776419586; c=relaxed/simple; bh=sTXENcSTOi+5Yxm8YXqL7eOaR9Vbn5IVjuNcgU8C4B4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TJqHR0Ulua7/nQlUiWja+zZHl6f0AZaFzu6ryhnyku8JbHDtUXqrO5BF0BQaLJa9khgULBzPrZyRzNfaHau+tdMYDQYnozQLXFAULySwssUvv8ABbpl/nx1ZLejJhCeh3Wnrug5gudJ+/TY/NutcFyANKtp+kMmZ8r2TMY3F8+Q= 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=of/TtfZp; 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="of/TtfZp" 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 B31BF1DB5; Fri, 17 Apr 2026 02:52:56 -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 2F6663F7B4; Fri, 17 Apr 2026 02:53:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1776419582; bh=sTXENcSTOi+5Yxm8YXqL7eOaR9Vbn5IVjuNcgU8C4B4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=of/TtfZpH6B0O1HLhASo8Z6v0dsSUdGLybjR2Fa8Mc8sV3w9zs1q5yhkdMg7KdiyI bRfynjYCbBOVukJtiWLjvMCkge1KR+Ybd9z9torPgG6yWvL268KGzzeiHPxcoGGrEC lCMtIJtHXNU5ugdwaOjlfgwIkJ3JBI85AcJeobDA= Message-ID: <8c47b769-dd97-4e52-8c9e-496156850a3d@arm.com> Date: Fri, 17 Apr 2026 10:52:59 +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: Zeng Heng , 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 References: <20260413090041.1174485-1-zengheng4@huawei.com> Content-Language: en-US From: Ben Horgan In-Reply-To: <20260413090041.1174485-1-zengheng4@huawei.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 > --- > 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)