Changeset d0c82c5 in mainline
- Timestamp:
- 2010-06-16T19:44:53Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5387807
- Parents:
- 5954241
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/cpu.h
r5954241 rd0c82c5 72 72 size_t missed_clock_ticks; 73 73 74 /** 75 * Processor cycle accounting. 76 */ 74 77 bool idle; 75 uint64_t idle_ticks; 76 uint64_t busy_ticks; 78 uint64_t last_cycle; 79 uint64_t idle_cycles; 80 uint64_t busy_cycles; 77 81 78 82 /** -
kernel/generic/include/sysinfo/abi.h
r5954241 rd0c82c5 69 69 bool active; /**< CPU is activate */ 70 70 uint16_t frequency_mhz; /**< Frequency in MHz */ 71 uint64_t idle_ ticks; /**< Number of idle kernel quanta*/72 uint64_t busy_ ticks; /**< Number of busy kernel quanta*/71 uint64_t idle_cycles; /**< Number of idle cycles */ 72 uint64_t busy_cycles; /**< Number of busy cycles */ 73 73 } stats_cpu_t; 74 74 -
kernel/generic/src/cpu/cpu.c
r5954241 rd0c82c5 49 49 #include <print.h> 50 50 #include <sysinfo/sysinfo.h> 51 #include <arch/cycle.h> 51 52 52 53 cpu_t *cpus; … … 94 95 CPU->tlb_active = true; 95 96 97 CPU->idle = false; 98 CPU->last_cycle = get_cycle(); 99 CPU->idle_cycles = 0; 100 CPU->busy_cycles = 0; 101 96 102 cpu_identify(); 97 103 cpu_arch_init(); -
kernel/generic/src/interrupt/interrupt.c
r5954241 rd0c82c5 99 99 void exc_dispatch(unsigned int n, istate_t *istate) 100 100 { 101 ASSERT(CPU); 102 101 103 #if (IVT_ITEMS > 0) 102 104 ASSERT(n < IVT_ITEMS); … … 109 111 irq_spinlock_unlock(&THREAD->lock, false); 110 112 } 113 114 /* Account CPU usage if it has waked up from sleep */ 115 irq_spinlock_lock(&CPU->lock, false); 116 if (CPU->idle) { 117 uint64_t now = get_cycle(); 118 CPU->idle_cycles += now - CPU->last_cycle; 119 CPU->last_cycle = now; 120 CPU->idle = false; 121 } 122 irq_spinlock_unlock(&CPU->lock, false); 111 123 112 124 uint64_t begin_cycle = get_cycle(); -
kernel/generic/src/proc/scheduler.c
r5954241 rd0c82c5 193 193 * This improves energy saving and hyperthreading. 194 194 */ 195 196 /* Mark CPU as it was idle this clock tick */197 195 irq_spinlock_lock(&CPU->lock, false); 198 196 CPU->idle = true; 199 197 irq_spinlock_unlock(&CPU->lock, false); 200 201 198 interrupts_enable(); 199 202 200 /* 203 201 * An interrupt might occur right now and wake up a thread. … … 386 384 as_t *old_as = AS; 387 385 388 ASSERT( !THREAD || irq_spinlock_locked(&THREAD->lock));386 ASSERT((!THREAD) || (irq_spinlock_locked(&THREAD->lock))); 389 387 ASSERT(CPU != NULL); 390 388 -
kernel/generic/src/sysinfo/stats.c
r5954241 rd0c82c5 124 124 stats_cpus[i].active = cpus[i].active; 125 125 stats_cpus[i].frequency_mhz = cpus[i].frequency_mhz; 126 stats_cpus[i].busy_ ticks = cpus[i].busy_ticks;127 stats_cpus[i].idle_ ticks = cpus[i].idle_ticks;126 stats_cpus[i].busy_cycles = cpus[i].busy_cycles; 127 stats_cpus[i].idle_cycles = cpus[i].idle_cycles; 128 128 129 129 irq_spinlock_unlock(&cpus[i].lock, true); -
kernel/generic/src/time/clock.c
r5954241 rd0c82c5 57 57 #include <mm/frame.h> 58 58 #include <ddi/ddi.h> 59 #include <arch/cycle.h> 59 60 60 61 /* Pointer to variable with uptime */ … … 125 126 } 126 127 128 static void cpu_update_accounting(void) 129 { 130 irq_spinlock_lock(&CPU->lock, false); 131 uint64_t now = get_cycle(); 132 CPU->busy_cycles += now - CPU->last_cycle; 133 CPU->last_cycle = now; 134 irq_spinlock_unlock(&CPU->lock, false); 135 } 136 127 137 /** Clock routine 128 138 * … … 136 146 size_t missed_clock_ticks = CPU->missed_clock_ticks; 137 147 138 /* Account lost ticks to CPU usage */ 139 if (CPU->idle) 140 CPU->idle_ticks += missed_clock_ticks + 1; 141 else 142 CPU->busy_ticks += missed_clock_ticks + 1; 143 144 CPU->idle = false; 148 /* Account CPU usage */ 149 cpu_update_accounting(); 145 150 146 151 /* … … 151 156 size_t i; 152 157 for (i = 0; i <= missed_clock_ticks; i++) { 158 /* Update counters and accounting */ 153 159 clock_update_counters(); 160 cpu_update_accounting(); 161 154 162 irq_spinlock_lock(&CPU->timeoutlock, false); 155 163 -
uspace/app/tasks/tasks.c
r5954241 rd0c82c5 165 165 for (i = 0; i < count; i++) { 166 166 if (cpus[i].active) { 167 printf("cpu%u: %" PRIu16 " MHz, busy ticks: "168 "%" PRIu64 ", idle ticks: %" PRIu64 "\n",169 cpus[i].id, cpus[i].frequency_mhz, cpus[i].busy_ ticks,170 cpus[i].idle_ ticks);167 printf("cpu%u: %" PRIu16 " MHz, busy cycles: " 168 "%" PRIu64 ", idle cycles: %" PRIu64 "\n", 169 cpus[i].id, cpus[i].frequency_mhz, cpus[i].busy_cycles, 170 cpus[i].idle_cycles); 171 171 } else { 172 172 printf("cpu%u: inactive\n", cpus[i].id); -
uspace/app/top/screen.c
r5954241 rd0c82c5 222 222 for (i = 0; i < data->cpus_count; i++) { 223 223 if (data->cpus[i].active) { 224 printf("cpu%u (%4" PRIu16 " MHz): busy ticks: " 225 "%" PRIu64 ", idle ticks: %" PRIu64, 224 uint64_t busy; 225 uint64_t idle; 226 char busy_suffix; 227 char idle_suffix; 228 229 order_suffix(data->cpus[i].busy_cycles, &busy, &busy_suffix); 230 order_suffix(data->cpus[i].idle_cycles, &idle, &idle_suffix); 231 232 printf("cpu%u (%4" PRIu16 " MHz): busy cycles: " 233 "%" PRIu64 "%c, idle cycles: %" PRIu64 "%c", 226 234 data->cpus[i].id, data->cpus[i].frequency_mhz, 227 data->cpus[i].busy_ticks, data->cpus[i].idle_ticks);235 busy, busy_suffix, idle, idle_suffix); 228 236 puts(", idle: "); 229 237 print_percent(data->cpus_perc[i].idle, 2); -
uspace/app/top/top.c
r5954241 rd0c82c5 175 175 } 176 176 177 /* For each CPU: Compute total ticks and divide it between177 /* For each CPU: Compute total cycles and divide it between 178 178 user and kernel */ 179 179 … … 181 181 for (i = 0; i < new_data->cpus_count; i++) { 182 182 uint64_t idle = 183 new_data->cpus[i].idle_ ticks - old_data->cpus[i].idle_ticks;183 new_data->cpus[i].idle_cycles - old_data->cpus[i].idle_cycles; 184 184 uint64_t busy = 185 new_data->cpus[i].busy_ ticks - old_data->cpus[i].busy_ticks;185 new_data->cpus[i].busy_cycles - old_data->cpus[i].busy_cycles; 186 186 uint64_t sum = idle + busy; 187 187
Note:
See TracChangeset
for help on using the changeset viewer.