Skip to content

Commit 234d687

Browse files
Xin Haotorvalds
authored andcommitted
mm/damon: modify damon_rand() macro to static inline function
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.1638795127.git.xhao@linux.alibaba.com Fixes: b9a6ac4 ("mm/damon: adaptively adjust regions") Signed-off-by: Xin Hao <[email protected]> Reported-by: Andrew Morton <[email protected]> Reviewed-by: SeongJae Park <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 9b2a38d commit 234d687

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

include/linux/damon.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
#define DAMOS_MAX_SCORE (99)
2020

2121
/* Get a random number in [l, r) */
22-
#define damon_rand(l, r) (l + prandom_u32_max(r - l))
22+
static inline unsigned long damon_rand(unsigned long l, unsigned long r)
23+
{
24+
return l + prandom_u32_max(r - l);
25+
}
2326

2427
/**
2528
* struct damon_addr_range - Represents an address region of [@start, @end).

0 commit comments

Comments
 (0)