From: Xin Hao xhao@linux.alibaba.com
mainline inclusion from mainline-v5.17-rc1 commit 234d68732b6c135087bdebfa0630a43ae8c27758 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4RTX9
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
--------------------------------
damon_rand() cannot be implemented as a macro.
Example: damon_rand(a++, b);
The value of 'a' will be incremented twice, This is obviously unreasonable, So there fix it.
Link: https://lkml.kernel.org/r/110ffcd4e420c86c42b41ce2bc9f0fe6a4f32cd3.163879512... Fixes: b9a6ac4e4ede ("mm/damon: adaptively adjust regions") Signed-off-by: Xin Hao xhao@linux.alibaba.com Reported-by: Andrew Morton akpm@linux-foundation.org Reviewed-by: SeongJae Park sj@kernel.org Signed-off-by: Andrew Morton akpm@linux-foundation.org Signed-off-by: Linus Torvalds torvalds@linux-foundation.org (cherry picked from commit 234d68732b6c135087bdebfa0630a43ae8c27758) Signed-off-by: Yue Zou zouyue3@huawei.com Reviewed-by: Kefeng Wangwangkefeng.wang@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- include/linux/damon.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/linux/damon.h b/include/linux/damon.h index 3e91a597a1aa..e2c8152985b7 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -19,7 +19,10 @@ #define DAMOS_MAX_SCORE (99)
/* Get a random number in [l, r) */ -#define damon_rand(l, r) (l + prandom_u32_max(r - l)) +static inline unsigned long damon_rand(unsigned long l, unsigned long r) +{ + return l + prandom_u32_max(r - l); +}
/** * struct damon_addr_range - Represents an address region of [@start, @end).