mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 21:51:40 +00:00
tools/power/turbostat: Introduce cpu_allowed_set
Turbostat supports "-c" parameter which limits output to system summary plus the specified cpu-set. But some code still uses cpu_present_set to read and dump the counters. Introduce cpu_allowed_set for code that should obey the specified cpu-set. No functional change. Signed-off-by: Zhang Rui <rui.zhang@intel.com>
This commit is contained in:
parent
6b74a30b76
commit
71cfd1da9f
@ -904,8 +904,8 @@ int backwards_count;
|
||||
char *progname;
|
||||
|
||||
#define CPU_SUBSET_MAXCPUS 1024 /* need to use before probe... */
|
||||
cpu_set_t *cpu_present_set, *cpu_affinity_set, *cpu_subset;
|
||||
size_t cpu_present_setsize, cpu_affinity_setsize, cpu_subset_size;
|
||||
cpu_set_t *cpu_present_set, *cpu_allowed_set, *cpu_affinity_set, *cpu_subset;
|
||||
size_t cpu_present_setsize, cpu_allowed_setsize, cpu_affinity_setsize, cpu_subset_size;
|
||||
#define MAX_ADDED_COUNTERS 8
|
||||
#define MAX_ADDED_THREAD_COUNTERS 24
|
||||
#define BITMASK_SIZE 32
|
||||
@ -1157,6 +1157,11 @@ int cpu_is_not_present(int cpu)
|
||||
return !CPU_ISSET_S(cpu, cpu_present_setsize, cpu_present_set);
|
||||
}
|
||||
|
||||
int cpu_is_not_allowed(int cpu)
|
||||
{
|
||||
return !CPU_ISSET_S(cpu, cpu_allowed_setsize, cpu_allowed_set);
|
||||
}
|
||||
|
||||
/*
|
||||
* run func(thread, core, package) in topology order
|
||||
* skip non-present cpus
|
||||
@ -3396,6 +3401,10 @@ void free_all_buffers(void)
|
||||
cpu_present_set = NULL;
|
||||
cpu_present_setsize = 0;
|
||||
|
||||
CPU_FREE(cpu_allowed_set);
|
||||
cpu_allowed_set = NULL;
|
||||
cpu_allowed_setsize = 0;
|
||||
|
||||
CPU_FREE(cpu_affinity_set);
|
||||
cpu_affinity_set = NULL;
|
||||
cpu_affinity_setsize = 0;
|
||||
@ -5697,13 +5706,29 @@ void topology_probe()
|
||||
CPU_ZERO_S(cpu_present_setsize, cpu_present_set);
|
||||
for_all_proc_cpus(mark_cpu_present);
|
||||
|
||||
/*
|
||||
* Allocate and initialize cpu_allowed_set
|
||||
*/
|
||||
cpu_allowed_set = CPU_ALLOC((topo.max_cpu_num + 1));
|
||||
if (cpu_allowed_set == NULL)
|
||||
err(3, "CPU_ALLOC");
|
||||
cpu_allowed_setsize = CPU_ALLOC_SIZE((topo.max_cpu_num + 1));
|
||||
CPU_ZERO_S(cpu_allowed_setsize, cpu_allowed_set);
|
||||
|
||||
/*
|
||||
* Validate that all cpus in cpu_subset are also in cpu_present_set
|
||||
*/
|
||||
for (i = 0; i < CPU_SUBSET_MAXCPUS; ++i) {
|
||||
if (CPU_ISSET_S(i, cpu_subset_size, cpu_subset))
|
||||
if (!cpu_subset) {
|
||||
if (CPU_ISSET_S(i, cpu_present_setsize, cpu_present_set))
|
||||
CPU_SET_S(i, cpu_allowed_setsize, cpu_allowed_set);
|
||||
continue;
|
||||
}
|
||||
if (CPU_ISSET_S(i, cpu_subset_size, cpu_subset)) {
|
||||
if (!CPU_ISSET_S(i, cpu_present_setsize, cpu_present_set))
|
||||
err(1, "cpu%d not present", i);
|
||||
CPU_SET_S(i, cpu_allowed_setsize, cpu_allowed_set);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user