Skip to content

Commit 9b2a38d

Browse files
Xin Haotorvalds
authored andcommitted
mm/damon: move damon_rand() definition into damon.h
damon_rand() is called in three files:damon/core.c, damon/ paddr.c, damon/vaddr.c, i think there is no need to redefine this twice, So move it to damon.h will be a good choice. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Xin Hao <[email protected]> Reviewed-by: SeongJae Park <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent c89ae63 commit 9b2a38d

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

include/linux/damon.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@
1111
#include <linux/mutex.h>
1212
#include <linux/time64.h>
1313
#include <linux/types.h>
14+
#include <linux/random.h>
1415

1516
/* Minimal region size. Every damon_region is aligned by this. */
1617
#define DAMON_MIN_REGION PAGE_SIZE
1718
/* Max priority score for DAMON-based operation schemes */
1819
#define DAMOS_MAX_SCORE (99)
1920

21+
/* Get a random number in [l, r) */
22+
#define damon_rand(l, r) (l + prandom_u32_max(r - l))
23+
2024
/**
2125
* struct damon_addr_range - Represents an address region of [@start, @end).
2226
* @start: Start address of the region (inclusive).

mm/damon/core.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/delay.h>
1212
#include <linux/kthread.h>
1313
#include <linux/mm.h>
14-
#include <linux/random.h>
1514
#include <linux/slab.h>
1615
#include <linux/string.h>
1716

@@ -23,9 +22,6 @@
2322
#define DAMON_MIN_REGION 1
2423
#endif
2524

26-
/* Get a random number in [l, r) */
27-
#define damon_rand(l, r) (l + prandom_u32_max(r - l))
28-
2925
static DEFINE_MUTEX(damon_lock);
3026
static int nr_running_ctxs;
3127

mm/damon/prmtv-common.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
*/
77

88
#include <linux/damon.h>
9-
#include <linux/random.h>
10-
11-
/* Get a random number in [l, r) */
12-
#define damon_rand(l, r) (l + prandom_u32_max(r - l))
139

1410
struct page *damon_get_page(unsigned long pfn);
1511

0 commit comments

Comments
 (0)