From: Petr Vorel <pvorel@suse.cz>
To: "Kubaj, Piotr" <piotr.kubaj@intel.com>
Cc: "Wysocki, Rafael J" <rafael.j.wysocki@intel.com>,
"Ossowski, Tomasz" <tomasz.ossowski@intel.com>,
"Dubel, Helena Anna" <helena.anna.dubel@intel.com>,
"Niestepski, Daniel" <daniel.niestepski@intel.com>,
"ltp@lists.linux.it" <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v2] thermal: add new test group
Date: Thu, 22 Jan 2026 15:27:01 +0100 [thread overview]
Message-ID: <20260122142701.GA78350@pevik> (raw)
In-Reply-To: <4dd67d8bf040715bf5a6456bb4270f08dba3986b.camel@intel.com>
Hi Piotr,
...
> > > + bool interrupts_found = 0;
> > > + char line[8192];
> > very nit: IMHO 1024 would be more than enough, but whatever.
> And I wasn't even sure 8192 would be enough. The reason is that, since
> it's a string, every digit is a single array element. With new 2S or 4S
> systems with hundreds of cores and each interrupt being up to 2^64,
> even 8192 might not be enough.
OK.
> > > +
> > > + memset(interrupt_array, 0, nproc *
> > > sizeof(*interrupt_array));
> > > + FILE *fp = SAFE_FOPEN("/proc/interrupts", "r");
> > > +
> > > + while (fgets(line, sizeof(line), fp)) {
> > > + if (strstr(line, "Thermal event interrupts")) {
> > Can't we use FILE_LINES_SCANF() or SAFE_FILE_LINES_SCANF() to instead
> > of whole
> > while() block to simplify?
> > See example code
> > https://github.com/linux-test-project/ltp/tree/master/lib/newlib_tests/tst_safe_fileops.c
> It's quite unclear to me. SAFE_FILE_LINES_SCANF() seems fine for
> reading a single interrupt number or even multiple, but only when well
> known how many cores we have. Here the number of elements in the array
> is equal to the number of logical cores the system has, in my case
> it's:
> TRM: 7795 7795 7795 7795 7800 7800
> 7797 7797 7795 7795 7886 7886 7860
> 7860 7863 7863 7795 7795 7795 7795
> 7795 7795 7795 7795 Thermal event interrupts
> I tried:
> SAFE_FILE_LINES_SCANF("/proc/interrupts", " TRM:%sThermal event
> interrupts", line);
> to fit all the numbers in "line" string and then later parse them, but
> only the 1st number is read. Here we need to have all of them.
I'm sorry, I was wrong here. Yes, you right SAFE_FILE_LINES_SCANF() scans whole
file at once. With generic pattern it can cumulate the results (otherwise with
specific enough it finds only single place). Anyway, not suitable for you.
But you could process each line with SAFE_SSCANF(), that would help to avoid
strtok() (simplify code a lot).
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-01-22 14:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-20 14:46 [LTP] [PATCH v2] thermal: add new test group Piotr Kubaj
2026-01-20 19:38 ` Petr Vorel
2026-01-21 11:55 ` Kubaj, Piotr
2026-01-21 23:06 ` Petr Vorel
2026-01-22 14:27 ` Petr Vorel [this message]
2026-01-23 12:37 ` Kubaj, Piotr
2026-01-23 19:48 ` Petr Vorel
-- strict thread matches above, loose matches on Subject: below --
2025-11-14 18:01 Piotr Kubaj
2025-11-18 18:18 ` Cyril Hrubis
2025-11-19 9:35 ` Cyril Hrubis
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=20260122142701.GA78350@pevik \
--to=pvorel@suse.cz \
--cc=daniel.niestepski@intel.com \
--cc=helena.anna.dubel@intel.com \
--cc=ltp@lists.linux.it \
--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