Changeset 169815e in mainline
- Timestamp:
- 2023-04-16T12:22:00Z (18 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fbaf6ac
- Parents:
- b2ec5cf
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-04-16 12:14:09)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-04-16 12:22:00)
- Location:
- kernel/generic
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/cpu.h
rb2ec5cf r169815e 51 51 */ 52 52 typedef struct cpu { 53 IRQ_SPINLOCK_DECLARE( lock);53 IRQ_SPINLOCK_DECLARE(tlb_lock); 54 54 55 55 tlb_shootdown_msg_t tlb_messages[TLB_MESSAGE_QUEUE_LEN]; … … 97 97 cpu_arch_t arch; 98 98 99 IRQ_SPINLOCK_DECLARE(fpu_lock); 99 100 struct thread *fpu_owner; 100 101 -
kernel/generic/src/cpu/cpu.c
rb2ec5cf r169815e 84 84 cpus[i].id = i; 85 85 86 irq_spinlock_initialize(&cpus[i].lock, "cpus[].lock"); 86 irq_spinlock_initialize(&cpus[i].fpu_lock, "cpus[].fpu_lock"); 87 irq_spinlock_initialize(&cpus[i].tlb_lock, "cpus[].tlb_lock"); 87 88 88 89 for (unsigned int j = 0; j < RQ_COUNT; j++) { -
kernel/generic/src/interrupt/interrupt.c
rb2ec5cf r169815e 114 114 /* Account CPU usage if it woke up from sleep */ 115 115 if (CPU && CPU->idle) { 116 irq_spinlock_lock(&CPU->lock, false);117 116 uint64_t now = get_cycle(); 118 117 atomic_time_increment(&CPU->idle_cycles, now - CPU->last_cycle); 119 118 CPU->last_cycle = now; 120 119 CPU->idle = false; 121 irq_spinlock_unlock(&CPU->lock, false);122 120 } 123 121 -
kernel/generic/src/mm/tlb.c
rb2ec5cf r169815e 95 95 cpu_t *cpu = &cpus[i]; 96 96 97 irq_spinlock_lock(&cpu-> lock, false);97 irq_spinlock_lock(&cpu->tlb_lock, false); 98 98 if (cpu->tlb_messages_count == TLB_MESSAGE_QUEUE_LEN) { 99 99 /* … … 116 116 cpu->tlb_messages[idx].count = count; 117 117 } 118 irq_spinlock_unlock(&cpu-> lock, false);118 irq_spinlock_unlock(&cpu->tlb_lock, false); 119 119 } 120 120 … … 158 158 irq_spinlock_unlock(&tlblock, false); 159 159 160 irq_spinlock_lock(&CPU-> lock, false);160 irq_spinlock_lock(&CPU->tlb_lock, false); 161 161 assert(CPU->tlb_messages_count <= TLB_MESSAGE_QUEUE_LEN); 162 162 … … 189 189 190 190 CPU->tlb_messages_count = 0; 191 irq_spinlock_unlock(&CPU-> lock, false);191 irq_spinlock_unlock(&CPU->tlb_lock, false); 192 192 CPU->tlb_active = true; 193 193 } -
kernel/generic/src/proc/scheduler.c
rb2ec5cf r169815e 129 129 { 130 130 fpu_enable(); 131 irq_spinlock_lock(&CPU-> lock, false);131 irq_spinlock_lock(&CPU->fpu_lock, false); 132 132 133 133 /* Save old context */ … … 154 154 irq_spinlock_unlock(&THREAD->lock, false); 155 155 156 irq_spinlock_unlock(&CPU-> lock, false);156 irq_spinlock_unlock(&CPU->fpu_lock, false); 157 157 } 158 158 #endif /* CONFIG_FPU_LAZY */ … … 187 187 * This improves energy saving and hyperthreading. 188 188 */ 189 irq_spinlock_lock(&CPU->lock, false);190 189 CPU->idle = true; 191 irq_spinlock_unlock(&CPU->lock, false);192 190 193 191 /* … … 298 296 size_t n = 0; 299 297 300 irq_spinlock_lock(&CPU->lock, false);301 302 298 /* Move every list (except the one with highest priority) one level up. */ 303 299 for (int i = RQ_COUNT - 1; i > start; i--) { … … 322 318 irq_spinlock_unlock(&CPU->rq[start].lock, false); 323 319 } 324 325 irq_spinlock_unlock(&CPU->lock, false);326 320 } 327 321 … … 684 678 continue; 685 679 686 irq_spinlock_lock(&cpus[cpu].lock, true);687 688 680 /* Technically a data race, but we don't really care in this case. */ 689 681 int needs_relink = cpus[cpu].relink_deadline - cpus[cpu].current_clock_tick; … … 711 703 irq_spinlock_unlock(&(cpus[cpu].rq[i].lock), false); 712 704 } 713 714 irq_spinlock_unlock(&cpus[cpu].lock, true);715 705 } 716 706 } -
kernel/generic/src/proc/thread.c
rb2ec5cf r169815e 425 425 426 426 assert((thread->state == Exiting) || (thread->state == Lingering)); 427 assert(thread->cpu);428 427 429 428 /* Clear cpu->fpu_owner if set to this thread. */ 430 irq_spinlock_lock(&thread->cpu->lock, false); 431 if (thread->cpu->fpu_owner == thread) 432 thread->cpu->fpu_owner = NULL; 433 irq_spinlock_unlock(&thread->cpu->lock, false); 429 #ifdef CONFIG_FPU_LAZY 430 if (thread->cpu) { 431 irq_spinlock_lock(&thread->cpu->fpu_lock, false); 432 if (thread->cpu->fpu_owner == thread) 433 thread->cpu->fpu_owner = NULL; 434 irq_spinlock_unlock(&thread->cpu->fpu_lock, false); 435 } 436 #endif 434 437 435 438 interrupts_restore(ipl); -
kernel/generic/src/sysinfo/stats.c
rb2ec5cf r169815e 119 119 size_t i; 120 120 for (i = 0; i < config.cpu_count; i++) { 121 irq_spinlock_lock(&cpus[i].lock, true);122 123 121 stats_cpus[i].id = cpus[i].id; 124 122 stats_cpus[i].active = cpus[i].active; … … 127 125 stats_cpus[i].busy_cycles = atomic_time_read(&cpus[i].busy_cycles); 128 126 stats_cpus[i].idle_cycles = atomic_time_read(&cpus[i].idle_cycles); 129 130 irq_spinlock_unlock(&cpus[i].lock, true);131 127 } 132 128 -
kernel/generic/src/time/clock.c
rb2ec5cf r169815e 123 123 static void cpu_update_accounting(void) 124 124 { 125 irq_spinlock_lock(&CPU->lock, false);126 125 uint64_t now = get_cycle(); 127 126 atomic_time_increment(&CPU->busy_cycles, now - CPU->last_cycle); 128 127 CPU->last_cycle = now; 129 irq_spinlock_unlock(&CPU->lock, false);130 128 } 131 129
Note:
See TracChangeset
for help on using the changeset viewer.