From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 BD8E51BD9CE for ; Sat, 13 Jun 2026 08:59:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781341203; cv=none; b=OGZyRExo3iLRWhaoxU0TtZLhI7duZ33Obm7ZOFUXO26AUALqQV4KYDMNDdVS1F+AGS0SyDxyFNYWTgJFwLcQo2ooW/lRaDaKdMD/xyxXSm5j5eISqAHPGCnP+RYqDjKkYRKEK3JJmqbX3K/f+MOgMtROCPQcC9C5z5g55SlgdM8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781341203; c=relaxed/simple; bh=GSh20kUh2Sayz851e+jaHRBrDIXfHoeUF1iOxiuI/g4=; h=Message-ID:Date:MIME-Version:Subject:References:From:To:Cc: In-Reply-To:Content-Type; b=q3fqld2MnivAytp6SWPLSHCUK7k6Z1DVEK87ESBv7AIA0gBVBdVHiVzqeg+a61amFnM5SLOg6bewB3yK8sz89hNdWIgdQu3FLKCv+qqiHb+UdzdhAyeBaLqXSfwI1A1QEPSEORVCKlvFFuk6rws4l+tzapjjXeLopLbnrHMbPps= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.198]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4gcr0Z2ZtxzKHMQ7 for ; Sat, 13 Jun 2026 16:59:10 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 10E4F40576 for ; Sat, 13 Jun 2026 16:59:52 +0800 (CST) Received: from [10.174.179.37] (unknown [10.174.179.37]) by APP1 (Coremail) with SMTP id cCh0CgB3ej8FHC1qecmJBg--.8230S3; Sat, 13 Jun 2026 16:59:51 +0800 (CST) Message-ID: Date: Sat, 13 Jun 2026 16:59:49 +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: [PATCH v8 next 04/10 Resend v2] arm_mpam: Refactor rmid to reqPARTID/PMG mapping Content-Language: en-US References: <924fbfbc-995f-e291-8849-efcb8e01ef98@huawei.com> From: Zeng Heng To: James Morse , ben.horgan@arm.com, Dave.Martin@arm.com, tan.shaopeng@jp.fujitsu.com, reinette.chatre@intel.com, fenghuay@nvidia.com, tglx@kernel.org, will@kernel.org, hpa@zytor.com, bp@alien8.de, babu.moger@amd.com, dave.hansen@linux.intel.com, mingo@redhat.com, tony.luck@intel.com, gshan@redhat.com, catalin.marinas@arm.com Cc: linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-kernel@vger.kernel.org, Kefeng Wang , sunnanyong@huawei.com In-Reply-To: <924fbfbc-995f-e291-8849-efcb8e01ef98@huawei.com> X-Forwarded-Message-Id: <924fbfbc-995f-e291-8849-efcb8e01ef98@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID:cCh0CgB3ej8FHC1qecmJBg--.8230S3 X-Coremail-Antispam: 1UD129KBjvJXoWxJF48Cry7XF4DAw1DKFWxWFg_yoWrCF45pr 4fKw47tF1DGF15W3srJa18Xw18JrZ3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l_mon *mon, struct mpam_component *mon_c >> enum resctrl_conf_type cdp_type, u32 closid, u32 rmid, u64 *val) >> { >> struct mon_cfg cfg; >> + u32 reqpartid = rmid2reqpartid(rmid); >> >> if (!mpam_is_enabled()) >> return -EINVAL; >> @@ -493,8 +534,8 @@ static int __read_mon(struct mpam_resctrl_mon *mon, struct mpam_component *mon_c >> cfg = (struct mon_cfg) { >> .mon = mon_idx, >> .match_pmg = true, >> - .partid = closid, >> - .pmg = rmid, >> + .partid = (cdp_type == CDP_CODE) ? reqpartid + 1 : reqpartid, >> + .pmg = rmid2pmg(rmid), > > Not using the CLOSID here breaks multiple control groups. > After carefully reviewing your comments and Martin's patch series, I tried to understand why there's insistence that CLOSID information is necessary to support multiple control groups, but that's actually not the case. Before proceeding, allow me to introduce CPARTID (control partition ID, no longer borrowing the intPARTID concept). All partids_per_closid PARTIDs associated with it share the same control scheme under this CPARTID. Each PARTID within the partids_per_closid associated with a CPARTID is called MPARTID (monitor partition ID, no longer borrowing the reqPARTID concept). It refers to the PARTID used to represent different monitoring groups under the same control scheme. I've summarized the ID conversion diagrams from you and Martin as follows: +-------------------------+-----+------------------+ | CLOSID |{CDP}| RMID | +-------------------------+-----+------------+-----+ | MPARTID | PMG | +-------------------------------+------------+ | | MPARTID_hi (base_partid) : MPARTID_lo | | +-------------------------------+------------+-----+ Where (closid|cdp) = base_partid, rmid = mpartid_lo * pmg_num + pmg, and mpartid = base_partid * partids_per_closid + mpartid_lo, with mpartid_lo in the range [0, partids_per_closid). In this scheme, CLOSID and RMID are coupled together to form MPARTID, which represents the monitor group PARTID. In current patchset design, decoupling CLOSID and RMID, letting them represent CPARTID and (MPARTID,PMG) pair respectively, rather than having RMID depend on CLOSID to derive MPARTID. This decoupling is essential for future dynamic allocation, because the relationship between MPARTID and CPARTID must rely on table lookup rather than linear mapping. If don't decouple in the static allocation design, we would need another refactor when considering dynamic allocation extensibility. +-------------------------------------------+-----+ | CLOSID |{CDP}| +-------------------------------------------+-----+ | CPARTID (base_partid) | +-------------------------------------------------+ +-----------------------------------+-----+-------+ | RMID_hi |{CDP}|RMID_lo| +-----------------------------------+-----+-------+ | MPARTID | PMG | +--------------+--------------------------+ | | MPARTID_hi : MPARTID_lo (base_partid) | | +--------------+--------------------------+-------+ Where (closid|cdp) = base_partid, rmid_lo = pmg, and (rmid_hi|cdp) = mpartid = mpartid_hi * (partid_num / partids_per_closid) + base_partid, with mpartid_hi in the range [0, partids_per_closid). The reason of using base_partid as MPARTID_lo is to keep base_partid contiguous and CLOSIDs are allocated contiguously. This does mean MPARTIDs under the same CPARTID won't be contiguous, but that's inherently difficult to guarantee with dynamic allocation anyway. The control path uses CLOSID alone (CPARTID), and the monitor path uses RMID alone (the (MPARTID, PMG) pair). This definition also aligns closely with the native resctrl concepts: CLOSID (Class of Service ID, corresponding to CPARTID) and RMID (Resource Monitor ID, corresponding to the (MPARTID, PMG) pair). In the end, the number of control groups is determined by the number of CPARTIDs. Both of these ID translation schemes support multiple control groups. Could you please help outline the pros and cons of each approach? This will determine which direction I take for subsequent iterations. Thanks in advance. Best Regards, Zeng Heng