Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 1295a1da in mainline


Ignore:
Timestamp:
2012-05-06T17:27:16Z (9 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
master
Children:
25ebfbd
Parents:
caed0279
Message:

Make the ra_arena_t spinlock IRQ save.

  • The lock is currently being taken by code which performs TLB shootdown sequence and hence it could create a deadlock situation.
Location:
kernel/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/lib/ra.h

    rcaed0279 r1295a1da  
    4242
    4343typedef struct {
    44         SPINLOCK_DECLARE(lock);
     44        IRQ_SPINLOCK_DECLARE(lock);
    4545        list_t spans;           /**< List of arena's spans. */
    4646} ra_arena_t;
  • kernel/generic/src/lib/ra.c

    rcaed0279 r1295a1da  
    185185                return NULL;
    186186
    187         spinlock_initialize(&arena->lock, "arena_lock");
     187        irq_spinlock_initialize(&arena->lock, "arena_lock");
    188188        list_initialize(&arena->spans);
    189189
     
    209209
    210210        /* TODO: check for overlaps */
    211         spinlock_lock(&arena->lock);
     211        irq_spinlock_lock(&arena->lock, true);
    212212        list_append(&span->span_link, &arena->spans);
    213         spinlock_unlock(&arena->lock);
     213        irq_spinlock_unlock(&arena->lock, true);
    214214        return true;
    215215}
     
    390390        ASSERT(ispwr2(alignment));
    391391
    392         spinlock_lock(&arena->lock);
     392        irq_spinlock_lock(&arena->lock, true);
    393393        list_foreach(arena->spans, cur) {
    394394                ra_span_t *span = list_get_instance(cur, ra_span_t, span_link);
     
    398398                        break;
    399399        }
    400         spinlock_unlock(&arena->lock);
     400        irq_spinlock_unlock(&arena->lock, true);
    401401
    402402        return base;
     
    406406void ra_free(ra_arena_t *arena, uintptr_t base, size_t size)
    407407{
    408         spinlock_lock(&arena->lock);
     408        irq_spinlock_lock(&arena->lock, true);
    409409        list_foreach(arena->spans, cur) {
    410410                ra_span_t *span = list_get_instance(cur, ra_span_t, span_link);
     
    412412                if (iswithin(span->base, span->size, base, size)) {
    413413                        ra_span_free(span, base, size);
    414                         spinlock_unlock(&arena->lock);
     414                        irq_spinlock_unlock(&arena->lock, true);
    415415                        return;
    416416                }
    417417        }
    418         spinlock_unlock(&arena->lock);
     418        irq_spinlock_unlock(&arena->lock, true);
    419419
    420420        panic("Freeing to wrong arena (base=%" PRIxn ", size=%" PRIdn ").",
Note: See TracChangeset for help on using the changeset viewer.