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 5BE66221F13 for ; Tue, 16 Dec 2025 16:58:38 +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=1765904320; cv=none; b=WTOTJOPadw97IIaYGUpKoFZcATt+Oh+qS5bD9O6O91LrgE7HF+PzxG9QXiw/lyWzUCwH9I2pOvYGmKZqYgmsN6rdIcF7sATRhhMxCfN+MpYxm6dC8KzdVQBPBptCWuu1/anuxd5u767x5Y2dRU572cI4f+WjcJQoNJGOqfhfUeM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765904320; c=relaxed/simple; bh=yh6UTWAs3eNAzzF+0zMuAQTR++wARtF/mnFrTzivC3c=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=oswlUuRNh+wbnQDgNH2kmG5Xixm3q44wACpyF5QCfp6hGrkwfsdPlb0Oq9bFuHQ07PEDiS6HWxF3a3q5IVIiDZsgy+BYHrUJ8RWhg6BpJWkDsMX+cNyCQhFMDtLBUNi6WR+1D5ku+lAu5FbMZqpD5Nb+688A8G80ZXzjkeszwQw= 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; 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 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 57C6BFEC; Tue, 16 Dec 2025 08:58:30 -0800 (PST) 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 352A43F73B; Tue, 16 Dec 2025 08:58:34 -0800 (PST) Message-ID: Date: Tue, 16 Dec 2025 16:58:32 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 24/38] arm_mpam: resctrl: Allow resctrl to allocate monitors To: James Morse , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: D Scott Phillips OS , carl@os.amperecomputing.com, lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com, amitsinght@marvell.com, David Hildenbrand , Dave Martin , Koba Ko , Shanker Donthineni , fenghuay@nvidia.com, baisheng.gao@unisoc.com, Jonathan Cameron , Gavin Shan , rohit.mathew@arm.com, reinette.chatre@intel.com, Punit Agrawal References: <20251205215901.17772-1-james.morse@arm.com> <20251205215901.17772-25-james.morse@arm.com> From: Ben Horgan Content-Language: en-US In-Reply-To: <20251205215901.17772-25-james.morse@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi James, On 12/5/25 21:58, James Morse wrote: > When resctrl wants to read a domain's 'QOS_L3_OCCUP', it needs > to allocate a monitor on the corresponding resource. Monitors are > allocated by class instead of component. > > MBM monitors are much more complicated, if there are enough monitors, > they will be pre-allocated and free-running. If ABMC is in use instead > then 'some' are pre-allocated in a different way, and need assigning. > > Add helpers to allocate a CSU monitor. These helper return an out > of range value for MBM counters. > > Allocating a montitor context is expected to block until hardware > resources become available. This only makes sense for QOS_L3_OCCUP > as unallocated MBM counters are losing data. > > Signed-off-by: James Morse > --- > Since ABMC got merged it may be possible to remove the monitor alloc > call for MBM counters from resctrl as this work is now done by ABMC's > assign call. > --- > drivers/resctrl/mpam_internal.h | 14 ++++++- > drivers/resctrl/mpam_resctrl.c | 68 +++++++++++++++++++++++++++++++++ > include/linux/arm_mpam.h | 4 ++ > 3 files changed, 85 insertions(+), 1 deletion(-) > > diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h > index 05101186af17..3a68ebd498fa 100644 > --- a/drivers/resctrl/mpam_internal.h > +++ b/drivers/resctrl/mpam_internal.h > @@ -32,6 +32,14 @@ DECLARE_STATIC_KEY_FALSE(mpam_enabled); > #define PACKED_FOR_KUNIT > #endif > > +/* > + * This 'mon' values must not alias an actual monitor, so must be larger than > + * U16_MAX, but not be confused with an errno value, so smaller than > + * (u32)-SZ_4K. > + * USE_PRE_ALLOCATED is used to avoid confusion with an actual monitor. > + */ > +#define USE_PRE_ALLOCATED (U16_MAX + 1) > + > static inline bool mpam_is_enabled(void) > { > return static_branch_likely(&mpam_enabled); > @@ -215,7 +223,11 @@ enum mon_filter_options { > }; > > struct mon_cfg { > - u16 mon; > + /* > + * mon must be large enough to hold out of range values like > + * USE_RMID_IDX > + */ USE_RMID_IDX -> USE_PRE_ALLOCATED Thanks, Ben