From: sashiko-bot@kernel.org
To: "James Clark" <james.clark@linaro.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 05/18] perf test: Add deterministic workload
Date: Tue, 02 Jun 2026 14:49:29 +0000 [thread overview]
Message-ID: <20260602144929.DEDC61F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260602-james-cs-context-tracking-fix-v2-5-85b5ce6f55c6@linaro.org>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] Signed integer overflow in dt_work causes Undefined Behavior
- [Medium] Workload state leakage breaks data determinism on consecutive runs
- [Low] Build failure due to missing `-U_FORTIFY_SOURCE` with `-O0`
- [Low] Global namespace pollution from non-static `dt_work`
--
commit cdb1ed35f7dbaf322c0b18289b38a7da8d21039e
Author: James Clark <james.clark@linaro.org>
perf test: Add deterministic workload
This commit adds a new workload for testing CPU trace decoding. It introduces
a deterministic sequence of multiplications and function calls that can be
used to verify expected behavior across test runs.
[ ... ]
> diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/Build
> index 3bda6da04a350..599a37c87878f 100644
> --- a/tools/perf/tests/workloads/Build
> +++ b/tools/perf/tests/workloads/Build
[ ... ]
> @@ -22,3 +23,4 @@ CFLAGS_brstack.o = -g -O0 -fno-inline -U_FORTIFY_SOURCE
> CFLAGS_datasym.o = -g -O0 -fno-inline -U_FORTIFY_SOURCE
> CFLAGS_traploop.o = -g -O0 -fno-inline -U_FORTIFY_SOURCE
> CFLAGS_inlineloop.o = -g -O2
> +CFLAGS_deterministic.o = -g -O0
[Severity: Low]
Does this code introduce a build regression on systems with glibc?
Since the perf build system globally defines _FORTIFY_SOURCE=2 and enables
-Werror by default, compiling with -O0 without also passing -U_FORTIFY_SOURCE
can trigger a warning from <features.h> ("_FORTIFY_SOURCE requires compiling
with optimization (-O)"), which is then escalated to an error.
> diff --git a/tools/perf/tests/workloads/deterministic.c b/tools/perf/tests/workloads/deterministic.c
> new file mode 100644
> index 0000000000000..3caea8564043c
> --- /dev/null
> +++ b/tools/perf/tests/workloads/deterministic.c
> @@ -0,0 +1,39 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <linux/compiler.h>
> +#include "../tests.h"
> +
> +int dt_work = 1234;
[Severity: Low]
Should dt_work be declared static?
It is currently declared at global scope without a unique prefix, which exposes
it to the entire perf tool binary.
[Severity: Medium]
Will dt_work experience undefined behavior due to signed integer overflow?
The variable is initialized to 1234 and is unconditionally multiplied by 7
twelve times during the execution of deterministic(). The 8th multiplication
results in 7,113,764,434, which exceeds the maximum value of a 32-bit signed
integer.
Could this cause crashes if the perf tool is built with undefined behavior
sanitizer? Perhaps dt_work could be unsigned int or unsigned long long
instead.
> +
> +static noinline void function1(void)
> +{
> + dt_work *= 7;
[ ... ]
> +static int deterministic(int argc __maybe_unused,
> + const char **argv __maybe_unused)
> +{
[Severity: Medium]
Does this code break data determinism on consecutive test runs?
If the workload is executed multiple times within the same process (for example,
using perf test -w deterministic -r N), dt_work will start from the final
overflowed value of the previous run rather than being reset to 1234.
> + dt_work *= 7;
> + dt_work *= 7;
> + dt_work *= 7;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260602-james-cs-context-tracking-fix-v2-0-85b5ce6f55c6@linaro.org?part=5
next prev parent reply other threads:[~2026-06-02 14:49 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 14:26 [PATCH v2 00/18] perf cs-etm: Queue context packets for frontend James Clark
2026-06-02 14:26 ` [PATCH v2 01/18] " James Clark
2026-06-02 14:43 ` sashiko-bot
2026-06-02 14:26 ` [PATCH v2 02/18] perf test: Add workload-ctl option James Clark
2026-06-02 14:40 ` sashiko-bot
2026-06-02 14:26 ` [PATCH v2 03/18] perf test: Add a workload that forces context switches James Clark
2026-06-02 14:38 ` sashiko-bot
2026-06-02 14:26 ` [PATCH v2 04/18] perf test cs-etm: Test process attribution James Clark
2026-06-02 14:26 ` [PATCH v2 05/18] perf test: Add deterministic workload James Clark
2026-06-02 14:49 ` sashiko-bot [this message]
2026-06-02 14:26 ` [PATCH v2 06/18] perf test cs-etm: Replace unroll loop thread with deterministic decode test James Clark
2026-06-02 14:26 ` [PATCH v2 07/18] perf test cs-etm: Remove asm_pure_loop test James Clark
2026-06-02 14:26 ` [PATCH v2 08/18] perf test cs-etm: Replace memcpy test with raw dump stress test James Clark
2026-06-02 15:01 ` sashiko-bot
2026-06-02 14:26 ` [PATCH v2 09/18] perf test: Add named_threads workload James Clark
2026-06-02 15:01 ` sashiko-bot
2026-06-02 14:26 ` [PATCH v2 10/18] perf test cs-etm: Test decoding for concurrent threads test James Clark
2026-06-02 14:26 ` [PATCH v2 11/18] perf test cs-etm: Remove duplicate branch tests James Clark
2026-06-02 15:05 ` sashiko-bot
2026-06-02 14:26 ` [PATCH v2 12/18] perf test cs-etm: Reduce snapshot size James Clark
2026-06-02 14:26 ` [PATCH v2 13/18] perf test cs-etm: Speed up basic test James Clark
2026-06-02 14:26 ` [PATCH v2 14/18] perf test cs-etm: Remove unused Coresight workloads James Clark
2026-06-02 14:26 ` [PATCH v2 15/18] perf test cs-etm: Make disassembly test use kcore James Clark
2026-06-02 14:26 ` [PATCH v2 16/18] perf test cs-etm: Add all branch instructions to test James Clark
2026-06-02 14:26 ` [PATCH v2 17/18] perf test cs-etm: Speed up disassembly test James Clark
2026-06-02 15:26 ` sashiko-bot
2026-06-02 14:27 ` [PATCH v2 18/18] perf test cs-etm: Move existing tests to coresight folder James Clark
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=20260602144929.DEDC61F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=james.clark@linaro.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox