From: Wang ShaoBo bobo.shaobowang@huawei.com
hulk inclusion category: feature bugzilla: 34278 CVE: NA
-------------------------------------------------
This supports cdpl2,cdpl3 parameters for mount options, some other options including capabilities' feature such as priority and hardlimit will be supported in the future, a simple example like this.
e.g.
mount -t resctrl resctrl /sys/fs/resctrl -o cdpl3 cd /sys/fs/resctrl && cat schemata
L3CODE:0=7fff;1=7fff;2=7fff;3=7fff L3CODE:0=7fff;1=7fff;2=7fff;3=7fff MB:0=100;1=100;2=100;3=100
Note that we only complete this part interface adaption, not mean cdp is supported currently.
Signed-off-by: Wang ShaoBo bobo.shaobowang@huawei.com Reviewed-by: Xiongfeng Wang wangxiongfeng2@huawei.com Reviewed-by: Cheng Jian cj.chengjian@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com Signed-off-by: Cheng Jian cj.chengjian@huawei.com --- arch/arm64/kernel/mpam/mpam_resctrl.c | 73 +++++++++++++++++++++++++++ 1 file changed, 73 insertions(+)
diff --git a/arch/arm64/kernel/mpam/mpam_resctrl.c b/arch/arm64/kernel/mpam/mpam_resctrl.c index 8fd5c84f28bd..aa7a3d1402ec 100644 --- a/arch/arm64/kernel/mpam/mpam_resctrl.c +++ b/arch/arm64/kernel/mpam/mpam_resctrl.c @@ -75,6 +75,12 @@ bool rdt_alloc_capable; * Indicate the max number of monitor supported. */ static u32 max_mon_num; + +/* + * Indicate if had mount cdpl2/cdpl3 option. + */ +static bool resctrl_cdp_enabled; + /* * Hi1620 2P Base Address Map * @@ -433,9 +439,76 @@ void release_rdtgroupfs_options(void) { }
+static void disable_cdp(void) +{ + struct mpam_resctrl_res *res; + struct resctrl_resource *r; + + for_each_supported_resctrl_exports(res) { + r = &res->resctrl_res; + r->cdp_enable = false; + } + + resctrl_cdp_enabled = false; +} + +static int try_to_enable_cdp(enum resctrl_resource_level level) +{ + struct resctrl_resource *r = mpam_resctrl_get_resource(level); + + if (!r || !r->cdp_capable) + return -EINVAL; + + r->cdp_enable = true; + + resctrl_cdp_enabled = true; + return 0; +} + +static int cdpl3_enable(void) +{ + return try_to_enable_cdp(RDT_RESOURCE_L3); +} + +static int cdpl2_enable(void) +{ + return try_to_enable_cdp(RDT_RESOURCE_L2); +} + int parse_rdtgroupfs_options(char *data) { + char *token; + char *o = data; + int ret = 0; + + disable_cdp(); + + while ((token = strsep(&o, ",")) != NULL) { + if (!*token) { + ret = -EINVAL; + goto out; + } + + if (!strcmp(token, "cdpl3")) { + ret = cdpl3_enable(); + if (ret) + goto out; + } else if (!strcmp(token, "cdpl2")) { + ret = cdpl2_enable(); + if (ret) + goto out; + } else { + ret = -EINVAL; + goto out; + } + } + return 0; + +out: + pr_err("Invalid mount option "%s"\n", token); + + return ret; }
/*