diff options
Diffstat (limited to 'tools/power/x86/turbostat/turbostat.c')
| -rw-r--r-- | tools/power/x86/turbostat/turbostat.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index ab2f682fd44c..16de7ad4850f 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c | |||
| @@ -73,8 +73,8 @@ int backwards_count; | |||
| 73 | char *progname; | 73 | char *progname; |
| 74 | 74 | ||
| 75 | int num_cpus; | 75 | int num_cpus; |
| 76 | cpu_set_t *cpu_mask; | 76 | cpu_set_t *cpu_present_set, *cpu_mask; |
| 77 | size_t cpu_mask_size; | 77 | size_t cpu_present_setsize, cpu_mask_size; |
| 78 | 78 | ||
| 79 | struct counters { | 79 | struct counters { |
| 80 | unsigned long long tsc; /* per thread */ | 80 | unsigned long long tsc; /* per thread */ |
| @@ -103,6 +103,12 @@ struct timeval tv_even; | |||
| 103 | struct timeval tv_odd; | 103 | struct timeval tv_odd; |
| 104 | struct timeval tv_delta; | 104 | struct timeval tv_delta; |
| 105 | 105 | ||
| 106 | int mark_cpu_present(int pkg, int core, int cpu) | ||
| 107 | { | ||
| 108 | CPU_SET_S(cpu, cpu_present_setsize, cpu_present_set); | ||
| 109 | return 0; | ||
| 110 | } | ||
| 111 | |||
| 106 | /* | 112 | /* |
| 107 | * cpu_mask_init(ncpus) | 113 | * cpu_mask_init(ncpus) |
| 108 | * | 114 | * |
| @@ -118,6 +124,18 @@ void cpu_mask_init(int ncpus) | |||
| 118 | } | 124 | } |
| 119 | cpu_mask_size = CPU_ALLOC_SIZE(ncpus); | 125 | cpu_mask_size = CPU_ALLOC_SIZE(ncpus); |
| 120 | CPU_ZERO_S(cpu_mask_size, cpu_mask); | 126 | CPU_ZERO_S(cpu_mask_size, cpu_mask); |
| 127 | |||
| 128 | /* | ||
| 129 | * Allocate and initialize cpu_present_set | ||
| 130 | */ | ||
| 131 | cpu_present_set = CPU_ALLOC(ncpus); | ||
| 132 | if (cpu_present_set == NULL) { | ||
| 133 | perror("CPU_ALLOC"); | ||
| 134 | exit(3); | ||
| 135 | } | ||
| 136 | cpu_present_setsize = CPU_ALLOC_SIZE(ncpus); | ||
| 137 | CPU_ZERO_S(cpu_present_setsize, cpu_present_set); | ||
| 138 | for_all_cpus(mark_cpu_present); | ||
| 121 | } | 139 | } |
| 122 | 140 | ||
| 123 | void cpu_mask_uninit() | 141 | void cpu_mask_uninit() |
| @@ -125,6 +143,9 @@ void cpu_mask_uninit() | |||
| 125 | CPU_FREE(cpu_mask); | 143 | CPU_FREE(cpu_mask); |
| 126 | cpu_mask = NULL; | 144 | cpu_mask = NULL; |
| 127 | cpu_mask_size = 0; | 145 | cpu_mask_size = 0; |
| 146 | CPU_FREE(cpu_present_set); | ||
| 147 | cpu_present_set = NULL; | ||
| 148 | cpu_present_setsize = 0; | ||
| 128 | } | 149 | } |
| 129 | 150 | ||
| 130 | int cpu_migrate(int cpu) | 151 | int cpu_migrate(int cpu) |
| @@ -912,6 +933,8 @@ int is_snb(unsigned int family, unsigned int model) | |||
| 912 | switch (model) { | 933 | switch (model) { |
| 913 | case 0x2A: | 934 | case 0x2A: |
| 914 | case 0x2D: | 935 | case 0x2D: |
| 936 | case 0x3A: /* IVB */ | ||
| 937 | case 0x3D: /* IVB Xeon */ | ||
| 915 | return 1; | 938 | return 1; |
| 916 | } | 939 | } |
| 917 | return 0; | 940 | return 0; |
| @@ -1047,6 +1070,9 @@ int fork_it(char **argv) | |||
| 1047 | int retval; | 1070 | int retval; |
| 1048 | pid_t child_pid; | 1071 | pid_t child_pid; |
| 1049 | get_counters(cnt_even); | 1072 | get_counters(cnt_even); |
| 1073 | |||
| 1074 | /* clear affinity side-effect of get_counters() */ | ||
| 1075 | sched_setaffinity(0, cpu_present_setsize, cpu_present_set); | ||
| 1050 | gettimeofday(&tv_even, (struct timezone *)NULL); | 1076 | gettimeofday(&tv_even, (struct timezone *)NULL); |
| 1051 | 1077 | ||
| 1052 | child_pid = fork(); | 1078 | child_pid = fork(); |
