2022-08-12 07:44:40

by Kaixu Xia

[permalink] [raw]
Subject: [PATCH] mm/damon/core: simplify the parameter passing for region split operation

From: Kaixu Xia <[email protected]>

The parameter 'struct damon_target *t' is unnecessary in damon region
split operation, so we can remove it.

Signed-off-by: Kaixu Xia <[email protected]>
---
mm/damon/core.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 7d25dc582fe3..9964b9d00768 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -658,9 +658,8 @@ static void kdamond_reset_aggregated(struct damon_ctx *c)
}
}

-static void damon_split_region_at(struct damon_ctx *ctx,
- struct damon_target *t, struct damon_region *r,
- unsigned long sz_r);
+static void damon_split_region_at(struct damon_target *t,
+ struct damon_region *r, unsigned long sz_r);

static bool __damos_valid_target(struct damon_region *r, struct damos *s)
{
@@ -726,7 +725,7 @@ static void damon_do_apply_schemes(struct damon_ctx *c,
continue;
sz = DAMON_MIN_REGION;
}
- damon_split_region_at(c, t, r, sz);
+ damon_split_region_at(t, r, sz);
r = damon_next_region(r);
sz = r->ar.end - r->ar.start;
}
@@ -745,7 +744,7 @@ static void damon_do_apply_schemes(struct damon_ctx *c,
DAMON_MIN_REGION);
if (!sz)
goto update_stat;
- damon_split_region_at(c, t, r, sz);
+ damon_split_region_at(t, r, sz);
}
ktime_get_coarse_ts64(&begin);
sz_applied = c->ops.apply_scheme(c, t, r, s);
@@ -928,9 +927,8 @@ static void kdamond_merge_regions(struct damon_ctx *c, unsigned int threshold,
* r the region to be split
* sz_r size of the first sub-region that will be made
*/
-static void damon_split_region_at(struct damon_ctx *ctx,
- struct damon_target *t, struct damon_region *r,
- unsigned long sz_r)
+static void damon_split_region_at(struct damon_target *t,
+ struct damon_region *r, unsigned long sz_r)
{
struct damon_region *new;

@@ -947,8 +945,7 @@ static void damon_split_region_at(struct damon_ctx *ctx,
}

/* Split every region in the given target into 'nr_subs' regions */
-static void damon_split_regions_of(struct damon_ctx *ctx,
- struct damon_target *t, int nr_subs)
+static void damon_split_regions_of(struct damon_target *t, int nr_subs)
{
struct damon_region *r, *next;
unsigned long sz_region, sz_sub = 0;
@@ -969,7 +966,7 @@ static void damon_split_regions_of(struct damon_ctx *ctx,
if (sz_sub == 0 || sz_sub >= sz_region)
continue;

- damon_split_region_at(ctx, t, r, sz_sub);
+ damon_split_region_at(t, r, sz_sub);
sz_region = sz_sub;
}
}
@@ -1004,7 +1001,7 @@ static void kdamond_split_regions(struct damon_ctx *ctx)
nr_subregions = 3;

damon_for_each_target(t, ctx)
- damon_split_regions_of(ctx, t, nr_subregions);
+ damon_split_regions_of(t, nr_subregions);

last_nr_regions = nr_regions;
}
--
2.27.0


2022-08-12 11:17:49

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] mm/damon/core: simplify the parameter passing for region split operation

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on akpm-mm/mm-everything]

url: https://github.com/intel-lab-lkp/linux/commits/xiakaixu1987-gmail-com/mm-damon-core-simplify-the-parameter-passing-for-region-split-operation/20220812-154316
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20220812/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/26b7d93b0f64c71d6d324a4a37d85641b55eaec2
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review xiakaixu1987-gmail-com/mm-damon-core-simplify-the-parameter-passing-for-region-split-operation/20220812-154316
git checkout 26b7d93b0f64c71d6d324a4a37d85641b55eaec2
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash mm/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

In file included from mm/damon/core.c:1218:
mm/damon/core-test.h: In function 'damon_test_split_at':
mm/damon/core-test.h:129:31: error: passing argument 1 of 'damon_split_region_at' from incompatible pointer type [-Werror=incompatible-pointer-types]
129 | damon_split_region_at(c, t, r, 25);
| ^
| |
| struct damon_ctx *
mm/damon/core.c:930:56: note: expected 'struct damon_target *' but argument is of type 'struct damon_ctx *'
930 | static void damon_split_region_at(struct damon_target *t,
| ~~~~~~~~~~~~~~~~~~~~~^
In file included from mm/damon/core.c:1218:
mm/damon/core-test.h:129:34: error: passing argument 2 of 'damon_split_region_at' from incompatible pointer type [-Werror=incompatible-pointer-types]
129 | damon_split_region_at(c, t, r, 25);
| ^
| |
| struct damon_target *
mm/damon/core.c:931:56: note: expected 'struct damon_region *' but argument is of type 'struct damon_target *'
931 | struct damon_region *r, unsigned long sz_r)
| ~~~~~~~~~~~~~~~~~~~~~^
In file included from mm/damon/core.c:1218:
>> mm/damon/core-test.h:129:37: warning: passing argument 3 of 'damon_split_region_at' makes integer from pointer without a cast [-Wint-conversion]
129 | damon_split_region_at(c, t, r, 25);
| ^
| |
| struct damon_region *
mm/damon/core.c:931:73: note: expected 'long unsigned int' but argument is of type 'struct damon_region *'
931 | struct damon_region *r, unsigned long sz_r)
| ~~~~~~~~~~~~~~^~~~
In file included from mm/damon/core.c:1218:
mm/damon/core-test.h:129:9: error: too many arguments to function 'damon_split_region_at'
129 | damon_split_region_at(c, t, r, 25);
| ^~~~~~~~~~~~~~~~~~~~~
mm/damon/core.c:930:13: note: declared here
930 | static void damon_split_region_at(struct damon_target *t,
| ^~~~~~~~~~~~~~~~~~~~~
In file included from mm/damon/core.c:1218:
mm/damon/core-test.h: In function 'damon_test_split_regions_of':
mm/damon/core-test.h:222:32: error: passing argument 1 of 'damon_split_regions_of' from incompatible pointer type [-Werror=incompatible-pointer-types]
222 | damon_split_regions_of(c, t, 2);
| ^
| |
| struct damon_ctx *
mm/damon/core.c:948:57: note: expected 'struct damon_target *' but argument is of type 'struct damon_ctx *'
948 | static void damon_split_regions_of(struct damon_target *t, int nr_subs)
| ~~~~~~~~~~~~~~~~~~~~~^
In file included from mm/damon/core.c:1218:
>> mm/damon/core-test.h:222:35: warning: passing argument 2 of 'damon_split_regions_of' makes integer from pointer without a cast [-Wint-conversion]
222 | damon_split_regions_of(c, t, 2);
| ^
| |
| struct damon_target *
mm/damon/core.c:948:64: note: expected 'int' but argument is of type 'struct damon_target *'
948 | static void damon_split_regions_of(struct damon_target *t, int nr_subs)
| ~~~~^~~~~~~
In file included from mm/damon/core.c:1218:
mm/damon/core-test.h:222:9: error: too many arguments to function 'damon_split_regions_of'
222 | damon_split_regions_of(c, t, 2);
| ^~~~~~~~~~~~~~~~~~~~~~
mm/damon/core.c:948:13: note: declared here
948 | static void damon_split_regions_of(struct damon_target *t, int nr_subs)
| ^~~~~~~~~~~~~~~~~~~~~~
In file included from mm/damon/core.c:1218:
mm/damon/core-test.h:229:32: error: passing argument 1 of 'damon_split_regions_of' from incompatible pointer type [-Werror=incompatible-pointer-types]
229 | damon_split_regions_of(c, t, 4);
| ^
| |
| struct damon_ctx *
mm/damon/core.c:948:57: note: expected 'struct damon_target *' but argument is of type 'struct damon_ctx *'
948 | static void damon_split_regions_of(struct damon_target *t, int nr_subs)
| ~~~~~~~~~~~~~~~~~~~~~^
In file included from mm/damon/core.c:1218:
mm/damon/core-test.h:229:35: warning: passing argument 2 of 'damon_split_regions_of' makes integer from pointer without a cast [-Wint-conversion]
229 | damon_split_regions_of(c, t, 4);
| ^
| |
| struct damon_target *
mm/damon/core.c:948:64: note: expected 'int' but argument is of type 'struct damon_target *'
948 | static void damon_split_regions_of(struct damon_target *t, int nr_subs)
| ~~~~^~~~~~~
In file included from mm/damon/core.c:1218:
mm/damon/core-test.h:229:9: error: too many arguments to function 'damon_split_regions_of'
229 | damon_split_regions_of(c, t, 4);
| ^~~~~~~~~~~~~~~~~~~~~~
mm/damon/core.c:948:13: note: declared here
948 | static void damon_split_regions_of(struct damon_target *t, int nr_subs)
| ^~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors


vim +/damon_split_region_at +129 mm/damon/core-test.h

17ccae8bb5c9289 SeongJae Park 2021-09-07 119
17ccae8bb5c9289 SeongJae Park 2021-09-07 120 static void damon_test_split_at(struct kunit *test)
17ccae8bb5c9289 SeongJae Park 2021-09-07 121 {
17ccae8bb5c9289 SeongJae Park 2021-09-07 122 struct damon_ctx *c = damon_new_ctx();
17ccae8bb5c9289 SeongJae Park 2021-09-07 123 struct damon_target *t;
17ccae8bb5c9289 SeongJae Park 2021-09-07 124 struct damon_region *r;
17ccae8bb5c9289 SeongJae Park 2021-09-07 125
1971bd630452e94 SeongJae Park 2022-03-22 126 t = damon_new_target();
17ccae8bb5c9289 SeongJae Park 2021-09-07 127 r = damon_new_region(0, 100);
17ccae8bb5c9289 SeongJae Park 2021-09-07 128 damon_add_region(r, t);
17ccae8bb5c9289 SeongJae Park 2021-09-07 @129 damon_split_region_at(c, t, r, 25);
17ccae8bb5c9289 SeongJae Park 2021-09-07 130 KUNIT_EXPECT_EQ(test, r->ar.start, 0ul);
17ccae8bb5c9289 SeongJae Park 2021-09-07 131 KUNIT_EXPECT_EQ(test, r->ar.end, 25ul);
17ccae8bb5c9289 SeongJae Park 2021-09-07 132
17ccae8bb5c9289 SeongJae Park 2021-09-07 133 r = damon_next_region(r);
17ccae8bb5c9289 SeongJae Park 2021-09-07 134 KUNIT_EXPECT_EQ(test, r->ar.start, 25ul);
17ccae8bb5c9289 SeongJae Park 2021-09-07 135 KUNIT_EXPECT_EQ(test, r->ar.end, 100ul);
17ccae8bb5c9289 SeongJae Park 2021-09-07 136
17ccae8bb5c9289 SeongJae Park 2021-09-07 137 damon_free_target(t);
17ccae8bb5c9289 SeongJae Park 2021-09-07 138 damon_destroy_ctx(c);
17ccae8bb5c9289 SeongJae Park 2021-09-07 139 }
17ccae8bb5c9289 SeongJae Park 2021-09-07 140
17ccae8bb5c9289 SeongJae Park 2021-09-07 141 static void damon_test_merge_two(struct kunit *test)
17ccae8bb5c9289 SeongJae Park 2021-09-07 142 {
17ccae8bb5c9289 SeongJae Park 2021-09-07 143 struct damon_target *t;
17ccae8bb5c9289 SeongJae Park 2021-09-07 144 struct damon_region *r, *r2, *r3;
17ccae8bb5c9289 SeongJae Park 2021-09-07 145 int i;
17ccae8bb5c9289 SeongJae Park 2021-09-07 146
1971bd630452e94 SeongJae Park 2022-03-22 147 t = damon_new_target();
17ccae8bb5c9289 SeongJae Park 2021-09-07 148 r = damon_new_region(0, 100);
17ccae8bb5c9289 SeongJae Park 2021-09-07 149 r->nr_accesses = 10;
17ccae8bb5c9289 SeongJae Park 2021-09-07 150 damon_add_region(r, t);
17ccae8bb5c9289 SeongJae Park 2021-09-07 151 r2 = damon_new_region(100, 300);
17ccae8bb5c9289 SeongJae Park 2021-09-07 152 r2->nr_accesses = 20;
17ccae8bb5c9289 SeongJae Park 2021-09-07 153 damon_add_region(r2, t);
17ccae8bb5c9289 SeongJae Park 2021-09-07 154
17ccae8bb5c9289 SeongJae Park 2021-09-07 155 damon_merge_two_regions(t, r, r2);
17ccae8bb5c9289 SeongJae Park 2021-09-07 156 KUNIT_EXPECT_EQ(test, r->ar.start, 0ul);
17ccae8bb5c9289 SeongJae Park 2021-09-07 157 KUNIT_EXPECT_EQ(test, r->ar.end, 300ul);
17ccae8bb5c9289 SeongJae Park 2021-09-07 158 KUNIT_EXPECT_EQ(test, r->nr_accesses, 16u);
17ccae8bb5c9289 SeongJae Park 2021-09-07 159
17ccae8bb5c9289 SeongJae Park 2021-09-07 160 i = 0;
17ccae8bb5c9289 SeongJae Park 2021-09-07 161 damon_for_each_region(r3, t) {
17ccae8bb5c9289 SeongJae Park 2021-09-07 162 KUNIT_EXPECT_PTR_EQ(test, r, r3);
17ccae8bb5c9289 SeongJae Park 2021-09-07 163 i++;
17ccae8bb5c9289 SeongJae Park 2021-09-07 164 }
17ccae8bb5c9289 SeongJae Park 2021-09-07 165 KUNIT_EXPECT_EQ(test, i, 1);
17ccae8bb5c9289 SeongJae Park 2021-09-07 166
17ccae8bb5c9289 SeongJae Park 2021-09-07 167 damon_free_target(t);
17ccae8bb5c9289 SeongJae Park 2021-09-07 168 }
17ccae8bb5c9289 SeongJae Park 2021-09-07 169
17ccae8bb5c9289 SeongJae Park 2021-09-07 170 static struct damon_region *__nth_region_of(struct damon_target *t, int idx)
17ccae8bb5c9289 SeongJae Park 2021-09-07 171 {
17ccae8bb5c9289 SeongJae Park 2021-09-07 172 struct damon_region *r;
17ccae8bb5c9289 SeongJae Park 2021-09-07 173 unsigned int i = 0;
17ccae8bb5c9289 SeongJae Park 2021-09-07 174
17ccae8bb5c9289 SeongJae Park 2021-09-07 175 damon_for_each_region(r, t) {
17ccae8bb5c9289 SeongJae Park 2021-09-07 176 if (i++ == idx)
17ccae8bb5c9289 SeongJae Park 2021-09-07 177 return r;
17ccae8bb5c9289 SeongJae Park 2021-09-07 178 }
17ccae8bb5c9289 SeongJae Park 2021-09-07 179
17ccae8bb5c9289 SeongJae Park 2021-09-07 180 return NULL;
17ccae8bb5c9289 SeongJae Park 2021-09-07 181 }
17ccae8bb5c9289 SeongJae Park 2021-09-07 182
17ccae8bb5c9289 SeongJae Park 2021-09-07 183 static void damon_test_merge_regions_of(struct kunit *test)
17ccae8bb5c9289 SeongJae Park 2021-09-07 184 {
17ccae8bb5c9289 SeongJae Park 2021-09-07 185 struct damon_target *t;
17ccae8bb5c9289 SeongJae Park 2021-09-07 186 struct damon_region *r;
17ccae8bb5c9289 SeongJae Park 2021-09-07 187 unsigned long sa[] = {0, 100, 114, 122, 130, 156, 170, 184};
17ccae8bb5c9289 SeongJae Park 2021-09-07 188 unsigned long ea[] = {100, 112, 122, 130, 156, 170, 184, 230};
17ccae8bb5c9289 SeongJae Park 2021-09-07 189 unsigned int nrs[] = {0, 0, 10, 10, 20, 30, 1, 2};
17ccae8bb5c9289 SeongJae Park 2021-09-07 190
17ccae8bb5c9289 SeongJae Park 2021-09-07 191 unsigned long saddrs[] = {0, 114, 130, 156, 170};
17ccae8bb5c9289 SeongJae Park 2021-09-07 192 unsigned long eaddrs[] = {112, 130, 156, 170, 230};
17ccae8bb5c9289 SeongJae Park 2021-09-07 193 int i;
17ccae8bb5c9289 SeongJae Park 2021-09-07 194
1971bd630452e94 SeongJae Park 2022-03-22 195 t = damon_new_target();
17ccae8bb5c9289 SeongJae Park 2021-09-07 196 for (i = 0; i < ARRAY_SIZE(sa); i++) {
17ccae8bb5c9289 SeongJae Park 2021-09-07 197 r = damon_new_region(sa[i], ea[i]);
17ccae8bb5c9289 SeongJae Park 2021-09-07 198 r->nr_accesses = nrs[i];
17ccae8bb5c9289 SeongJae Park 2021-09-07 199 damon_add_region(r, t);
17ccae8bb5c9289 SeongJae Park 2021-09-07 200 }
17ccae8bb5c9289 SeongJae Park 2021-09-07 201
17ccae8bb5c9289 SeongJae Park 2021-09-07 202 damon_merge_regions_of(t, 9, 9999);
17ccae8bb5c9289 SeongJae Park 2021-09-07 203 /* 0-112, 114-130, 130-156, 156-170 */
17ccae8bb5c9289 SeongJae Park 2021-09-07 204 KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 5u);
17ccae8bb5c9289 SeongJae Park 2021-09-07 205 for (i = 0; i < 5; i++) {
17ccae8bb5c9289 SeongJae Park 2021-09-07 206 r = __nth_region_of(t, i);
17ccae8bb5c9289 SeongJae Park 2021-09-07 207 KUNIT_EXPECT_EQ(test, r->ar.start, saddrs[i]);
17ccae8bb5c9289 SeongJae Park 2021-09-07 208 KUNIT_EXPECT_EQ(test, r->ar.end, eaddrs[i]);
17ccae8bb5c9289 SeongJae Park 2021-09-07 209 }
17ccae8bb5c9289 SeongJae Park 2021-09-07 210 damon_free_target(t);
17ccae8bb5c9289 SeongJae Park 2021-09-07 211 }
17ccae8bb5c9289 SeongJae Park 2021-09-07 212
17ccae8bb5c9289 SeongJae Park 2021-09-07 213 static void damon_test_split_regions_of(struct kunit *test)
17ccae8bb5c9289 SeongJae Park 2021-09-07 214 {
17ccae8bb5c9289 SeongJae Park 2021-09-07 215 struct damon_ctx *c = damon_new_ctx();
17ccae8bb5c9289 SeongJae Park 2021-09-07 216 struct damon_target *t;
17ccae8bb5c9289 SeongJae Park 2021-09-07 217 struct damon_region *r;
17ccae8bb5c9289 SeongJae Park 2021-09-07 218
1971bd630452e94 SeongJae Park 2022-03-22 219 t = damon_new_target();
17ccae8bb5c9289 SeongJae Park 2021-09-07 220 r = damon_new_region(0, 22);
17ccae8bb5c9289 SeongJae Park 2021-09-07 221 damon_add_region(r, t);
17ccae8bb5c9289 SeongJae Park 2021-09-07 @222 damon_split_regions_of(c, t, 2);
2e014660b3e4b7b SeongJae Park 2021-10-28 223 KUNIT_EXPECT_LE(test, damon_nr_regions(t), 2u);
17ccae8bb5c9289 SeongJae Park 2021-09-07 224 damon_free_target(t);
17ccae8bb5c9289 SeongJae Park 2021-09-07 225
1971bd630452e94 SeongJae Park 2022-03-22 226 t = damon_new_target();
17ccae8bb5c9289 SeongJae Park 2021-09-07 227 r = damon_new_region(0, 220);
17ccae8bb5c9289 SeongJae Park 2021-09-07 228 damon_add_region(r, t);
17ccae8bb5c9289 SeongJae Park 2021-09-07 229 damon_split_regions_of(c, t, 4);
2e014660b3e4b7b SeongJae Park 2021-10-28 230 KUNIT_EXPECT_LE(test, damon_nr_regions(t), 4u);
17ccae8bb5c9289 SeongJae Park 2021-09-07 231 damon_free_target(t);
17ccae8bb5c9289 SeongJae Park 2021-09-07 232 damon_destroy_ctx(c);
17ccae8bb5c9289 SeongJae Park 2021-09-07 233 }
17ccae8bb5c9289 SeongJae Park 2021-09-07 234

--
0-DAY CI Kernel Test Service
https://01.org/lkp

2022-08-12 13:16:10

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] mm/damon/core: simplify the parameter passing for region split operation

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on akpm-mm/mm-everything]

url: https://github.com/intel-lab-lkp/linux/commits/xiakaixu1987-gmail-com/mm-damon-core-simplify-the-parameter-passing-for-region-split-operation/20220812-154316
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20220812/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/26b7d93b0f64c71d6d324a4a37d85641b55eaec2
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review xiakaixu1987-gmail-com/mm-damon-core-simplify-the-parameter-passing-for-region-split-operation/20220812-154316
git checkout 26b7d93b0f64c71d6d324a4a37d85641b55eaec2
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

In file included from mm/damon/core.c:1218:
mm/damon/core-test.h: In function 'damon_test_split_at':
>> mm/damon/core-test.h:129:31: error: passing argument 1 of 'damon_split_region_at' from incompatible pointer type [-Werror=incompatible-pointer-types]
129 | damon_split_region_at(c, t, r, 25);
| ^
| |
| struct damon_ctx *
mm/damon/core.c:930:56: note: expected 'struct damon_target *' but argument is of type 'struct damon_ctx *'
930 | static void damon_split_region_at(struct damon_target *t,
| ~~~~~~~~~~~~~~~~~~~~~^
In file included from mm/damon/core.c:1218:
mm/damon/core-test.h:129:34: error: passing argument 2 of 'damon_split_region_at' from incompatible pointer type [-Werror=incompatible-pointer-types]
129 | damon_split_region_at(c, t, r, 25);
| ^
| |
| struct damon_target *
mm/damon/core.c:931:56: note: expected 'struct damon_region *' but argument is of type 'struct damon_target *'
931 | struct damon_region *r, unsigned long sz_r)
| ~~~~~~~~~~~~~~~~~~~~~^
In file included from mm/damon/core.c:1218:
mm/damon/core-test.h:129:37: warning: passing argument 3 of 'damon_split_region_at' makes integer from pointer without a cast [-Wint-conversion]
129 | damon_split_region_at(c, t, r, 25);
| ^
| |
| struct damon_region *
mm/damon/core.c:931:73: note: expected 'long unsigned int' but argument is of type 'struct damon_region *'
931 | struct damon_region *r, unsigned long sz_r)
| ~~~~~~~~~~~~~~^~~~
In file included from mm/damon/core.c:1218:
>> mm/damon/core-test.h:129:9: error: too many arguments to function 'damon_split_region_at'
129 | damon_split_region_at(c, t, r, 25);
| ^~~~~~~~~~~~~~~~~~~~~
mm/damon/core.c:930:13: note: declared here
930 | static void damon_split_region_at(struct damon_target *t,
| ^~~~~~~~~~~~~~~~~~~~~
In file included from mm/damon/core.c:1218:
mm/damon/core-test.h: In function 'damon_test_split_regions_of':
>> mm/damon/core-test.h:222:32: error: passing argument 1 of 'damon_split_regions_of' from incompatible pointer type [-Werror=incompatible-pointer-types]
222 | damon_split_regions_of(c, t, 2);
| ^
| |
| struct damon_ctx *
mm/damon/core.c:948:57: note: expected 'struct damon_target *' but argument is of type 'struct damon_ctx *'
948 | static void damon_split_regions_of(struct damon_target *t, int nr_subs)
| ~~~~~~~~~~~~~~~~~~~~~^
In file included from mm/damon/core.c:1218:
mm/damon/core-test.h:222:35: warning: passing argument 2 of 'damon_split_regions_of' makes integer from pointer without a cast [-Wint-conversion]
222 | damon_split_regions_of(c, t, 2);
| ^
| |
| struct damon_target *
mm/damon/core.c:948:64: note: expected 'int' but argument is of type 'struct damon_target *'
948 | static void damon_split_regions_of(struct damon_target *t, int nr_subs)
| ~~~~^~~~~~~
In file included from mm/damon/core.c:1218:
>> mm/damon/core-test.h:222:9: error: too many arguments to function 'damon_split_regions_of'
222 | damon_split_regions_of(c, t, 2);
| ^~~~~~~~~~~~~~~~~~~~~~
mm/damon/core.c:948:13: note: declared here
948 | static void damon_split_regions_of(struct damon_target *t, int nr_subs)
| ^~~~~~~~~~~~~~~~~~~~~~
In file included from mm/damon/core.c:1218:
mm/damon/core-test.h:229:32: error: passing argument 1 of 'damon_split_regions_of' from incompatible pointer type [-Werror=incompatible-pointer-types]
229 | damon_split_regions_of(c, t, 4);
| ^
| |
| struct damon_ctx *
mm/damon/core.c:948:57: note: expected 'struct damon_target *' but argument is of type 'struct damon_ctx *'
948 | static void damon_split_regions_of(struct damon_target *t, int nr_subs)
| ~~~~~~~~~~~~~~~~~~~~~^
In file included from mm/damon/core.c:1218:
mm/damon/core-test.h:229:35: warning: passing argument 2 of 'damon_split_regions_of' makes integer from pointer without a cast [-Wint-conversion]
229 | damon_split_regions_of(c, t, 4);
| ^
| |
| struct damon_target *
mm/damon/core.c:948:64: note: expected 'int' but argument is of type 'struct damon_target *'
948 | static void damon_split_regions_of(struct damon_target *t, int nr_subs)
| ~~~~^~~~~~~
In file included from mm/damon/core.c:1218:
mm/damon/core-test.h:229:9: error: too many arguments to function 'damon_split_regions_of'
229 | damon_split_regions_of(c, t, 4);
| ^~~~~~~~~~~~~~~~~~~~~~
mm/damon/core.c:948:13: note: declared here
948 | static void damon_split_regions_of(struct damon_target *t, int nr_subs)
| ^~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors


vim +/damon_split_region_at +129 mm/damon/core-test.h

17ccae8bb5c928 SeongJae Park 2021-09-07 119
17ccae8bb5c928 SeongJae Park 2021-09-07 120 static void damon_test_split_at(struct kunit *test)
17ccae8bb5c928 SeongJae Park 2021-09-07 121 {
17ccae8bb5c928 SeongJae Park 2021-09-07 122 struct damon_ctx *c = damon_new_ctx();
17ccae8bb5c928 SeongJae Park 2021-09-07 123 struct damon_target *t;
17ccae8bb5c928 SeongJae Park 2021-09-07 124 struct damon_region *r;
17ccae8bb5c928 SeongJae Park 2021-09-07 125
1971bd630452e9 SeongJae Park 2022-03-22 126 t = damon_new_target();
17ccae8bb5c928 SeongJae Park 2021-09-07 127 r = damon_new_region(0, 100);
17ccae8bb5c928 SeongJae Park 2021-09-07 128 damon_add_region(r, t);
17ccae8bb5c928 SeongJae Park 2021-09-07 @129 damon_split_region_at(c, t, r, 25);
17ccae8bb5c928 SeongJae Park 2021-09-07 130 KUNIT_EXPECT_EQ(test, r->ar.start, 0ul);
17ccae8bb5c928 SeongJae Park 2021-09-07 131 KUNIT_EXPECT_EQ(test, r->ar.end, 25ul);
17ccae8bb5c928 SeongJae Park 2021-09-07 132
17ccae8bb5c928 SeongJae Park 2021-09-07 133 r = damon_next_region(r);
17ccae8bb5c928 SeongJae Park 2021-09-07 134 KUNIT_EXPECT_EQ(test, r->ar.start, 25ul);
17ccae8bb5c928 SeongJae Park 2021-09-07 135 KUNIT_EXPECT_EQ(test, r->ar.end, 100ul);
17ccae8bb5c928 SeongJae Park 2021-09-07 136
17ccae8bb5c928 SeongJae Park 2021-09-07 137 damon_free_target(t);
17ccae8bb5c928 SeongJae Park 2021-09-07 138 damon_destroy_ctx(c);
17ccae8bb5c928 SeongJae Park 2021-09-07 139 }
17ccae8bb5c928 SeongJae Park 2021-09-07 140
17ccae8bb5c928 SeongJae Park 2021-09-07 141 static void damon_test_merge_two(struct kunit *test)
17ccae8bb5c928 SeongJae Park 2021-09-07 142 {
17ccae8bb5c928 SeongJae Park 2021-09-07 143 struct damon_target *t;
17ccae8bb5c928 SeongJae Park 2021-09-07 144 struct damon_region *r, *r2, *r3;
17ccae8bb5c928 SeongJae Park 2021-09-07 145 int i;
17ccae8bb5c928 SeongJae Park 2021-09-07 146
1971bd630452e9 SeongJae Park 2022-03-22 147 t = damon_new_target();
17ccae8bb5c928 SeongJae Park 2021-09-07 148 r = damon_new_region(0, 100);
17ccae8bb5c928 SeongJae Park 2021-09-07 149 r->nr_accesses = 10;
17ccae8bb5c928 SeongJae Park 2021-09-07 150 damon_add_region(r, t);
17ccae8bb5c928 SeongJae Park 2021-09-07 151 r2 = damon_new_region(100, 300);
17ccae8bb5c928 SeongJae Park 2021-09-07 152 r2->nr_accesses = 20;
17ccae8bb5c928 SeongJae Park 2021-09-07 153 damon_add_region(r2, t);
17ccae8bb5c928 SeongJae Park 2021-09-07 154
17ccae8bb5c928 SeongJae Park 2021-09-07 155 damon_merge_two_regions(t, r, r2);
17ccae8bb5c928 SeongJae Park 2021-09-07 156 KUNIT_EXPECT_EQ(test, r->ar.start, 0ul);
17ccae8bb5c928 SeongJae Park 2021-09-07 157 KUNIT_EXPECT_EQ(test, r->ar.end, 300ul);
17ccae8bb5c928 SeongJae Park 2021-09-07 158 KUNIT_EXPECT_EQ(test, r->nr_accesses, 16u);
17ccae8bb5c928 SeongJae Park 2021-09-07 159
17ccae8bb5c928 SeongJae Park 2021-09-07 160 i = 0;
17ccae8bb5c928 SeongJae Park 2021-09-07 161 damon_for_each_region(r3, t) {
17ccae8bb5c928 SeongJae Park 2021-09-07 162 KUNIT_EXPECT_PTR_EQ(test, r, r3);
17ccae8bb5c928 SeongJae Park 2021-09-07 163 i++;
17ccae8bb5c928 SeongJae Park 2021-09-07 164 }
17ccae8bb5c928 SeongJae Park 2021-09-07 165 KUNIT_EXPECT_EQ(test, i, 1);
17ccae8bb5c928 SeongJae Park 2021-09-07 166
17ccae8bb5c928 SeongJae Park 2021-09-07 167 damon_free_target(t);
17ccae8bb5c928 SeongJae Park 2021-09-07 168 }
17ccae8bb5c928 SeongJae Park 2021-09-07 169
17ccae8bb5c928 SeongJae Park 2021-09-07 170 static struct damon_region *__nth_region_of(struct damon_target *t, int idx)
17ccae8bb5c928 SeongJae Park 2021-09-07 171 {
17ccae8bb5c928 SeongJae Park 2021-09-07 172 struct damon_region *r;
17ccae8bb5c928 SeongJae Park 2021-09-07 173 unsigned int i = 0;
17ccae8bb5c928 SeongJae Park 2021-09-07 174
17ccae8bb5c928 SeongJae Park 2021-09-07 175 damon_for_each_region(r, t) {
17ccae8bb5c928 SeongJae Park 2021-09-07 176 if (i++ == idx)
17ccae8bb5c928 SeongJae Park 2021-09-07 177 return r;
17ccae8bb5c928 SeongJae Park 2021-09-07 178 }
17ccae8bb5c928 SeongJae Park 2021-09-07 179
17ccae8bb5c928 SeongJae Park 2021-09-07 180 return NULL;
17ccae8bb5c928 SeongJae Park 2021-09-07 181 }
17ccae8bb5c928 SeongJae Park 2021-09-07 182
17ccae8bb5c928 SeongJae Park 2021-09-07 183 static void damon_test_merge_regions_of(struct kunit *test)
17ccae8bb5c928 SeongJae Park 2021-09-07 184 {
17ccae8bb5c928 SeongJae Park 2021-09-07 185 struct damon_target *t;
17ccae8bb5c928 SeongJae Park 2021-09-07 186 struct damon_region *r;
17ccae8bb5c928 SeongJae Park 2021-09-07 187 unsigned long sa[] = {0, 100, 114, 122, 130, 156, 170, 184};
17ccae8bb5c928 SeongJae Park 2021-09-07 188 unsigned long ea[] = {100, 112, 122, 130, 156, 170, 184, 230};
17ccae8bb5c928 SeongJae Park 2021-09-07 189 unsigned int nrs[] = {0, 0, 10, 10, 20, 30, 1, 2};
17ccae8bb5c928 SeongJae Park 2021-09-07 190
17ccae8bb5c928 SeongJae Park 2021-09-07 191 unsigned long saddrs[] = {0, 114, 130, 156, 170};
17ccae8bb5c928 SeongJae Park 2021-09-07 192 unsigned long eaddrs[] = {112, 130, 156, 170, 230};
17ccae8bb5c928 SeongJae Park 2021-09-07 193 int i;
17ccae8bb5c928 SeongJae Park 2021-09-07 194
1971bd630452e9 SeongJae Park 2022-03-22 195 t = damon_new_target();
17ccae8bb5c928 SeongJae Park 2021-09-07 196 for (i = 0; i < ARRAY_SIZE(sa); i++) {
17ccae8bb5c928 SeongJae Park 2021-09-07 197 r = damon_new_region(sa[i], ea[i]);
17ccae8bb5c928 SeongJae Park 2021-09-07 198 r->nr_accesses = nrs[i];
17ccae8bb5c928 SeongJae Park 2021-09-07 199 damon_add_region(r, t);
17ccae8bb5c928 SeongJae Park 2021-09-07 200 }
17ccae8bb5c928 SeongJae Park 2021-09-07 201
17ccae8bb5c928 SeongJae Park 2021-09-07 202 damon_merge_regions_of(t, 9, 9999);
17ccae8bb5c928 SeongJae Park 2021-09-07 203 /* 0-112, 114-130, 130-156, 156-170 */
17ccae8bb5c928 SeongJae Park 2021-09-07 204 KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 5u);
17ccae8bb5c928 SeongJae Park 2021-09-07 205 for (i = 0; i < 5; i++) {
17ccae8bb5c928 SeongJae Park 2021-09-07 206 r = __nth_region_of(t, i);
17ccae8bb5c928 SeongJae Park 2021-09-07 207 KUNIT_EXPECT_EQ(test, r->ar.start, saddrs[i]);
17ccae8bb5c928 SeongJae Park 2021-09-07 208 KUNIT_EXPECT_EQ(test, r->ar.end, eaddrs[i]);
17ccae8bb5c928 SeongJae Park 2021-09-07 209 }
17ccae8bb5c928 SeongJae Park 2021-09-07 210 damon_free_target(t);
17ccae8bb5c928 SeongJae Park 2021-09-07 211 }
17ccae8bb5c928 SeongJae Park 2021-09-07 212
17ccae8bb5c928 SeongJae Park 2021-09-07 213 static void damon_test_split_regions_of(struct kunit *test)
17ccae8bb5c928 SeongJae Park 2021-09-07 214 {
17ccae8bb5c928 SeongJae Park 2021-09-07 215 struct damon_ctx *c = damon_new_ctx();
17ccae8bb5c928 SeongJae Park 2021-09-07 216 struct damon_target *t;
17ccae8bb5c928 SeongJae Park 2021-09-07 217 struct damon_region *r;
17ccae8bb5c928 SeongJae Park 2021-09-07 218
1971bd630452e9 SeongJae Park 2022-03-22 219 t = damon_new_target();
17ccae8bb5c928 SeongJae Park 2021-09-07 220 r = damon_new_region(0, 22);
17ccae8bb5c928 SeongJae Park 2021-09-07 221 damon_add_region(r, t);
17ccae8bb5c928 SeongJae Park 2021-09-07 @222 damon_split_regions_of(c, t, 2);
2e014660b3e4b7 SeongJae Park 2021-10-28 223 KUNIT_EXPECT_LE(test, damon_nr_regions(t), 2u);
17ccae8bb5c928 SeongJae Park 2021-09-07 224 damon_free_target(t);
17ccae8bb5c928 SeongJae Park 2021-09-07 225
1971bd630452e9 SeongJae Park 2022-03-22 226 t = damon_new_target();
17ccae8bb5c928 SeongJae Park 2021-09-07 227 r = damon_new_region(0, 220);
17ccae8bb5c928 SeongJae Park 2021-09-07 228 damon_add_region(r, t);
17ccae8bb5c928 SeongJae Park 2021-09-07 229 damon_split_regions_of(c, t, 4);
2e014660b3e4b7 SeongJae Park 2021-10-28 230 KUNIT_EXPECT_LE(test, damon_nr_regions(t), 4u);
17ccae8bb5c928 SeongJae Park 2021-09-07 231 damon_free_target(t);
17ccae8bb5c928 SeongJae Park 2021-09-07 232 damon_destroy_ctx(c);
17ccae8bb5c928 SeongJae Park 2021-09-07 233 }
17ccae8bb5c928 SeongJae Park 2021-09-07 234

--
0-DAY CI Kernel Test Service
https://01.org/lkp

2022-08-12 16:04:22

by SeongJae Park

[permalink] [raw]
Subject: Re: [PATCH] mm/damon/core: simplify the parameter passing for region split operation

Hi Kaixu,

On Fri, 12 Aug 2022 15:41:13 +0800 [email protected] wrote:

> From: Kaixu Xia <[email protected]>
>
> The parameter 'struct damon_target *t' is unnecessary in damon region
> split operation, so we can remove it.

Good finding. But, 't' is used while 'ctx' is unused in
'damon_split_region_at()' and 'damon_split_regions_of'. Below code change is
also removing 'ctx', not 't'. Could you please update the commit message for
that?

Also, please fix the kernel test robot reported issues together:
https://lore.kernel.org/damon/[email protected]/


Thanks,
SJ

[...]

2022-08-12 20:18:01

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] mm/damon/core: simplify the parameter passing for region split operation

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on akpm-mm/mm-everything]

url: https://github.com/intel-lab-lkp/linux/commits/xiakaixu1987-gmail-com/mm-damon-core-simplify-the-parameter-passing-for-region-split-operation/20220812-154316
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
config: hexagon-randconfig-r045-20220812 (https://download.01.org/0day-ci/archive/20220813/[email protected]/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 5f1c7e2cc5a3c07cbc2412e851a7283c1841f520)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/26b7d93b0f64c71d6d324a4a37d85641b55eaec2
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review xiakaixu1987-gmail-com/mm-damon-core-simplify-the-parameter-passing-for-region-split-operation/20220812-154316
git checkout 26b7d93b0f64c71d6d324a4a37d85641b55eaec2
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

In file included from mm/damon/core.c:1218:
>> mm/damon/core-test.h:129:33: error: too many arguments to function call, expected 3, have 4
damon_split_region_at(c, t, r, 25);
~~~~~~~~~~~~~~~~~~~~~ ^~
mm/damon/core.c:930:13: note: 'damon_split_region_at' declared here
static void damon_split_region_at(struct damon_target *t,
^
In file included from mm/damon/core.c:1218:
mm/damon/core-test.h:222:31: error: too many arguments to function call, expected 2, have 3
damon_split_regions_of(c, t, 2);
~~~~~~~~~~~~~~~~~~~~~~ ^
mm/damon/core.c:948:13: note: 'damon_split_regions_of' declared here
static void damon_split_regions_of(struct damon_target *t, int nr_subs)
^
In file included from mm/damon/core.c:1218:
mm/damon/core-test.h:229:31: error: too many arguments to function call, expected 2, have 3
damon_split_regions_of(c, t, 4);
~~~~~~~~~~~~~~~~~~~~~~ ^
mm/damon/core.c:948:13: note: 'damon_split_regions_of' declared here
static void damon_split_regions_of(struct damon_target *t, int nr_subs)
^
3 errors generated.


vim +129 mm/damon/core-test.h

17ccae8bb5c928 SeongJae Park 2021-09-07 119
17ccae8bb5c928 SeongJae Park 2021-09-07 120 static void damon_test_split_at(struct kunit *test)
17ccae8bb5c928 SeongJae Park 2021-09-07 121 {
17ccae8bb5c928 SeongJae Park 2021-09-07 122 struct damon_ctx *c = damon_new_ctx();
17ccae8bb5c928 SeongJae Park 2021-09-07 123 struct damon_target *t;
17ccae8bb5c928 SeongJae Park 2021-09-07 124 struct damon_region *r;
17ccae8bb5c928 SeongJae Park 2021-09-07 125
1971bd630452e9 SeongJae Park 2022-03-22 126 t = damon_new_target();
17ccae8bb5c928 SeongJae Park 2021-09-07 127 r = damon_new_region(0, 100);
17ccae8bb5c928 SeongJae Park 2021-09-07 128 damon_add_region(r, t);
17ccae8bb5c928 SeongJae Park 2021-09-07 @129 damon_split_region_at(c, t, r, 25);
17ccae8bb5c928 SeongJae Park 2021-09-07 130 KUNIT_EXPECT_EQ(test, r->ar.start, 0ul);
17ccae8bb5c928 SeongJae Park 2021-09-07 131 KUNIT_EXPECT_EQ(test, r->ar.end, 25ul);
17ccae8bb5c928 SeongJae Park 2021-09-07 132
17ccae8bb5c928 SeongJae Park 2021-09-07 133 r = damon_next_region(r);
17ccae8bb5c928 SeongJae Park 2021-09-07 134 KUNIT_EXPECT_EQ(test, r->ar.start, 25ul);
17ccae8bb5c928 SeongJae Park 2021-09-07 135 KUNIT_EXPECT_EQ(test, r->ar.end, 100ul);
17ccae8bb5c928 SeongJae Park 2021-09-07 136
17ccae8bb5c928 SeongJae Park 2021-09-07 137 damon_free_target(t);
17ccae8bb5c928 SeongJae Park 2021-09-07 138 damon_destroy_ctx(c);
17ccae8bb5c928 SeongJae Park 2021-09-07 139 }
17ccae8bb5c928 SeongJae Park 2021-09-07 140

--
0-DAY CI Kernel Test Service
https://01.org/lkp

2022-08-13 14:40:35

by Kaixu Xia

[permalink] [raw]
Subject: Re: [PATCH] mm/damon/core: simplify the parameter passing for region split operation

On Fri, Aug 12, 2022 at 11:48 PM SeongJae Park <[email protected]> wrote:
>
> Hi Kaixu,
>
> On Fri, 12 Aug 2022 15:41:13 +0800 [email protected] wrote:
>
> > From: Kaixu Xia <[email protected]>
> >
> > The parameter 'struct damon_target *t' is unnecessary in damon region
> > split operation, so we can remove it.
>
> Good finding. But, 't' is used while 'ctx' is unused in
> 'damon_split_region_at()' and 'damon_split_regions_of'. Below code change is
> also removing 'ctx', not 't'. Could you please update the commit message for
> that?
>
> Also, please fix the kernel test robot reported issues together:
> https://lore.kernel.org/damon/[email protected]/
>
>
Thanks. Will fix them in the next version.

> Thanks,
> SJ
>
> [...]