Changeset 434f700 in mainline for src/mm/tlb.c


Ignore:
Timestamp:
2005-04-26T16:17:41Z (20 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
babcb148
Parents:
dba84ff
Message:

Replace the deadlock-prone TLB shootdown algorithm with a deadlock-free implementation.
The implementation is a variant of the CMU TLB consistency algorithm.
Very inefficient implementation of a very inefficient (but correct) algorithm.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mm/tlb.c

    rdba84ff r434f700  
    3434#include <arch/interrupt.h>
    3535#include <config.h>
     36#include <arch.h>
    3637
    3738#ifdef __SMP__
    3839static spinlock_t tlblock;
    39 static volatile int tlb_shootdown_cnt;
    4040
    4141void tlb_init(void)
    4242{
    4343        spinlock_initialize(&tlblock);
    44         tlb_shootdown_cnt = 0;
    4544}
    4645
     
    4847void tlb_shootdown_start(void)
    4948{
     49        int i;
     50
     51        CPU->tlb_active = 0;
    5052        spinlock_lock(&tlblock);
    5153        tlb_shootdown_ipi_send();
     54        tlb_invalidate(0); /* TODO: use valid ASID */
    5255       
    53         while (tlb_shootdown_cnt < config.cpu_active - 1)
    54                 ;
    55                
    56         tlb_shootdown_cnt = 0;
     56busy_wait:     
     57        for (i = 0; i<config.cpu_active; i++)
     58                if (cpus[i].tlb_active)
     59                        goto busy_wait;
    5760}
    5861
     
    6063{
    6164        spinlock_unlock(&tlblock);
     65        CPU->tlb_active = 1;
    6266}
    6367
     
    6973void tlb_shootdown_ipi_recv(void)
    7074{
    71         atomic_inc((int *) &tlb_shootdown_cnt);
     75        CPU->tlb_active = 0;
    7276        spinlock_lock(&tlblock);
    7377        spinlock_unlock(&tlblock);
    7478        tlb_invalidate(0);      /* TODO: use valid ASID */
     79        CPU->tlb_active = 1;
    7580}
    7681#endif /* __SMP__ */
Note: See TracChangeset for help on using the changeset viewer.