Message ID | 20220910165536.99023-1-xhao@linux.alibaba.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | mm/damon: simplify scheme create in damon_lru_sort_apply_parameters | expand |
Hi Xin,
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/Xin-Hao/mm-damon-simplify-scheme-create-in-damon_lru_sort_apply_parameters/20220911-005630
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
config: x86_64-allyesconfig
compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/d9938ea4d14a88832eee655cda52401891778dd5
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Xin-Hao/mm-damon-simplify-scheme-create-in-damon_lru_sort_apply_parameters/20220911-005630
git checkout d9938ea4d14a88832eee655cda52401891778dd5
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash mm/damon/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
mm/damon/lru_sort.c: In function 'damon_lru_sort_apply_parameters':
>> mm/damon/lru_sort.c:353:32: warning: unused variable 'next_scheme' [-Wunused-variable]
353 | struct damos *scheme, *next_scheme;
| ^~~~~~~~~~~
vim +/next_scheme +353 mm/damon/lru_sort.c
40e983cca9274e SeongJae Park 2022-06-13 350
40e983cca9274e SeongJae Park 2022-06-13 351 static int damon_lru_sort_apply_parameters(void)
40e983cca9274e SeongJae Park 2022-06-13 352 {
40e983cca9274e SeongJae Park 2022-06-13 @353 struct damos *scheme, *next_scheme;
40e983cca9274e SeongJae Park 2022-06-13 354 struct damon_addr_range addr_range;
40e983cca9274e SeongJae Park 2022-06-13 355 unsigned int hot_thres, cold_thres;
40e983cca9274e SeongJae Park 2022-06-13 356 int err = 0;
40e983cca9274e SeongJae Park 2022-06-13 357
40e983cca9274e SeongJae Park 2022-06-13 358 err = damon_set_attrs(ctx, sample_interval, aggr_interval, 0,
40e983cca9274e SeongJae Park 2022-06-13 359 min_nr_regions, max_nr_regions);
40e983cca9274e SeongJae Park 2022-06-13 360 if (err)
40e983cca9274e SeongJae Park 2022-06-13 361 return err;
40e983cca9274e SeongJae Park 2022-06-13 362
40e983cca9274e SeongJae Park 2022-06-13 363 /* aggr_interval / sample_interval is the maximum nr_accesses */
40e983cca9274e SeongJae Park 2022-06-13 364 hot_thres = aggr_interval / sample_interval * hot_thres_access_freq /
40e983cca9274e SeongJae Park 2022-06-13 365 1000;
40e983cca9274e SeongJae Park 2022-06-13 366 scheme = damon_lru_sort_new_hot_scheme(hot_thres);
40e983cca9274e SeongJae Park 2022-06-13 367 if (!scheme)
40e983cca9274e SeongJae Park 2022-06-13 368 return -ENOMEM;
d9938ea4d14a88 Xin Hao 2022-09-11 369 err = damon_set_schemes(ctx, &scheme, 1);
d9938ea4d14a88 Xin Hao 2022-09-11 370 if (err)
d9938ea4d14a88 Xin Hao 2022-09-11 371 return err;
40e983cca9274e SeongJae Park 2022-06-13 372
40e983cca9274e SeongJae Park 2022-06-13 373 cold_thres = cold_min_age / aggr_interval;
40e983cca9274e SeongJae Park 2022-06-13 374 scheme = damon_lru_sort_new_cold_scheme(cold_thres);
40e983cca9274e SeongJae Park 2022-06-13 375 if (!scheme)
40e983cca9274e SeongJae Park 2022-06-13 376 return -ENOMEM;
40e983cca9274e SeongJae Park 2022-06-13 377 damon_add_scheme(ctx, scheme);
40e983cca9274e SeongJae Park 2022-06-13 378
40e983cca9274e SeongJae Park 2022-06-13 379 if (monitor_region_start > monitor_region_end)
40e983cca9274e SeongJae Park 2022-06-13 380 return -EINVAL;
40e983cca9274e SeongJae Park 2022-06-13 381 if (!monitor_region_start && !monitor_region_end &&
dd7ecfcf662cdf Xin Hao 2022-09-09 382 !damon_find_biggest_system_ram(&monitor_region_start,
40e983cca9274e SeongJae Park 2022-06-13 383 &monitor_region_end))
40e983cca9274e SeongJae Park 2022-06-13 384 return -EINVAL;
40e983cca9274e SeongJae Park 2022-06-13 385 addr_range.start = monitor_region_start;
40e983cca9274e SeongJae Park 2022-06-13 386 addr_range.end = monitor_region_end;
40e983cca9274e SeongJae Park 2022-06-13 387 return damon_set_regions(target, &addr_range, 1);
40e983cca9274e SeongJae Park 2022-06-13 388 }
40e983cca9274e SeongJae Park 2022-06-13 389
diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index b8ec52739e0f..b581b7b76fb2 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -350,17 +350,15 @@ static int damon_lru_sort_apply_parameters(void) if (err) return err; - /* free previously set schemes */ - damon_for_each_scheme_safe(scheme, next_scheme, ctx) - damon_destroy_scheme(scheme); - /* aggr_interval / sample_interval is the maximum nr_accesses */ hot_thres = aggr_interval / sample_interval * hot_thres_access_freq / 1000; scheme = damon_lru_sort_new_hot_scheme(hot_thres); if (!scheme) return -ENOMEM; - damon_add_scheme(ctx, scheme); + err = damon_set_schemes(ctx, &scheme, 1); + if (err) + return err; cold_thres = cold_min_age / aggr_interval; scheme = damon_lru_sort_new_cold_scheme(cold_thres);
In damon_lru_sort_apply_parameters(), we can use damon_set_schemes() to replace the way of creating the first 'scheme' in original code, this makes the code look cleaner. Signed-off-by: Xin Hao <xhao@linux.alibaba.com> --- mm/damon/lru_sort.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) -- 2.31.0