Changeset 31d8e10 in mainline for kernel/generic/include


Ignore:
Timestamp:
2007-04-05T16:09:49Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
547fa39
Parents:
879585a3
Message:

Continue to de-oversynchronize the kernel.

  • replace as→refcount with an atomic counter; accesses to this

reference counter are not to be done when the as→lock mutex is held;
this gets us rid of mutex_lock_active();

Remove the possibility of a deadlock between TLB shootdown and asidlock.

  • get rid of mutex_lock_active() on as→lock
  • when locking the asidlock spinlock, always do it conditionally and with

preemption disabled; in the unsuccessful case, enable interrupts and try again

  • there should be no deadlock between TLB shootdown and the as→lock mutexes
  • PLEASE REVIEW !!!

Add DEADLOCK_PROBE's to places where we have spinlock_trylock() loops.

Location:
kernel/generic/include
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/mm/as.h

    r879585a3 r31d8e10  
    102102                asid_t asid;
    103103               
     104                /** Number of references (i.e tasks that reference this as). */
     105                atomic_t refcount;
     106
    104107                mutex_t lock;
    105                
    106                 /** Number of references (i.e tasks that reference this as). */
    107                 count_t refcount;
    108108               
    109109                /** B+tree of address space areas. */
     
    148148        asid_t asid;
    149149
     150        /** Number of references (i.e tasks that reference this as). */
     151        atomic_t refcount;
     152
    150153        mutex_t lock;
    151 
    152         /** Number of references (i.e tasks that reference this as). */
    153         count_t refcount;
    154154
    155155        /** B+tree of address space areas. */
  • kernel/generic/include/synch/mutex.h

    r879585a3 r31d8e10  
    4545
    4646#define mutex_lock(mtx) \
    47         _mutex_lock_timeout((mtx),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NONE)
     47        _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
    4848#define mutex_trylock(mtx) \
    49         _mutex_lock_timeout((mtx),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NON_BLOCKING)
    50 #define mutex_lock_timeout(mtx,usec) \
    51         _mutex_lock_timeout((mtx),(usec),SYNCH_FLAGS_NON_BLOCKING)
    52 #define mutex_lock_active(mtx) \
    53         while (mutex_trylock((mtx)) != ESYNCH_OK_ATOMIC)
     49        _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING)
     50#define mutex_lock_timeout(mtx, usec) \
     51        _mutex_lock_timeout((mtx), (usec), SYNCH_FLAGS_NON_BLOCKING)
    5452
    5553extern void mutex_initialize(mutex_t *mtx);
  • kernel/generic/include/synch/spinlock.h

    r879585a3 r31d8e10  
    102102}
    103103
     104#ifdef CONFIG_DEBUG_SPINLOCK
     105
     106extern int printf(const char *, ...);
     107
     108#define DEADLOCK_THRESHOLD              100000000
     109#define DEADLOCK_PROBE_INIT(pname)      count_t pname = 0
     110#define DEADLOCK_PROBE(pname, value)                                    \
     111        if ((pname)++ > (value)) {                                      \
     112                (pname) = 0;                                            \
     113                printf("Deadlock probe %s: exceeded threshold %d\n",    \
     114                    "cpu%d: function=%s, line=%d\n",                    \
     115                    #pname, (value), CPU->id, __FUNCTION__, __LINE__);  \
     116        }
     117#else
     118#define DEADLOCK_PROBE_INIT(pname)
     119#define DEADLOCK_PROBE(pname, value)
     120#endif
     121
    104122#else
    105123
     
    114132#define spinlock_unlock(x)              preemption_enable()
    115133
     134#define DEADLOCK_PROBE_INIT(pname)
     135#define DEADLOCK_PROBE(pname, value)
     136
    116137#endif
    117138
Note: See TracChangeset for help on using the changeset viewer.