[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <41373082-e421-496f-955d-bc9abbf44be4@redhat.com>
Date: Tue, 25 Nov 2025 16:50:52 -0500
From: David Arcari <darcari@...hat.com>
To: Len Brown <lenb@...nel.org>
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] tools/power turbostat: avoid an infinite loop of
restarts
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@...hat.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@...hat.com>
>> Cc: Len Brown <lenb@...nel.org>
>> Cc: linux-kernel@...r.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
>>
>>
>
>
Powered by blists - more mailing lists