Re: [PATCH 2/2] mm/damon/core: Copy only installed probe in damon_split_region_at()

From: SJ Park

Date: Thu Oct 08 2026 - 07:03:19 EST


Hello Suhaas,


>From the next time, please send a patch series as a single thread, with a cover
letter.

On Wed, 7 Oct 2026 21:18:46 +0530 Suhaas Joshi <suhaas@xxxxxxxxxx> wrote:

> In damon_split_region_at(), we copy the entire probe_hits[] and
> last_probe_hits[] arrays of DAMON_MAX_PROBES size. However it is possible
> that the number of probes installed is less than DAMON_MAX_PROBES, in which
> case one or more iterations is/are redundant. To remedy this, iterate over
> only as many times as the number of installed probes. To do so, accept a
> struct damon_ctx pointer in damon_split_region_at(), and update all
> invocations of the function to pass the new argument.
>
> Also update damon_test_split_at() and damos_test_filter_out() in
> core-kunit.h to supply a context to function paths that call
> damon_split_region_at().
>
> Signed-off-by: Suhaas Joshi <suhaas@xxxxxxxxxx>
> ---
> mm/damon/core.c | 42 +++++++++++++++++---------------
> mm/damon/tests/core-kunit.h | 48 ++++++++++++++++++++++++++++++-------
> 2 files changed, 63 insertions(+), 27 deletions(-)
>
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index a3af5ee685e1..025df4d19e20 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -2049,8 +2049,8 @@ static unsigned long damon_region_sz_limit(struct damon_ctx *ctx)
> return sz;
> }
>
> -static int damon_split_region_at(struct damon_target *t,
> - struct damon_region *r, unsigned long sz_r);
> +static int damon_split_region_at(struct damon_ctx *ctx, struct damon_target *t,
> + struct damon_region *r, unsigned long sz_r);

Please wrap lines for 80 columns [1] limit per line. Same for below.

[...]
> @@ -2494,9 +2494,9 @@ static bool damos_valid_target(struct damon_ctx *c, struct damon_region *r,
> *
> * Return: true if the region should be skipped, false otherwise.
> */
> -static bool damos_skip_charged_region(struct damon_target *t,
> - struct damon_region *r, struct damos *s,
> - unsigned long min_region_sz)
> +static bool damos_skip_charged_region(struct damon_ctx *ctx, struct damon_target *t,
> + struct damon_region *r, struct damos *s,
> + unsigned long min_region_sz)

Please update the comment above to document the new parameter.

[...]
> @@ -3643,10 +3643,12 @@ static void damon_verify_split_region_at(struct damon_region *r,
> *
> * Return: 0 on success, negative error code otherwise.
> */
> -static int damon_split_region_at(struct damon_target *t,
> - struct damon_region *r, unsigned long sz_r)
> +static int damon_split_region_at(struct damon_ctx *ctx, struct damon_target *t,
> + struct damon_region *r, unsigned long sz_r)

Ditto.

[...]

[1] https://docs.kernel.org/process/coding-style.html#breaking-long-lines-and-strings


Thanks,
SJ