Commit d46f85d3 authored by Wang ShaoBo's avatar Wang ShaoBo Committed by Zheng Zengkai
Browse files

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: default avatarWang ShaoBo <bobo.shaobowang@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
Reviewed-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent cf62a86b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment