mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-03-01 12:00:18 +07:00
tools/power turbostat: prevent infinite loop on migration error path
Turbostat assumed if it can't migrate to a CPU, then the CPU must have gone off-line and turbostat should re-initialize with the new topology. But if turbostat can not migrate because it is restricted by a cpuset, then it will fail to migrate even after re-initialization, resulting in an infinite loop. Spit out a warning when we can't migrate and endure only 2 re-initialize cycles in a row before giving up and exiting. Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
parent
3fc808aaa0
commit
e52966c084
@ -656,8 +656,10 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
|
|||||||
{
|
{
|
||||||
int cpu = t->cpu_id;
|
int cpu = t->cpu_id;
|
||||||
|
|
||||||
if (cpu_migrate(cpu))
|
if (cpu_migrate(cpu)) {
|
||||||
|
fprintf(stderr, "Could not migrate to CPU %d\n", cpu);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
t->tsc = rdtsc(); /* we are running on local CPU of interest */
|
t->tsc = rdtsc(); /* we are running on local CPU of interest */
|
||||||
|
|
||||||
@ -1088,15 +1090,22 @@ int mark_cpu_present(int cpu)
|
|||||||
void turbostat_loop()
|
void turbostat_loop()
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
|
int restarted = 0;
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
|
restarted++;
|
||||||
|
|
||||||
retval = for_all_cpus(get_counters, EVEN_COUNTERS);
|
retval = for_all_cpus(get_counters, EVEN_COUNTERS);
|
||||||
if (retval < -1) {
|
if (retval < -1) {
|
||||||
exit(retval);
|
exit(retval);
|
||||||
} else if (retval == -1) {
|
} else if (retval == -1) {
|
||||||
|
if (restarted > 1) {
|
||||||
|
exit(retval);
|
||||||
|
}
|
||||||
re_initialize();
|
re_initialize();
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
|
restarted = 0;
|
||||||
gettimeofday(&tv_even, (struct timezone *)NULL);
|
gettimeofday(&tv_even, (struct timezone *)NULL);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user