From: Wang ShaoBo bobo.shaobowang@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7SVKK
--------------------------------
MPAM manages RMID in a matrix using PARTID as columns and PMG as rows.
------------row----------------------> | | RMID 0 1 2 3 ... 255 | 256 257 258 259 ... 511 | 512 513 514 515 ... 767 v 768 769 770 771 ... 1023
Each time mon_groups is created, a new PARTID will be consumed until all PARTID are exhausted and PMG still has remaining. As a result, RMID greater than 255 cannot be used. mon_groups in the same resource group should reuse PARTID to avoid rmid waste.
Fix it by adding 'exclusive' parameter to rmid_remap_bmp_find_step_entry() 1) Allocate non-exclusive rmid for rmid_alloc() 2) Allocate exclusive rmid when 'partid = old_reqpartid' for resctrl_group_rmid_write(). Otherwise, allocate non-exclusive rmid.
Signed-off-by: Wang ShaoBo bobo.shaobowang@huawei.com Signed-off-by: Yu Liao liaoyu15@huawei.com --- arch/arm64/kernel/mpam/mpam_resctrl.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/arch/arm64/kernel/mpam/mpam_resctrl.c b/arch/arm64/kernel/mpam/mpam_resctrl.c index 4a1e376ec497..bb241d8071d7 100644 --- a/arch/arm64/kernel/mpam/mpam_resctrl.c +++ b/arch/arm64/kernel/mpam/mpam_resctrl.c @@ -919,7 +919,7 @@ static int is_rmid_remap_bmp_full(unsigned long *bmp) bitmap_full(bmp, rmid_remap_matrix.rows)); }
-static int rmid_remap_bmp_find_step_entry(int partid) +static int rmid_remap_bmp_find_step_entry(int partid, bool exclusive) { int x, y; unsigned long **bmp; @@ -931,7 +931,7 @@ static int rmid_remap_bmp_find_step_entry(int partid) /* step entry should be non-occupied and aligned */ bmp = __rmid_remap_bmp(partid); if (bmp) - return (is_rmid_remap_bmp_occ(*bmp) || + return ((exclusive && is_rmid_remap_bmp_occ(*bmp)) || !__step_align(partid)) ? -ENOSPC : partid;
for_each_rmid_transform_point_from(bmp, x, y, 0) { @@ -1024,7 +1024,7 @@ static int rmid_to_partid_pmg(int rmid, int *partid, int *pmg) return 0; }
-static int __rmid_alloc(int partid, int pmg) +static int __rmid_alloc(int partid, int pmg, bool exclusive) { int x, y, step, ret, rmid; bool checkpmg = false; @@ -1034,7 +1034,7 @@ static int __rmid_alloc(int partid, int pmg) checkpmg = true;
/* traverse from first non-occupied and step-aligned entry */ - ret = rmid_remap_bmp_find_step_entry(partid); + ret = rmid_remap_bmp_find_step_entry(partid, exclusive); if (ret < 0) goto out; partid = ret; @@ -1084,7 +1084,7 @@ static int __rmid_alloc(int partid, int pmg)
int rmid_alloc(int partid) { - return __rmid_alloc(partid, -1); + return __rmid_alloc(partid, -1, false); }
void rmid_free(int rmid) @@ -1914,6 +1914,7 @@ static ssize_t resctrl_group_rmid_write(struct kernfs_open_file *of, struct rdtgroup *rdtgrp; int ret = 0; int partid; + bool exclusive; int pmg; int rmid; int old_rmid; @@ -1954,15 +1955,16 @@ static ssize_t resctrl_group_rmid_write(struct kernfs_open_file *of, goto unlock; }
- ret = __rmid_alloc(partid, pmg); + old_rmid = rdtgrp->mon.rmid; + old_reqpartid = rdtgrp->closid.reqpartid; + + exclusive = (partid == old_reqpartid) ? false : true; + ret = __rmid_alloc(partid, pmg, exclusive); if (ret < 0) { rdt_last_cmd_puts("set rmid failed\n"); goto unlock; }
- old_rmid = rdtgrp->mon.rmid; - old_reqpartid = rdtgrp->closid.reqpartid; - /* * we use intpartid as group control, use reqpartid for config * synchronization and monitor, only update the reqpartid
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/1734 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/A...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/1734 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/A...