linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Xin Hao <xhao@linux.alibaba.com>
Cc: sj@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH V1] mm/damon: Modify damon_rand() macro to static inline function
Date: Mon,  6 Dec 2021 12:45:23 +0000	[thread overview]
Message-ID: <20211206124523.6259-1-sj@kernel.org> (raw)
In-Reply-To: <7066b07ba4f89e32c5264ed1f7d71260bea8812e.1638794380.git.xhao@linux.alibaba.com>

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


  reply	other threads:[~2021-12-06 12:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-06 12:41 Xin Hao
2021-12-06 12:45 ` SeongJae Park [this message]
2021-12-06 12:48   ` Xin Hao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211206124523.6259-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=xhao@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox