DAMON development mailing list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ravi Jonnalagadda" <ravis.opensrc@gmail.com>
Cc: damon@lists.linux.dev
Subject: Re: [RFC PATCH v3 7/9] mm/damon/tests/drain-kunit: kunit for report rings and ring drain
Date: Sat, 03 Oct 2026 21:17:36 +0000	[thread overview]
Message-ID: <20261003211737.18ED81F0089B@smtp.kernel.org> (raw)
In-Reply-To: <20261003-damon-perf-rfc-v3-send-2026-10-03-v3-7-0f00417b41bc@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] mm: damon: KUnit tests leak struct pid on success path
- [Medium] mm: damon: test bsearch_unsorted_regions mistakenly creates sorted list
- [Medium] mm: damon: memory leak of region r1 on allocation error path
--

commit 19081629f237047138afa26eda20068a417837a2
Author: Ravi Jonnalagadda <ravis.opensrc@gmail.com>
Subject: mm/damon/tests/drain-kunit: kunit for report rings and ring drain

This commit adds kunit test coverage for the per-context perf report rings
and the unified paddr/vaddr report drain path.

> diff --git a/mm/damon/tests/drain-kunit.h b/mm/damon/tests/drain-kunit.h
> new file mode 100644
> index 0000000000000..8e5023ebf6df7
> --- /dev/null
> +++ b/mm/damon/tests/drain-kunit.h

[ ... ]

> +static void damon_test_unified_vaddr_match(struct kunit *test)
> +{

[ ... ]

> +	t = damon_new_target();
> +	if (!t) {
> +		damon_destroy_ctx(ctx);
> +		kunit_skip(test, "target alloc failed");
> +	}
> +	t->pid = get_pid(task_tgid(current));

[Severity: Medium]
Does this code leak the struct pid reference? Because ops.cleanup_target
is not defined for this test context, damon_destroy_ctx() won't drop the
target's PID reference acquired by get_pid().

[ ... ]

> +static void damon_test_unified_vaddr_tgid_mismatch(struct kunit *test)
> +{

[ ... ]

> +	t = damon_new_target();
> +	if (!t) {
> +		damon_destroy_ctx(ctx);
> +		kunit_skip(test, "target alloc failed");
> +	}
> +	t->pid = get_pid(task_tgid(current));

[Severity: Medium]
Similarly, does this test also leak the struct pid reference on teardown
for the same reason?

[ ... ]

> +static void damon_test_bsearch_unsorted_regions(struct kunit *test)
> +{

[ ... ]

> +	/*
> +	 * Insert regions in REVERSE order so the list is unsorted: r2 at lower
> +	 * address first, r1 at higher address second.  DAMON normally inserts
> +	 * in sorted order; we bypass that here to exercise the bsearch path
> +	 * with unsorted input.
> +	 */
> +	r1 = damon_new_region(0x10000, 0x20000);
> +	r2 = damon_new_region(0x30000, 0x40000);
> +	if (!r1 || !r2) {
> +		damon_free_target(t);
> +		damon_destroy_ctx(ctx);
> +		kunit_skip(test, "region alloc failed");
> +	}

[Severity: Medium]
If r1 is allocated successfully but r2 fails to allocate, does this error
path leak r1? Since r1 has not been added to the target's region list
yet, damon_free_target() won't free it.

> +	/* Add in reverse (high first) to create an unsorted list. */
> +	list_add(&r2->list, &t->regions_list);
> +	list_add(&r1->list, &t->regions_list);

[Severity: Medium]
Does this sequence actually create a sorted list instead of an unsorted
one? Because list_add() prepends to the head, adding r2 (higher address)
then r1 (lower address) places r1 before r2. This results in the regions
being sorted in ascending order, which defeats the purpose of the test.

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261003-damon-perf-rfc-v3-send-2026-10-03-v3-0-0f00417b41bc@gmail.com?part=7

  reply	other threads:[~2026-10-03 21:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-03 21:07 [RFC PATCH v3 0/9] mm/damon: hardware-sampled access reports Ravi Jonnalagadda
2026-10-03 21:07 ` [RFC PATCH v3 1/9] mm/damon/paddr: remove page_fault access check primitive Ravi Jonnalagadda
2026-10-03 21:20   ` sashiko-bot
2026-10-03 21:07 ` [RFC PATCH v3 2/9] mm/damon/core: replace the access report buffer with per-context rings Ravi Jonnalagadda
2026-10-03 21:22   ` sashiko-bot
2026-10-04  8:30   ` Kunwu Chan
2026-10-05  9:09     ` Ravi Jonnalagadda
2026-10-04  9:10   ` Kunwu Chan
2026-10-05  9:11     ` Ravi Jonnalagadda
2026-10-03 21:07 ` [RFC PATCH v3 3/9] mm/damon: add perf-event overflow handler feeding the report ring Ravi Jonnalagadda
2026-10-03 21:22   ` sashiko-bot
2026-10-03 21:07 ` [RFC PATCH v3 4/9] mm/damon/ops-common: use probe-weighted score when probe weights are set Ravi Jonnalagadda
2026-10-03 21:15   ` sashiko-bot
2026-10-03 21:07 ` [RFC PATCH v3 5/9] mm/damon: add perf_event prep type, core lifecycle, and PMU arm/disarm Ravi Jonnalagadda
2026-10-03 21:07 ` [RFC PATCH v3 6/9] mm/damon/sysfs: expose perf_event prep attributes Ravi Jonnalagadda
2026-10-03 21:20   ` sashiko-bot
2026-10-03 21:08 ` [RFC PATCH v3 7/9] mm/damon/tests/drain-kunit: kunit for report rings and ring drain Ravi Jonnalagadda
2026-10-03 21:17   ` sashiko-bot [this message]
2026-10-03 21:08 ` [RFC PATCH v3 8/9] mm/damon/core: cap the region merge threshold per target Ravi Jonnalagadda
2026-10-03 21:18   ` sashiko-bot
2026-10-03 21:08 ` [RFC PATCH v3 9/9] mm/damon/core: allow both primitives disabled when a perf probe is present Ravi Jonnalagadda
2026-10-03 21:20   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261003211737.18ED81F0089B@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=damon@lists.linux.dev \
    --cc=ravis.opensrc@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox