public inbox for ltp@lists.linux.it
 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 v6] high_freq_hwp_cap_cppc.c: new test
Date: Wed, 25 Mar 2026 12:24:15 +0000	[thread overview]
Message-ID: <69c3d3f0.050a0220.2bacda.8597@mx.google.com> (raw)
In-Reply-To: <20260323113940.188663-2-piotr.kubaj@intel.com>

Hi Piotr,

Thanks for the new test. A few issues below.

> +/*
> + * Copyright (C) 2026 Intel - http://www.intel.com/
> + */

The copyright line should include an author name and email, e.g.:

  Copyright (c) 2026 Piotr Kubaj <piotr.kubaj@intel.com>

> +		if (i)
> +			SAFE_FILE_SCANF(path, "%d", &online);

SAFE_FILE_SCANF with "%d" expects a pointer to int, but `online` is
bool (typically 1 byte). This is undefined behavior and will likely
corrupt the stack on little-endian. Please use `int online = 1;`
instead.

This should be spotted by any static analyzer or clangd..and even
gcc shows this error.

> +		snprintf(path, sizeof(path), "/dev/cpu/%d/msr", i);
> +		int fd = SAFE_OPEN(path, O_RDONLY);
> +
> +		SAFE_PREAD(1, fd, &msr_highest_perf, sizeof(msr_highest_perf), 0x771);

SAFE_CLOSE(fd) right after it has been used. There's no need to keep it
open after pread().

> +		msr_highest_perf &= (1ULL << 8) - 1;

0x771 and the 8-bit mask are magic numbers. Named defines would
help readability, e.g.:

  #define MSR_HWP_CAPABILITIES  0x771
  #define HIGHEST_PERF_MASK     0xFF

The test fails because msr device is not available, so you need:

  .needs_drivers = (const char *const []) {                                                                                                        
      "msr",                                                                                                                                       
      NULL                                                                                                                                         
  },

And probably the CONFIG_X86_MSR=y check as well.

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

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

  reply	other threads:[~2026-03-25 12:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-23 11:39 [LTP] [PATCH v6] high_freq_hwp_cap_cppc.c: new test Piotr Kubaj
2026-03-25 12:24 ` Andrea Cervesato via ltp [this message]
2026-03-30 11:58   ` Kubaj, Piotr

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=69c3d3f0.050a0220.2bacda.8597@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox