All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrea Cervesato via ltp <ltp@lists.linux.it>
To: "Piotr Kubaj" <piotr.kubaj@intel.com>
Cc: daniel.niestepski@intel.com, tomasz.ossowski@intel.com,
	helena.anna.dubel@intel.com, rafael.j.wysocki@intel.com,
	ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v14] thermal: add new test group
Date: Thu, 26 Mar 2026 08:58:55 +0000	[thread overview]
Message-ID: <69c4f550.050a0220.1d2cf9.0560@mx.google.com> (raw)
In-Reply-To: <20260325105533.259287-2-piotr.kubaj@intel.com>

Hi Piotr,

> +static int nproc, temp_high, temp, trip, tz_counter;

`trip` is a single int, but cleanup() uses it to restore trip_point_1_temp
for ALL x86_pkg_temp zones. If there are multiple such zones, each
test_zone() call overwrites `trip` at the SAFE_FILE_SCANF, so only the
last zone's original value survives. The earlier zones get the wrong
value restored.

This needs to be a per-zone array, e.g. `static int *trip_orig;`
allocated alongside x86_pkg_temp_tz in setup(), with each zone's
original trip value saved individually.

> +	interrupt_init = calloc(nproc, sizeof(uint64_t));
> +	interrupt_later = calloc(nproc, sizeof(uint64_t));

[...]

> +	x86_pkg_temp_tz = calloc(tz_counter, sizeof(bool));

LTP has SAFE_CALLOC() in tst_safe_macros.h. Please use it instead of
raw calloc() — it handles the NULL check and calls tst_brk(TBROK) on
failure.

> +			tst_res(TDEBUG, "interrupts[%d]: %ld", i, interrupts[i]);

interrupts[i] is uint64_t but printed with %ld. Use PRIu64:

    tst_res(TDEBUG, "interrupts[%d]: %" PRIu64, i, interrupts[i]);

Same issue below in run():

> +				tst_res(TFAIL, "CPU %d interrupt counter: %ld (previous: %ld)",
> +					i, interrupt_later[i], interrupt_init[i]);

> +		SAFE_FILE_SCANF(path, "%s", line);

%s without a width limit can overflow line[8192]. Use "%8191s".

> +static void *cpu_workload(double run_time)
> +{

[...]

> +	return NULL;
> +}

cpu_workload() returns void * as if it were a pthread start routine, but
it is only called directly from the child process. It should return void.

> +	for (int i = 0; i < tz_counter; i++) {
> +		if (x86_pkg_temp_tz[i]) {
> +			read_interrupts(interrupt_init, nproc);
> +			test_zone(i);
> +			read_interrupts(interrupt_later, nproc);
> +			for (int i = 0; i < nproc; i++) {

Inner `i` shadows the outer loop variable `i`. Please rename to `j` or
`cpu` to avoid confusion.

Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

      parent reply	other threads:[~2026-03-26  8:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-25 10:55 [LTP] [PATCH v14] thermal: add new test group Piotr Kubaj
2026-03-25 12:49 ` Petr Vorel
2026-03-26  8:58 ` Andrea Cervesato via ltp [this message]

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=69c4f550.050a0220.1d2cf9.0560@mx.google.com \
    --to=ltp@lists.linux.it \
    --cc=andrea.cervesato@suse.com \
    --cc=daniel.niestepski@intel.com \
    --cc=helena.anna.dubel@intel.com \
    --cc=piotr.kubaj@intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=tomasz.ossowski@intel.com \
    /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.