Re: [LTP] [PATCH v2] thermal: add new test group

Kubaj, Piotr
2026-01-23T12:37:51Z

2026-01-22 (木) の 15:27 +0100 に Petr Vorel さんは書きました:
> 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

Hi,

I tried:
SAFE_SSCANF(line, " TRM:%sThermal event interrupts", buffer);

But it's the same as before, only the first number ends up in the
buffer. Still, even if I managed to put them all into buffer, I would
still need to later divide them into individual elements of
interrupt_array and strtok seems fit for that.
---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.
Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach handlowych.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.