Commit 3b7f6009 authored by Yu Liao's avatar Yu Liao
Browse files

arm64/mpam: Fix wrong seconds to jiffies conversion

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9SXQ8



--------------------------------

According to the comment:

  jiff = (sec) * (NSEC_PER_SEC / NSEC_PER_JIFFIE);
  jiff = ((sec) * ((NSEC_PER_SEC * SCALE)/ NSEC_PER_JIFFIE)) / SCALE;
  Then we make SCALE a power of two so:
  jiff = ((sec) * ((NSEC_PER_SEC << SCALE)/ NSEC_PER_JIFFIE)) >> SCALE;
  Now we define:
  #define SEC_CONV = ((NSEC_PER_SEC << SCALE)/ NSEC_PER_JIFFIE))
  jiff = (sec * SEC_CONV) >> SCALE;

Fix the incorrect seconds to jiffies conversion.

Fixes: 8d7469cd ("arm64/mpam: Integrate monitor data for Memory Bandwidth if cdp enabled")
Signed-off-by: default avatarYu Liao <liaoyu15@huawei.com>
parent 281b97e7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -468,7 +468,7 @@ static u64 cache_rdmon(struct rdt_domain *d, void *md_priv)
	 * We should judge if return is OK, it is possible affected
	 * by NRDY bit.
	 */
	timeout = READ_ONCE(jiffies) + (1*SEC_CONVERSION);
	timeout = READ_ONCE(jiffies) + msecs_to_jiffies(1000);
	do {
		if (time_after(READ_ONCE(jiffies), timeout)) {
			err = -ETIMEDOUT;
@@ -509,7 +509,7 @@ static u64 mbw_rdmon(struct rdt_domain *d, void *md_priv)
	 * We should judge if return is OK, it is possible affected
	 * by NRDY bit.
	 */
	timeout = READ_ONCE(jiffies) + (1*SEC_CONVERSION);
	timeout = READ_ONCE(jiffies) + msecs_to_jiffies(1000);
	do {
		if (time_after(READ_ONCE(jiffies), timeout)) {
			err = -ETIMEDOUT;