All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [RFC PATCH 07/10] mm/damon/tests/core-kunit: test damon_nr_samples_per_aggr()
Date: Tue, 28 Jul 2026 05:33:44 +0000	[thread overview]
Message-ID: <20260728053344.A42901F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260728052811.192712-8-sj@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The newly added `damon_test_nr_samples_per_aggr` test uses tautological assertions that will always pass, failing to detect the regressions it was intended to prevent. Additionally, the test setup overflows to zero on 32-bit architectures.
--

--- Patch [7]: [RFC PATCH 07/10] mm/damon/tests/core-kunit: test damon_nr_samples_per_aggr() ---
commit 50a7320dda40ca169bc23924caa1421599f78314
Author: SJ Park <sj@kernel.org>

mm/damon/tests/core-kunit: test damon_nr_samples_per_aggr()

This commit adds a kunit test for damon_nr_samples_per_aggr() to ensure
that extreme interval setups are handled properly without returning zero
or random overflowed values.

> diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> index 3041b8288ec26..511f2856d343c 100644
> --- a/mm/damon/tests/core-kunit.h
> +++ b/mm/damon/tests/core-kunit.h

[ ... ]

> +static void damon_test_nr_samples_per_aggr(struct kunit *test)
> +{
> +	struct damon_attrs attrs = {
> +		.sample_interval = 0,
> +		.aggr_interval = 0,
> +	};
> +
> +	/* Zero aggregation interval doesn't cause division by zero */
> +	KUNIT_EXPECT_EQ(test, damon_nr_samples_per_aggr(&attrs), 1);
> +
> +	/* Too large aggregation interval doesn't cause overflow */
> +	attrs.aggr_interval = (unsigned long)UINT_MAX + 1;

[Severity: Medium]
On 32-bit systems where unsigned long is 32-bits wide, does this assignment
overflow to 0?

If it overflows, the test would configure an interval of 0 instead of a value
larger than UINT_MAX, failing to test the large-interval scenario.

> +	KUNIT_EXPECT_GE(test, damon_nr_samples_per_aggr(&attrs), 0);
> +	KUNIT_EXPECT_LE(test, damon_nr_samples_per_aggr(&attrs), UINT_MAX);
> +}

[Severity: Medium]
Since damon_nr_samples_per_aggr() returns an unsigned int, are these
assertions tautological?

An unsigned int is inherently always >= 0 and <= UINT_MAX. This means the
test will pass regardless of the function's return value, and it wouldn't
catch if the function unexpectedly returned 0.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260728052811.192712-1-sj@kernel.org?part=7

  reply	other threads:[~2026-07-28  5:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28  5:27 [RFC PATCH 00/10] mm/damon: cleanup code, add test cases, and update guidances in docs SJ Park
2026-07-28  5:28 ` [RFC PATCH 01/10] mm/damon/core: use damon_nr_samples_per_aggr() for max merge threshold SJ Park
2026-07-28  5:28 ` [RFC PATCH 02/10] mm/damon/core: remove debug messages SJ Park
2026-07-28  5:28 ` [RFC PATCH 03/10] mm/damon/vaddr: remove a debug message SJ Park
2026-07-28  5:32   ` sashiko-bot
2026-07-28  5:39     ` SJ Park
2026-07-28  5:28 ` [RFC PATCH 04/10] mm/damon/tests/core-kunit: extend set_regions() test for error case SJ Park
2026-07-28  5:28 ` [RFC PATCH 05/10] mm/damon/tests/core-kunit: test <=0 size damon_set_regions() inputs SJ Park
2026-07-28  5:28 ` [RFC PATCH 06/10] mm/damon/tests/core-kunit: test overlapping ranges for set_regions() SJ Park
2026-07-28  5:28 ` [RFC PATCH 07/10] mm/damon/tests/core-kunit: test damon_nr_samples_per_aggr() SJ Park
2026-07-28  5:33   ` sashiko-bot [this message]
2026-07-28  5:54     ` SJ Park
2026-07-28  5:28 ` [RFC PATCH 08/10] selftests/damon/sysfs.sh: test hugepage_mem_bp quota goal SJ Park
2026-07-28  5:35   ` sashiko-bot
2026-07-28  5:56     ` SJ Park
2026-07-28  5:28 ` [RFC PATCH 09/10] Docs/mm/damon/maintainer-profile: update AI review for Sashiko replies SJ Park
2026-07-28  5:28 ` [RFC PATCH 10/10] Docs/ABI/damon: recommend subsystem doc instead of admin-guide SJ Park

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=20260728053344.A42901F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=damon@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sj@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.