Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/frame.c

    rc626117 r597fa24  
    7272 * available.
    7373 */
    74 static IRQ_SPINLOCK_INITIALIZE(mem_avail_lock);
     74static MUTEX_INITIALIZE(mem_avail_mtx, MUTEX_ACTIVE);
    7575static CONDVAR_INITIALIZE(mem_avail_cv);
    7676static size_t mem_avail_req = 0;  /**< Number of frames requested. */
     
    951951#endif
    952952
    953                 /* Disabled interrupts needed to prevent deadlock with TLB shootdown. */
    954                 irq_spinlock_lock(&mem_avail_lock, true);
     953                /*
     954                 * Since the mem_avail_mtx is an active mutex, we need to
     955                 * disable interrupts to prevent deadlock with TLB shootdown.
     956                 */
     957                ipl_t ipl = interrupts_disable();
     958                mutex_lock(&mem_avail_mtx);
    955959
    956960                if (mem_avail_req > 0)
     
    962966
    963967                while (gen == mem_avail_gen)
    964                         condvar_wait(&mem_avail_cv, &mem_avail_lock);
    965 
    966                 irq_spinlock_unlock(&mem_avail_lock, true);
     968                        condvar_wait(&mem_avail_cv, &mem_avail_mtx);
     969
     970                mutex_unlock(&mem_avail_mtx);
     971                interrupts_restore(ipl);
    967972
    968973#ifdef CONFIG_DEBUG
     
    10221027        irq_spinlock_unlock(&zones.lock, true);
    10231028
    1024         /* Signal that some memory has been freed. */
    1025 
    1026         /* Disabled interrupts needed to prevent deadlock with TLB shootdown. */
    1027         irq_spinlock_lock(&mem_avail_lock, true);
     1029        /*
     1030         * Signal that some memory has been freed.
     1031         * Since the mem_avail_mtx is an active mutex,
     1032         * we need to disable interruptsto prevent deadlock
     1033         * with TLB shootdown.
     1034         */
     1035
     1036        ipl_t ipl = interrupts_disable();
     1037        mutex_lock(&mem_avail_mtx);
    10281038
    10291039        if (mem_avail_req > 0)
     
    10351045        }
    10361046
    1037         irq_spinlock_unlock(&mem_avail_lock, true);
     1047        mutex_unlock(&mem_avail_mtx);
     1048        interrupts_restore(ipl);
    10381049
    10391050        if (!(flags & FRAME_NO_RESERVE))
Note: See TracChangeset for help on using the changeset viewer.