Changes in / [8264867:99d05e1] in mainline


Ignore:
Location:
kernel
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/include/mm/page.h

    r8264867 r99d05e1  
    3131 */
    3232/** @file
     33 */
     34
     35/** Paging on AMD64
     36 *
     37 * The space is divided in positive numbers (uspace) and
     38 * negative numbers (kernel). The 'negative' space starting
     39 * with 0xffff800000000000 and ending with 0xffffffffffffffff
     40 * is identically mapped physical memory.
     41 *
    3342 */
    3443
  • kernel/genarch/src/mm/page_pt.c

    r8264867 r99d05e1  
    4848#include <align.h>
    4949#include <macros.h>
    50 #include <bitops.h>
    5150
    5251static void pt_mapping_insert(as_t *, uintptr_t, uintptr_t, unsigned int);
     
    293292}
    294293
    295 /** Return the size of the region mapped by a single PTL0 entry.
    296  *
    297  * @return Size of the region mapped by a single PTL0 entry.
    298  */
    299 static uintptr_t ptl0_step_get(void)
    300 {
    301         size_t va_bits;
    302 
    303         va_bits = fnzb(PTL0_ENTRIES) + fnzb(PTL1_ENTRIES) + fnzb(PTL2_ENTRIES) +
    304             fnzb(PTL3_ENTRIES) + PAGE_WIDTH;
    305 
    306         return 1UL << (va_bits - fnzb(PTL0_ENTRIES));
    307 }
    308 
    309294/** Make the mappings in the given range global accross all address spaces.
    310295 *
     
    324309{
    325310        uintptr_t ptl0 = PA2KA((uintptr_t) AS_KERNEL->genarch.page_table);
    326         uintptr_t ptl0_step = ptl0_step_get();
     311        uintptr_t ptl0step = (((uintptr_t) -1) / PTL0_ENTRIES) + 1;
    327312        size_t order;
    328313        uintptr_t addr;
     
    336321#endif
    337322
     323        ASSERT(ispwr2(ptl0step));
    338324        ASSERT(size > 0);
    339325
    340         for (addr = ALIGN_DOWN(base, ptl0_step); addr - 1 < base + size - 1;
    341             addr += ptl0_step) {
     326        for (addr = ALIGN_DOWN(base, ptl0step); addr - 1 < base + size - 1;
     327            addr += ptl0step) {
    342328                uintptr_t l1;
    343329
  • kernel/generic/include/lib/ra.h

    r8264867 r99d05e1  
    4242
    4343typedef struct {
    44         IRQ_SPINLOCK_DECLARE(lock);
     44        SPINLOCK_DECLARE(lock);
    4545        list_t spans;           /**< List of arena's spans. */
    4646} ra_arena_t;
  • kernel/generic/include/mm/slab.h

    r8264867 r99d05e1  
    8181        slab_magazine_t *current;
    8282        slab_magazine_t *last;
    83         IRQ_SPINLOCK_DECLARE(lock);
     83        SPINLOCK_DECLARE(lock);
    8484} slab_mag_cache_t;
    8585
     
    113113        list_t full_slabs;     /**< List of full slabs */
    114114        list_t partial_slabs;  /**< List of partial slabs */
    115         IRQ_SPINLOCK_DECLARE(slablock);
     115        SPINLOCK_DECLARE(slablock);
    116116        /* Magazines */
    117117        list_t magazines;  /**< List o full magazines */
    118         IRQ_SPINLOCK_DECLARE(maglock);
     118        SPINLOCK_DECLARE(maglock);
    119119       
    120120        /** CPU cache */
  • kernel/generic/src/lib/ra.c

    r8264867 r99d05e1  
    185185                return NULL;
    186186
    187         irq_spinlock_initialize(&arena->lock, "arena_lock");
     187        spinlock_initialize(&arena->lock, "arena_lock");
    188188        list_initialize(&arena->spans);
    189189
     
    209209
    210210        /* TODO: check for overlaps */
    211         irq_spinlock_lock(&arena->lock, true);
     211        spinlock_lock(&arena->lock);
    212212        list_append(&span->span_link, &arena->spans);
    213         irq_spinlock_unlock(&arena->lock, true);
     213        spinlock_unlock(&arena->lock);
    214214        return true;
    215215}
     
    390390        ASSERT(ispwr2(alignment));
    391391
    392         irq_spinlock_lock(&arena->lock, true);
     392        spinlock_lock(&arena->lock);
    393393        list_foreach(arena->spans, cur) {
    394394                ra_span_t *span = list_get_instance(cur, ra_span_t, span_link);
     
    398398                        break;
    399399        }
    400         irq_spinlock_unlock(&arena->lock, true);
     400        spinlock_unlock(&arena->lock);
    401401
    402402        return base;
     
    406406void ra_free(ra_arena_t *arena, uintptr_t base, size_t size)
    407407{
    408         irq_spinlock_lock(&arena->lock, true);
     408        spinlock_lock(&arena->lock);
    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                         irq_spinlock_unlock(&arena->lock, true);
     414                        spinlock_unlock(&arena->lock);
    415415                        return;
    416416                }
    417417        }
    418         irq_spinlock_unlock(&arena->lock, true);
     418        spinlock_unlock(&arena->lock);
    419419
    420420        panic("Freeing to wrong arena (base=%" PRIxn ", size=%" PRIdn ").",
  • kernel/generic/src/mm/frame.c

    r8264867 r99d05e1  
    10861086#endif
    10871087               
    1088                 /*
    1089                  * Since the mem_avail_mtx is an active mutex, we need to disable interrupts
    1090                  * to prevent deadlock with TLB shootdown.
    1091                  */
    1092                 ipl_t ipl = interrupts_disable();
    10931088                mutex_lock(&mem_avail_mtx);
    10941089               
     
    11031098               
    11041099                mutex_unlock(&mem_avail_mtx);
    1105                 interrupts_restore(ipl);
    11061100               
    11071101#ifdef CONFIG_DEBUG
     
    11671161         * Signal that some memory has been freed.
    11681162         */
    1169 
    1170        
    1171         /*
    1172          * Since the mem_avail_mtx is an active mutex, we need to disable interrupts
    1173          * to prevent deadlock with TLB shootdown.
    1174          */
    1175         ipl_t ipl = interrupts_disable();
    11761163        mutex_lock(&mem_avail_mtx);
    11771164        if (mem_avail_req > 0)
     
    11831170        }
    11841171        mutex_unlock(&mem_avail_mtx);
    1185         interrupts_restore(ipl);
    11861172       
    11871173        if (!(flags & FRAME_NO_RESERVE))
  • kernel/generic/src/mm/slab.c

    r8264867 r99d05e1  
    264264                freed = cache->destructor(obj);
    265265       
    266         irq_spinlock_lock(&cache->slablock, true);
     266        spinlock_lock(&cache->slablock);
    267267        ASSERT(slab->available < cache->objects);
    268268       
     
    275275                /* Free associated memory */
    276276                list_remove(&slab->link);
    277                 irq_spinlock_unlock(&cache->slablock, true);
     277                spinlock_unlock(&cache->slablock);
    278278               
    279279                return freed + slab_space_free(cache, slab);
     
    284284        }
    285285       
    286         irq_spinlock_unlock(&cache->slablock, true);
     286        spinlock_unlock(&cache->slablock);
    287287        return freed;
    288288}
     
    295295NO_TRACE static void *slab_obj_create(slab_cache_t *cache, unsigned int flags)
    296296{
    297         irq_spinlock_lock(&cache->slablock, true);
     297        spinlock_lock(&cache->slablock);
    298298       
    299299        slab_t *slab;
     
    308308                 *
    309309                 */
    310                 irq_spinlock_unlock(&cache->slablock, true);
     310                spinlock_unlock(&cache->slablock);
    311311                slab = slab_space_alloc(cache, flags);
    312312                if (!slab)
    313313                        return NULL;
    314314               
    315                 irq_spinlock_lock(&cache->slablock, true);
     315                spinlock_lock(&cache->slablock);
    316316        } else {
    317317                slab = list_get_instance(list_first(&cache->partial_slabs),
     
    329329                list_prepend(&slab->link, &cache->partial_slabs);
    330330       
    331         irq_spinlock_unlock(&cache->slablock, true);
     331        spinlock_unlock(&cache->slablock);
    332332       
    333333        if ((cache->constructor) && (cache->constructor(obj, flags))) {
     
    355355        link_t *cur;
    356356       
    357         irq_spinlock_lock(&cache->maglock, true);
     357        spinlock_lock(&cache->maglock);
    358358        if (!list_empty(&cache->magazines)) {
    359359                if (first)
     
    366366                atomic_dec(&cache->magazine_counter);
    367367        }
    368         irq_spinlock_unlock(&cache->maglock, true);
    369 
     368       
     369        spinlock_unlock(&cache->maglock);
    370370        return mag;
    371371}
     
    377377    slab_magazine_t *mag)
    378378{
    379         irq_spinlock_lock(&cache->maglock, true);
     379        spinlock_lock(&cache->maglock);
    380380       
    381381        list_prepend(&mag->link, &cache->magazines);
    382382        atomic_inc(&cache->magazine_counter);
    383383       
    384         irq_spinlock_unlock(&cache->maglock, true);
     384        spinlock_unlock(&cache->maglock);
    385385}
    386386
     
    414414        slab_magazine_t *lastmag = cache->mag_cache[CPU->id].last;
    415415       
    416         ASSERT(irq_spinlock_locked(&cache->mag_cache[CPU->id].lock));
     416        ASSERT(spinlock_locked(&cache->mag_cache[CPU->id].lock));
    417417       
    418418        if (cmag) { /* First try local CPU magazines */
     
    451451                return NULL;
    452452       
    453         irq_spinlock_lock(&cache->mag_cache[CPU->id].lock, true);
     453        spinlock_lock(&cache->mag_cache[CPU->id].lock);
    454454       
    455455        slab_magazine_t *mag = get_full_current_mag(cache);
    456456        if (!mag) {
    457                 irq_spinlock_unlock(&cache->mag_cache[CPU->id].lock, true);
     457                spinlock_unlock(&cache->mag_cache[CPU->id].lock);
    458458                return NULL;
    459459        }
    460460       
    461461        void *obj = mag->objs[--mag->busy];
    462         irq_spinlock_unlock(&cache->mag_cache[CPU->id].lock, true);
     462        spinlock_unlock(&cache->mag_cache[CPU->id].lock);
    463463       
    464464        atomic_dec(&cache->cached_objs);
     
    481481        slab_magazine_t *lastmag = cache->mag_cache[CPU->id].last;
    482482       
    483         ASSERT(irq_spinlock_locked(&cache->mag_cache[CPU->id].lock));
     483        ASSERT(spinlock_locked(&cache->mag_cache[CPU->id].lock));
    484484       
    485485        if (cmag) {
     
    531531                return -1;
    532532       
    533         irq_spinlock_lock(&cache->mag_cache[CPU->id].lock, true);
     533        spinlock_lock(&cache->mag_cache[CPU->id].lock);
    534534       
    535535        slab_magazine_t *mag = make_empty_current_mag(cache);
    536536        if (!mag) {
    537                 irq_spinlock_unlock(&cache->mag_cache[CPU->id].lock, true);
     537                spinlock_unlock(&cache->mag_cache[CPU->id].lock);
    538538                return -1;
    539539        }
     
    541541        mag->objs[mag->busy++] = obj;
    542542       
    543         irq_spinlock_unlock(&cache->mag_cache[CPU->id].lock, true);
     543        spinlock_unlock(&cache->mag_cache[CPU->id].lock);
    544544       
    545545        atomic_inc(&cache->cached_objs);
     
    593593        for (i = 0; i < config.cpu_count; i++) {
    594594                memsetb(&cache->mag_cache[i], sizeof(cache->mag_cache[i]), 0);
    595                 irq_spinlock_initialize(&cache->mag_cache[i].lock,
     595                spinlock_initialize(&cache->mag_cache[i].lock,
    596596                    "slab.cache.mag_cache[].lock");
    597597        }
     
    624624        list_initialize(&cache->magazines);
    625625       
    626         irq_spinlock_initialize(&cache->slablock, "slab.cache.slablock");
    627         irq_spinlock_initialize(&cache->maglock, "slab.cache.maglock");
     626        spinlock_initialize(&cache->slablock, "slab.cache.slablock");
     627        spinlock_initialize(&cache->maglock, "slab.cache.maglock");
    628628       
    629629        if (!(cache->flags & SLAB_CACHE_NOMAGAZINE))
     
    704704                size_t i;
    705705                for (i = 0; i < config.cpu_count; i++) {
    706                         irq_spinlock_lock(&cache->mag_cache[i].lock, true);
     706                        spinlock_lock(&cache->mag_cache[i].lock);
    707707                       
    708708                        mag = cache->mag_cache[i].current;
     
    716716                        cache->mag_cache[i].last = NULL;
    717717                       
    718                         irq_spinlock_unlock(&cache->mag_cache[i].lock, true);
     718                        spinlock_unlock(&cache->mag_cache[i].lock);
    719719                }
    720720        }
  • kernel/generic/src/synch/mutex.c

    r8264867 r99d05e1  
    4040#include <debug.h>
    4141#include <arch.h>
    42 #include <stacktrace.h>
    4342
    4443/** Initialize mutex.
     
    8887                ASSERT(!(flags & SYNCH_FLAGS_INTERRUPTIBLE));
    8988               
    90                 unsigned int cnt = 0;
    91                 bool deadlock_reported = false;
    9289                do {
    93                         if (cnt++ > DEADLOCK_THRESHOLD) {
    94                                 printf("cpu%u: looping on active mutex %p\n",
    95                                     CPU->id, mtx);
    96                                 stack_trace();
    97                                 cnt = 0;
    98                                 deadlock_reported = true;
    99                         }
    10090                        rc = semaphore_trydown(&mtx->sem);
    10191                } while (SYNCH_FAILED(rc) &&
    10292                    !(flags & SYNCH_FLAGS_NON_BLOCKING));
    103                 if (deadlock_reported)
    104                         printf("cpu%u: not deadlocked\n", CPU->id);
    10593        }
    10694
  • kernel/generic/src/synch/spinlock.c

    r8264867 r99d05e1  
    4444#include <debug.h>
    4545#include <symtab.h>
    46 #include <stacktrace.h>
    4746
    4847#ifdef CONFIG_SMP
     
    105104                            "caller=%p (%s)\n", CPU->id, lock, lock->name,
    106105                            (void *) CALLER, symtab_fmt_name_lookup(CALLER));
    107                         stack_trace();
    108106                       
    109107                        i = 0;
     
    262260        int rc = spinlock_trylock(&(lock->lock));
    263261       
    264         ASSERT_IRQ_SPINLOCK(!rc || !lock->guard, lock);
     262        ASSERT_IRQ_SPINLOCK(!lock->guard, lock);
    265263        return rc;
    266264}
Note: See TracChangeset for help on using the changeset viewer.