Changes in kernel/generic/src/mm/tlb.c [da1bafb:98000fb] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/tlb.c
rda1bafb r98000fb 33 33 /** 34 34 * @file 35 * @brief 35 * @brief Generic TLB shootdown algorithm. 36 36 * 37 37 * The algorithm implemented here is based on the CMU TLB shootdown … … 53 53 #include <cpu.h> 54 54 55 /** 56 * This lock is used for synchronisation between sender and 57 * recipients of TLB shootdown message. It must be acquired 58 * before CPU structure lock. 59 */ 60 SPINLOCK_INITIALIZE(tlblock); 61 55 62 void tlb_init(void) 56 63 { … … 59 66 60 67 #ifdef CONFIG_SMP 61 62 /**63 * This lock is used for synchronisation between sender and64 * recipients of TLB shootdown message. It must be acquired65 * before CPU structure lock.66 *67 */68 IRQ_SPINLOCK_STATIC_INITIALIZE(tlblock);69 68 70 69 /** Send TLB shootdown message. … … 79 78 * @param page Virtual page address, if required by type. 80 79 * @param count Number of pages, if required by type. 81 *82 80 */ 83 81 void tlb_shootdown_start(tlb_invalidate_type_t type, asid_t asid, 84 82 uintptr_t page, size_t count) 85 83 { 86 CPU->tlb_active = false; 87 irq_spinlock_lock(&tlblock, false); 84 unsigned int i; 85 86 CPU->tlb_active = 0; 87 spinlock_lock(&tlblock); 88 88 89 size_t i;90 89 for (i = 0; i < config.cpu_count; i++) { 91 90 cpu_t *cpu; … … 93 92 if (i == CPU->id) 94 93 continue; 95 94 96 95 cpu = &cpus[i]; 97 irq_spinlock_lock(&cpu->lock, false);96 spinlock_lock(&cpu->lock); 98 97 if (cpu->tlb_messages_count == TLB_MESSAGE_QUEUE_LEN) { 99 98 /* … … 116 115 cpu->tlb_messages[idx].count = count; 117 116 } 118 irq_spinlock_unlock(&cpu->lock, false);117 spinlock_unlock(&cpu->lock); 119 118 } 120 119 121 120 tlb_shootdown_ipi_send(); 122 123 busy_wait: 121 122 busy_wait: 124 123 for (i = 0; i < config.cpu_count; i++) 125 124 if (cpus[i].tlb_active) … … 127 126 } 128 127 129 /** Finish TLB shootdown sequence. 130 * 131 */ 128 /** Finish TLB shootdown sequence. */ 132 129 void tlb_shootdown_finalize(void) 133 130 { 134 irq_spinlock_unlock(&tlblock, false);135 CPU->tlb_active = true;131 spinlock_unlock(&tlblock); 132 CPU->tlb_active = 1; 136 133 } 137 134 … … 141 138 } 142 139 143 /** Receive TLB shootdown message. 144 * 145 */ 140 /** Receive TLB shootdown message. */ 146 141 void tlb_shootdown_ipi_recv(void) 147 142 { 143 tlb_invalidate_type_t type; 144 asid_t asid; 145 uintptr_t page; 146 size_t count; 147 unsigned int i; 148 148 149 ASSERT(CPU); 149 150 150 CPU->tlb_active = false;151 irq_spinlock_lock(&tlblock, false);152 irq_spinlock_unlock(&tlblock, false);151 CPU->tlb_active = 0; 152 spinlock_lock(&tlblock); 153 spinlock_unlock(&tlblock); 153 154 154 irq_spinlock_lock(&CPU->lock, false);155 spinlock_lock(&CPU->lock); 155 156 ASSERT(CPU->tlb_messages_count <= TLB_MESSAGE_QUEUE_LEN); 156 157 size_t i; 157 158 158 for (i = 0; i < CPU->tlb_messages_count; CPU->tlb_messages_count--) { 159 t lb_invalidate_type_t type = CPU->tlb_messages[i].type;160 asid _t asid= CPU->tlb_messages[i].asid;161 uintptr_tpage = CPU->tlb_messages[i].page;162 size_tcount = CPU->tlb_messages[i].count;163 159 type = CPU->tlb_messages[i].type; 160 asid = CPU->tlb_messages[i].asid; 161 page = CPU->tlb_messages[i].page; 162 count = CPU->tlb_messages[i].count; 163 164 164 switch (type) { 165 165 case TLB_INVL_ALL: … … 170 170 break; 171 171 case TLB_INVL_PAGES: 172 ASSERT(count);172 ASSERT(count); 173 173 tlb_invalidate_pages(asid, page, count); 174 174 break; … … 177 177 break; 178 178 } 179 180 179 if (type == TLB_INVL_ALL) 181 180 break; 182 181 } 183 182 184 irq_spinlock_unlock(&CPU->lock, false);185 CPU->tlb_active = true;183 spinlock_unlock(&CPU->lock); 184 CPU->tlb_active = 1; 186 185 } 187 186
Note:
See TracChangeset
for help on using the changeset viewer.