From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout08.his.huawei.com (canpmsgout08.his.huawei.com [113.46.200.223]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67A0122259F for ; Sat, 18 Apr 2026 06:14:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.223 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776492859; cv=none; b=ckRqFbzuxhwWYjSWCJ2nu7eWeQ436WyE2m/fJowPohvIpdhlklPg2LPzBU035OM85BGPpfJCIMlPB+92BP4ObqT2tslg6ur5b35RF5qBvswo4YDc4U+z97ZJr6H0Kl0nYVxtHOEr08h9UMj1eQXOMtYWkgHjaJIDJMXSOHTjB/0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776492859; c=relaxed/simple; bh=VsH7IGq+zYsKaa2Hg63xSmKBlelLri9NHFN6G2cA/uo=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=pLQGwFfNKPP3GO0eA7xrNNo9DT4VnGtBI1kV8crHzQQnOTO0zh7XhJpDHSSdAo/DoPw5xM1AeNWM/w4QtwoXd1j5U8uK10UZgYyY+EhigIahWLhgkURvU+Vy2ssKLaNpMOUJwWaL9Gu2kwaAYLC9ypefqxFnJ+Or0tBoVtro+e4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=h-partners.com; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b=Rc3qNW8b; arc=none smtp.client-ip=113.46.200.223 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=h-partners.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b="Rc3qNW8b" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=Iy3ahjjyRS5KwC3RWMgQxocFRVivuxTVSGhMkokz198=; b=Rc3qNW8baVPW1toYs6tm4Z6LM/F23bfHibjAvzgpc8fraMLcctJbDF1SZhDEtOX67rVmJwqn4 FCaNBnHKFH88mX2ytPJxxBKH2SKq4QI5hUr8n9hOfDSDpHiBbIgZy5jm7YE/3za4jVIyxo2nUKv bettRhg74lL/onfzmOqjU8w= Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout08.his.huawei.com (SkyGuard) with ESMTPS id 4fyLrZ5zqDzmV69; Sat, 18 Apr 2026 14:07:42 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id 62E414056C; Sat, 18 Apr 2026 14:14:04 +0800 (CST) Received: from [10.174.179.37] (10.174.179.37) by kwepemf100008.china.huawei.com (7.202.181.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Sat, 18 Apr 2026 14:14:03 +0800 Message-ID: <4593b16b-c273-f7cf-8156-d218948ba00e@huawei.com> Date: Sat, 18 Apr 2026 14:14:02 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH next] arm_mpam: Fix MBA alloc_capable handling Content-Language: en-US To: James Morse , Ben Horgan , , , , , CC: , , References: <20260413090041.1174485-1-zengheng4@huawei.com> <8c47b769-dd97-4e52-8c9e-496156850a3d@arm.com> <2ebfdf08-8752-431d-82e4-9567ec71d38c@arm.com> From: Zeng Heng In-Reply-To: <2ebfdf08-8752-431d-82e4-9567ec71d38c@arm.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemf100008.china.huawei.com (7.202.181.222) Hi James, Ben: On 2026/4/18 0: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. > > The above comments and explanations look reasonable to me. Thanks to all for the thorough review. Thanks for your time, Zeng Heng