mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	mm/damon/core: simplify the parameter passing for region split operation
The parameter 'struct damon_ctx *ctx' is unnecessary in damon region split operation, so we can remove it. Link: https://lkml.kernel.org/r/1660403943-29124-1-git-send-email-kaixuxia@tencent.com Signed-off-by: Kaixu Xia <kaixuxia@tencent.com> Reviewed-by: SeongJae Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
		
							parent
							
								
									57eb60c04d
								
							
						
					
					
						commit
						4ed9824346
					
				
					 2 changed files with 12 additions and 15 deletions
				
			
		| 
						 | 
					@ -126,7 +126,7 @@ static void damon_test_split_at(struct kunit *test)
 | 
				
			||||||
	t = damon_new_target();
 | 
						t = damon_new_target();
 | 
				
			||||||
	r = damon_new_region(0, 100);
 | 
						r = damon_new_region(0, 100);
 | 
				
			||||||
	damon_add_region(r, t);
 | 
						damon_add_region(r, t);
 | 
				
			||||||
	damon_split_region_at(c, t, r, 25);
 | 
						damon_split_region_at(t, r, 25);
 | 
				
			||||||
	KUNIT_EXPECT_EQ(test, r->ar.start, 0ul);
 | 
						KUNIT_EXPECT_EQ(test, r->ar.start, 0ul);
 | 
				
			||||||
	KUNIT_EXPECT_EQ(test, r->ar.end, 25ul);
 | 
						KUNIT_EXPECT_EQ(test, r->ar.end, 25ul);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -219,14 +219,14 @@ static void damon_test_split_regions_of(struct kunit *test)
 | 
				
			||||||
	t = damon_new_target();
 | 
						t = damon_new_target();
 | 
				
			||||||
	r = damon_new_region(0, 22);
 | 
						r = damon_new_region(0, 22);
 | 
				
			||||||
	damon_add_region(r, t);
 | 
						damon_add_region(r, t);
 | 
				
			||||||
	damon_split_regions_of(c, t, 2);
 | 
						damon_split_regions_of(t, 2);
 | 
				
			||||||
	KUNIT_EXPECT_LE(test, damon_nr_regions(t), 2u);
 | 
						KUNIT_EXPECT_LE(test, damon_nr_regions(t), 2u);
 | 
				
			||||||
	damon_free_target(t);
 | 
						damon_free_target(t);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t = damon_new_target();
 | 
						t = damon_new_target();
 | 
				
			||||||
	r = damon_new_region(0, 220);
 | 
						r = damon_new_region(0, 220);
 | 
				
			||||||
	damon_add_region(r, t);
 | 
						damon_add_region(r, t);
 | 
				
			||||||
	damon_split_regions_of(c, t, 4);
 | 
						damon_split_regions_of(t, 4);
 | 
				
			||||||
	KUNIT_EXPECT_LE(test, damon_nr_regions(t), 4u);
 | 
						KUNIT_EXPECT_LE(test, damon_nr_regions(t), 4u);
 | 
				
			||||||
	damon_free_target(t);
 | 
						damon_free_target(t);
 | 
				
			||||||
	damon_destroy_ctx(c);
 | 
						damon_destroy_ctx(c);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -658,9 +658,8 @@ static void kdamond_reset_aggregated(struct damon_ctx *c)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void damon_split_region_at(struct damon_ctx *ctx,
 | 
					static void damon_split_region_at(struct damon_target *t,
 | 
				
			||||||
		struct damon_target *t, struct damon_region *r,
 | 
									  struct damon_region *r, unsigned long sz_r);
 | 
				
			||||||
		unsigned long sz_r);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
static bool __damos_valid_target(struct damon_region *r, struct damos *s)
 | 
					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;
 | 
											continue;
 | 
				
			||||||
					sz = DAMON_MIN_REGION;
 | 
										sz = DAMON_MIN_REGION;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				damon_split_region_at(c, t, r, sz);
 | 
									damon_split_region_at(t, r, sz);
 | 
				
			||||||
				r = damon_next_region(r);
 | 
									r = damon_next_region(r);
 | 
				
			||||||
				sz = r->ar.end - r->ar.start;
 | 
									sz = r->ar.end - r->ar.start;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					@ -745,7 +744,7 @@ static void damon_do_apply_schemes(struct damon_ctx *c,
 | 
				
			||||||
						DAMON_MIN_REGION);
 | 
											DAMON_MIN_REGION);
 | 
				
			||||||
				if (!sz)
 | 
									if (!sz)
 | 
				
			||||||
					goto update_stat;
 | 
										goto update_stat;
 | 
				
			||||||
				damon_split_region_at(c, t, r, sz);
 | 
									damon_split_region_at(t, r, sz);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			ktime_get_coarse_ts64(&begin);
 | 
								ktime_get_coarse_ts64(&begin);
 | 
				
			||||||
			sz_applied = c->ops.apply_scheme(c, t, r, s);
 | 
								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
 | 
					 * r		the region to be split
 | 
				
			||||||
 * sz_r		size of the first sub-region that will be made
 | 
					 * sz_r		size of the first sub-region that will be made
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static void damon_split_region_at(struct damon_ctx *ctx,
 | 
					static void damon_split_region_at(struct damon_target *t,
 | 
				
			||||||
		struct damon_target *t, struct damon_region *r,
 | 
									  struct damon_region *r, unsigned long sz_r)
 | 
				
			||||||
		unsigned long sz_r)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct damon_region *new;
 | 
						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 */
 | 
					/* Split every region in the given target into 'nr_subs' regions */
 | 
				
			||||||
static void damon_split_regions_of(struct damon_ctx *ctx,
 | 
					static void damon_split_regions_of(struct damon_target *t, int nr_subs)
 | 
				
			||||||
				     struct damon_target *t, int nr_subs)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct damon_region *r, *next;
 | 
						struct damon_region *r, *next;
 | 
				
			||||||
	unsigned long sz_region, sz_sub = 0;
 | 
						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)
 | 
								if (sz_sub == 0 || sz_sub >= sz_region)
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			damon_split_region_at(ctx, t, r, sz_sub);
 | 
								damon_split_region_at(t, r, sz_sub);
 | 
				
			||||||
			sz_region = sz_sub;
 | 
								sz_region = sz_sub;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -1004,7 +1001,7 @@ static void kdamond_split_regions(struct damon_ctx *ctx)
 | 
				
			||||||
		nr_subregions = 3;
 | 
							nr_subregions = 3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	damon_for_each_target(t, ctx)
 | 
						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;
 | 
						last_nr_regions = nr_regions;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue