From: David Arcari <darcari@redhat.com>
To: Len Brown <lenb@kernel.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] tools/power turbostat: avoid an infinite loop of restarts
Date: Tue, 25 Nov 2025 16:50:52 -0500 [thread overview]
Message-ID: <41373082-e421-496f-955d-bc9abbf44be4@redhat.com> (raw)
In-Reply-To: <CAJvTdK=tw76+79sCAa3TbVQwDdv9EGCWVrFvFbHihtH3jNcDWw@mail.gmail.com>
I see. Perhaps this isn't fixable then. I'll take another look.
-DA
On 11/25/25 2:12 PM, Len Brown wrote:
> this patch introduces a limit of 10-restarts per turbostat lifetime,
> down from infinity.
>
> some turbostat invocations span multiple uses of cpu online/offline --
> so this limit will not fly.
>
> On Tue, Nov 18, 2025 at 10:58 AM David Arcari <darcari@redhat.com> wrote:
>>
>> There are some error cases where turbostat will attempt to reinitialize
>> by calling the re_initialize() function. The code attempts to avoid
>> an infinite loop by checking the value of 'restarted' in one case, but
>> not others. It should be checked in all cases of restart. Additonally,
>> the 'restarted' is reset to zero at the start of the loop which also
>> needs to be removed.
>>
>> Signed-off-by: David Arcari <darcari@redhat.com>
>> Cc: Len Brown <lenb@kernel.org>
>> Cc: linux-kernel@vger.kernel.org
>> ---
>> tools/power/x86/turbostat/turbostat.c | 10 +++++-----
>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
>> index 584b0f7f9067..5567b9ecd516 100644
>> --- a/tools/power/x86/turbostat/turbostat.c
>> +++ b/tools/power/x86/turbostat/turbostat.c
>> @@ -6722,7 +6722,11 @@ void turbostat_loop()
>> set_my_sched_priority(-20);
>>
>> restart:
>> - restarted++;
>> + if (restarted++ > 10) {
>> + if (!retval)
>> + retval = -1;
>> + exit(retval);
>> + }
>>
>> snapshot_proc_sysfs_files();
>> retval = for_all_cpus(get_counters, EVEN_COUNTERS);
>> @@ -6730,13 +6734,9 @@ void turbostat_loop()
>> if (retval < -1) {
>> exit(retval);
>> } else if (retval == -1) {
>> - if (restarted > 10) {
>> - exit(retval);
>> - }
>> re_initialize();
>> goto restart;
>> }
>> - restarted = 0;
>> done_iters = 0;
>> gettimeofday(&tv_even, (struct timezone *)NULL);
>>
>> --
>> 2.51.0
>>
>>
>
>
next prev parent reply other threads:[~2025-11-25 21:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-18 15:58 [PATCH 0/3] tools/power turbostat: Fix segfault and restart loop issues David Arcari
2025-11-18 15:58 ` [PATCH 1/3] tools/power turbostat: avoid segfault referencing fd_instr_count_percpu David Arcari
2025-11-25 19:11 ` Len Brown
2025-12-01 14:13 ` David Arcari
2025-11-18 15:58 ` [PATCH 2/3] tools/power turbostat: avoid an infinite loop of restarts David Arcari
2025-11-25 19:12 ` Len Brown
2025-11-25 21:50 ` David Arcari [this message]
2025-11-27 17:45 ` Len Brown
2025-12-01 12:18 ` David Arcari
2025-11-18 15:58 ` [PATCH 3/3] tools/power turbostat: allow turbostat to work when aperf is not available David Arcari
2025-11-25 19:14 ` Len Brown
2025-11-25 21:55 ` David Arcari
2025-12-01 15:13 ` David Arcari
2025-12-01 19:53 ` Len Brown
2025-12-01 20:11 ` Len Brown
2025-12-02 12:55 ` David Arcari
2025-12-02 15:02 ` Len Brown
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=41373082-e421-496f-955d-bc9abbf44be4@redhat.com \
--to=darcari@redhat.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
/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
all inboxes | Powered by JetHome®