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