lkml.org 
[lkml]   [2021]   [Dec]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH V1] mm/damon: Modify damon_rand() macro to static inline function
Date
On Mon, 6 Dec 2021 20:41:29 +0800 Xin Hao <xhao@linux.alibaba.com> wrote:

> The damon_rand() func can not 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.
>
> Fixes: b9a6ac4e4ede ("mm/damon: adaptively adjust regions")
> Reported-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Xin Hao <xhao@linux.alibaba.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 c6df025d8704..bc9c8932b1e8 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 + (r - l);

Seems prandom_u32_max() is missed?


Thanks,
SJ

> +}
>
> /**
> * struct damon_addr_range - Represents an address region of [@start, @end).
> --
> 2.31.0

\
 
 \ /
  Last update: 2021-12-06 13:46    [W:0.052 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site