arm64/mpam: correct mbw_max/min if remainder is too large
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I61CPK CVE: NA -------------------------------- Writing bandwidth control value to /sys/fs/resctrl/schemata may return an incorrect value. For instance: $ cat /sys/fs/resctrl/schemata L3:0=7fff;1=7fff;2=7fff;3=7fff MB:0=100;1=100;2=100;3=100 $ echo 'MB:0=20' > /sys/fs/resctrl/schemata $ cat /sys/fs/resctrl/schemata L3:0=7fff;1=7fff;2=7fff;3=7fff MB:0=18;1=100;2=100;3=100 Assuming that bwa_wd(given in MPAMF_MBW_IDR.BWA_WD) is greater than or equal to 6 (fraction is 64), we can divide mbw_max/min with a granularity of at least 2 in the range between 0 to 100, if we calculate mbw_max/min with this formula1: mbw_max/min = (Input * range) / Scale Then we turn to ask for Input with this formula2: Input = (mbw_max/min * Scale) / range But if calculated deviation is too large in formula1, we can no longer use formula2 to get our original value at a granularity of 2. Therefore, we need to correct the calculation result of formula1. Signed-off-by: NWang ShaoBo <bobo.shaobowang@huawei.com> Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com> Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com> Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Showing
想要评论请 注册 或 登录