Skip to contentSkip to conversation

mm/damon/lru_sort: Move target memory region check to head of func

PATCH Superseded Xin Hao 1 participant 2 messages Aug 18, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Xin Hao

author
#0 lore raw

PATCH 1/1 mm/damon/lru_sort: Move target memory region check to head of func

In damon_lru_sort_apply_parameters(), if "monitor_region_start" and "monitor_region_end" is not a valid physical address range, There no need to run the remainder codes in it.

---
 mm/damon/lru_sort.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
mm/damon/lru_sort.c +7 -6
index 9de6f00a71c5..ac50dca026f9 100644
@@ -378,6 +378,13 @@ static int damon_lru_sort_apply_parameters(void)
 	unsigned int hot_thres, cold_thres;
 	int err = 0;
 
+	if (monitor_region_start > monitor_region_end)
+		return -EINVAL;
+	if (!monitor_region_start && !monitor_region_end &&
+			!get_monitoring_region(&monitor_region_start,
+				&monitor_region_end))
+		return -EINVAL;
+
 	err = damon_set_attrs(ctx, sample_interval, aggr_interval, 0,
 			min_nr_regions, max_nr_regions);
 	if (err)
@@ -401,12 +408,6 @@ static int damon_lru_sort_apply_parameters(void)
 		return -ENOMEM;
 	damon_add_scheme(ctx, scheme);
 
-	if (monitor_region_start > monitor_region_end)
-		return -EINVAL;
-	if (!monitor_region_start && !monitor_region_end &&
-			!get_monitoring_region(&monitor_region_start,
-				&monitor_region_end))
-		return -EINVAL;
 	addr_range.start = monitor_region_start;
 	addr_range.end = monitor_region_end;
 	return damon_set_regions(target, &addr_range, 1);

--
2.31.0

author
#1 lore raw

Hi all,

Please ignore this patch, i have send a  patch v2 in there:

https://lore.kernel.org/damon/[email protected]/

Quoted 42 lines · Xin Hao

In damon_lru_sort_apply_parameters(), if "monitor_region_start" and "monitor_region_end" is not a valid physical address range, There no need to run the remainder codes in it.

---
  mm/damon/lru_sort.c | 13 +++++++------
  1 file changed, 7 insertions(+), 6 deletions(-)
mm/damon/lru_sort.c +7 -7
index 9de6f00a71c5..ac50dca026f9 100644
@@ -378,6 +378,13 @@ static int damon_lru_sort_apply_parameters(void)
  	unsigned int hot_thres, cold_thres;
  	int err = 0;
 
+	if (monitor_region_start > monitor_region_end)
+		return -EINVAL;
+	if (!monitor_region_start && !monitor_region_end &&
+			!get_monitoring_region(&monitor_region_start,
+				&monitor_region_end))
+		return -EINVAL;
+
  	err = damon_set_attrs(ctx, sample_interval, aggr_interval, 0,
  			min_nr_regions, max_nr_regions);
  	if (err)
@@ -401,12 +408,6 @@ static int damon_lru_sort_apply_parameters(void)
  		return -ENOMEM;
  	damon_add_scheme(ctx, scheme);
 
-	if (monitor_region_start > monitor_region_end)
-		return -EINVAL;
-	if (!monitor_region_start && !monitor_region_end &&
-			!get_monitoring_region(&monitor_region_start,
-				&monitor_region_end))
-		return -EINVAL;
  	addr_range.start = monitor_region_start;
  	addr_range.end = monitor_region_end;
  	return damon_set_regions(target, &addr_range, 1);
--

2.31.0