From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 03/12] perf tests workloads: Support sub-second durations in noploop and thloop
Date: Tue, 16 Jun 2026 01:35:56 +0000 [thread overview]
Message-ID: <20260616013557.0389E1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260616012744.4049193-4-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Small sub-second durations or non-finite inputs (NaN/Infinity) truncate to zero and cancel the alarm, resulting in an infinite loop.
--
commit 00c5973576e890f274ed5c092471d3ff5f7e1ded
Author: Ian Rogers <irogers@google.com>
perf tests workloads: Support sub-second durations in noploop and thloop
This commit updates the noploop and thloop workloads to use atof() for
parsing the duration argument, allowing sub-second execution times. It uses
ualarm() for fractional durations under 1.0 second and falls back to
alarm() otherwise.
> diff --git a/tools/perf/tests/workloads/noploop.c b/tools/perf/tests/workloads/noploop.c
> --- a/tools/perf/tests/workloads/noploop.c
> +++ b/tools/perf/tests/workloads/noploop.c
[ ... ]
> @@ -15,15 +15,24 @@ static void sighandler(int sig __maybe_unused)
>
> static int noploop(int argc, const char **argv)
> {
[ ... ]
> + if (sec <= 0.0) {
> + fprintf(stderr, "Error: seconds (%f) must be > 0\n", sec);
> + return 1;
> + }
>
> signal(SIGINT, sighandler);
> signal(SIGALRM, sighandler);
> - alarm(sec);
> +
> + if (sec < 1.0)
> + ualarm((useconds_t)(sec * 1000000.0), 0);
> + else
> + alarm((unsigned int)sec);
[Severity: Medium]
Could very small sub-second values or NaN inputs cause this to spin
infinitely?
If sec is NaN, the relational check sec <= 0.0 evaluates to false. Execution
falls through to the else block, casting NaN to unsigned int, which typically
results in 0 being passed to alarm().
Similarly, if sec is a very small positive value like 1e-7, it passes the
sec <= 0.0 error check. The calculation sec * 1000000.0 evaluates to 0.1,
which truncates to 0 when cast to useconds_t for ualarm().
Passing 0 to either alarm() or ualarm() cancels the timer entirely. Because
the timer is disabled, the signal handler is never invoked to set the done
flag, resulting in an infinite loop.
> while (!done)
> continue;
[ ... ]
> diff --git a/tools/perf/tests/workloads/thloop.c b/tools/perf/tests/workloads/thloop.c
> --- a/tools/perf/tests/workloads/thloop.c
> +++ b/tools/perf/tests/workloads/thloop.c
[ ... ]
> @@ -67,7 +68,10 @@ static int thloop(int argc, const char **argv)
> goto out;
> }
> }
> - alarm(sec);
> + if (sec < 1.0)
> + ualarm((useconds_t)(sec * 1000000.0), 0);
> + else
> + alarm((unsigned int)sec);
[Severity: Medium]
Does this exhibit the same truncation to zero behavior with NaN or very small
sub-second inputs as the noploop workload?
> test_loop();
> err = 0;
> out:
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260616012744.4049193-1-irogers@google.com?part=3
next prev parent reply other threads:[~2026-06-16 1:35 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 1:27 [PATCH v1 00/12] perf tests: Enhancements, speedups, and flakiness fixes Ian Rogers
2026-06-16 1:27 ` [PATCH v1 01/12] perf parse-events: Restrict core PMU bypass to --cputype option Ian Rogers
2026-06-16 1:44 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 02/12] perf test: Truncate test description to fit terminal width Ian Rogers
2026-06-16 1:38 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 03/12] perf tests workloads: Support sub-second durations in noploop and thloop Ian Rogers
2026-06-16 1:35 ` sashiko-bot [this message]
2026-06-16 1:27 ` [PATCH v1 04/12] perf tests: Add robust record retry helper and use subsecond workloads Ian Rogers
2026-06-16 1:38 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 05/12] perf tests: Skip metrics validation if system-wide recording lacks permission Ian Rogers
2026-06-16 1:41 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 06/12] perf tests: Fix Python JIT dump profiling test failure Ian Rogers
2026-06-16 1:39 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 07/12] perf tests: Fix flakiness in trace record and replay test Ian Rogers
2026-06-16 1:42 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 08/12] perf tests: Fix flakiness in BPF counters test on hybrid systems Ian Rogers
2026-06-16 1:35 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 09/12] perf tests: Fix flakiness in branch stack sampling tests Ian Rogers
2026-06-16 1:27 ` [PATCH v1 10/12] perf tests: Speed up off-cpu profiling tests Ian Rogers
2026-06-16 1:41 ` sashiko-bot
2026-06-16 1:27 ` [PATCH v1 11/12] perf tests: Speed up lock contention analysis shell test Ian Rogers
2026-06-16 1:27 ` [PATCH v1 12/12] perf tests: Speed up metrics checking shell tests Ian Rogers
2026-06-16 6:13 ` [PATCH v2 00/12] perf tests: Enhance robustness, speed up execution, and fix flakiness Ian Rogers
2026-06-16 6:13 ` [PATCH v2 01/12] perf parse-events: Restrict core PMU bypass to --cputype option Ian Rogers
2026-06-16 6:31 ` sashiko-bot
2026-06-16 6:13 ` [PATCH v2 02/12] perf test: Truncate test description to fit terminal width Ian Rogers
2026-06-16 6:24 ` sashiko-bot
2026-06-16 6:13 ` [PATCH v2 03/12] perf tests workloads: Support sub-second durations in noploop and thloop Ian Rogers
2026-06-16 6:22 ` sashiko-bot
2026-06-16 6:13 ` [PATCH v2 04/12] perf tests: Add robust record retry helper and use subsecond workloads Ian Rogers
2026-06-16 6:27 ` sashiko-bot
2026-06-16 6:13 ` [PATCH v2 05/12] perf tests: Skip metrics validation if system-wide recording lacks permission Ian Rogers
2026-06-16 6:13 ` [PATCH v2 06/12] perf tests: Fix Python JIT dump profiling test failure Ian Rogers
2026-06-16 6:27 ` sashiko-bot
2026-06-16 6:13 ` [PATCH v2 07/12] perf tests: Fix flakiness in trace record and replay test Ian Rogers
2026-06-16 6:27 ` sashiko-bot
2026-06-16 6:14 ` [PATCH v2 08/12] perf tests: Fix flakiness in BPF counters test on hybrid systems Ian Rogers
2026-06-16 6:14 ` [PATCH v2 09/12] perf tests: Fix flakiness in branch stack sampling tests Ian Rogers
2026-06-16 6:14 ` [PATCH v2 10/12] perf tests: Speed up off-cpu profiling tests Ian Rogers
2026-06-16 6:25 ` sashiko-bot
2026-06-16 6:14 ` [PATCH v2 11/12] perf tests: Speed up lock contention analysis shell test Ian Rogers
2026-06-16 6:14 ` [PATCH v2 12/12] perf tests: Speed up metrics checking shell tests Ian Rogers
-- strict thread matches above, loose matches on Subject: below --
2026-06-16 1:25 [PATCH v1 00/12] perf tests: Enhancements, speedups, and flakiness fixes Ian Rogers
2026-06-16 1:25 ` [PATCH v1 03/12] perf tests workloads: Support sub-second durations in noploop and thloop Ian Rogers
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=20260616013557.0389E1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=irogers@google.com \
--cc=linux-perf-users@vger.kernel.org \
--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 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.