[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260113145955.00005ed7@huawei.com>
Date: Tue, 13 Jan 2026 14:59:55 +0000
From: Jonathan Cameron <jonathan.cameron@...wei.com>
To: Ben Horgan <ben.horgan@....com>
CC: <amitsinght@...vell.com>, <baisheng.gao@...soc.com>,
<baolin.wang@...ux.alibaba.com>, <carl@...amperecomputing.com>,
<dave.martin@....com>, <david@...nel.org>, <dfustini@...libre.com>,
<fenghuay@...dia.com>, <gshan@...hat.com>, <james.morse@....com>,
<kobak@...dia.com>, <lcherian@...vell.com>,
<linux-arm-kernel@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
<peternewman@...gle.com>, <punit.agrawal@....qualcomm.com>,
<quic_jiles@...cinc.com>, <reinette.chatre@...el.com>,
<rohit.mathew@....com>, <scott@...amperecomputing.com>,
<sdonthineni@...dia.com>, <tan.shaopeng@...itsu.com>,
<xhao@...ux.alibaba.com>, <catalin.marinas@....com>, <will@...nel.org>,
<corbet@....net>, <maz@...nel.org>, <oupton@...nel.org>,
<joey.gouly@....com>, <suzuki.poulose@....com>, <kvmarm@...ts.linux.dev>
Subject: Re: [PATCH v3 25/47] arm_mpam: resctrl: Add kunit test for rmid idx
conversions
On Mon, 12 Jan 2026 16:58:52 +0000
Ben Horgan <ben.horgan@....com> wrote:
> As MPAM's pmg are scoped by partid and RDT's rmid are global the
> rescrl mapping to an index needs to differ.
>
> Add some tests for the MPAM rmid mapping.
>
> Signed-off-by: Ben Horgan <ben.horgan@....com>
I'm not sure this particular test brings a massive amount of value, but
I'm not one to object to more tests!
Reviewed-by: Jonathan Cameron <jonathan.cameron@...wei.com>
> ---
> drivers/resctrl/test_mpam_resctrl.c | 49 +++++++++++++++++++++++++++++
> 1 file changed, 49 insertions(+)
>
> diff --git a/drivers/resctrl/test_mpam_resctrl.c b/drivers/resctrl/test_mpam_resctrl.c
> index b93d6ad87e43..a20da161d965 100644
> --- a/drivers/resctrl/test_mpam_resctrl.c
> +++ b/drivers/resctrl/test_mpam_resctrl.c
> @@ -296,6 +296,54 @@ static void test_percent_to_max_rounding(struct kunit *test)
> KUNIT_EXPECT_LE(test, 4 * num_rounded_up, 3 * total);
> }
>
> +struct rmid_idx_case {
> + u32 max_partid;
> + u32 max_pmg;
> +};
> +
> +static const struct rmid_idx_case rmid_idx_cases[] = {
> + {0, 0}, {1, 4}, {3, 1}, {5, 9}, {4, 4}, {100, 11}, {0xFFFF, 0xFF},
> +};
> +
> +static void test_rmid_idx_desc(const struct rmid_idx_case *param, char *desc)
> +{
> + snprintf(desc, KUNIT_PARAM_DESC_SIZE, "max_partid=%d, max_pmg=%d\n",
> + param->max_partid, param->max_pmg);
> +}
> +
> +KUNIT_ARRAY_PARAM(test_rmid_idx, rmid_idx_cases, test_rmid_idx_desc);
> +
> +static void test_rmid_idx_encoding(struct kunit *test)
> +{
> + u32 orig_mpam_partid_max = mpam_partid_max;
> + u32 orig_mpam_pmg_max = mpam_pmg_max;
> + const struct rmid_idx_case *param = test->param_value;
> + u32 idx, num_idx, count = 0;
> +
> + mpam_partid_max = param->max_partid;
> + mpam_pmg_max = param->max_pmg;
> +
> + for (u32 partid = 0; partid <= mpam_partid_max; partid++) {
> + for (u32 pmg = 0; pmg <= mpam_pmg_max; pmg++) {
> + u32 partid_out, pmg_out;
> +
> + idx = resctrl_arch_rmid_idx_encode(partid, pmg);
> + /* Confirm there are no holes in the rmid idx range */
> + KUNIT_EXPECT_EQ(test, count, idx);
> + count++;
> + resctrl_arch_rmid_idx_decode(idx, &partid_out, &pmg_out);
> + KUNIT_EXPECT_EQ(test, pmg, pmg_out);
> + KUNIT_EXPECT_EQ(test, partid, partid_out);
> + }
> + }
> + num_idx = resctrl_arch_system_num_rmid_idx();
> + KUNIT_EXPECT_EQ(test, idx + 1, num_idx);
> +
> + /* Restore global variables that were messed with */
> + mpam_partid_max = orig_mpam_partid_max;
> + mpam_pmg_max = orig_mpam_pmg_max;
> +}
Powered by blists - more mailing lists