Changeset c626117 in mainline


Ignore:
Timestamp:
2025-04-10T17:31:25Z (4 days ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master
Children:
9f2f5ee
Parents:
0b47781
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-10 16:34:47)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-10 17:31:25)
Message:

Replace uses of MUTEX_ACTIVE with irq_spinlock_t

Location:
kernel/generic/src
Files:
2 edited

Legend:

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

    r0b47781 rc626117  
    7272 * available.
    7373 */
    74 static MUTEX_INITIALIZE(mem_avail_mtx, MUTEX_ACTIVE);
     74static IRQ_SPINLOCK_INITIALIZE(mem_avail_lock);
    7575static CONDVAR_INITIALIZE(mem_avail_cv);
    7676static size_t mem_avail_req = 0;  /**< Number of frames requested. */
     
    951951#endif
    952952
    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);
     953                /* Disabled interrupts needed to prevent deadlock with TLB shootdown. */
     954                irq_spinlock_lock(&mem_avail_lock, true);
    959955
    960956                if (mem_avail_req > 0)
     
    966962
    967963                while (gen == mem_avail_gen)
    968                         condvar_wait(&mem_avail_cv, &mem_avail_mtx);
    969 
    970                 mutex_unlock(&mem_avail_mtx);
    971                 interrupts_restore(ipl);
     964                        condvar_wait(&mem_avail_cv, &mem_avail_lock);
     965
     966                irq_spinlock_unlock(&mem_avail_lock, true);
    972967
    973968#ifdef CONFIG_DEBUG
     
    10271022        irq_spinlock_unlock(&zones.lock, true);
    10281023
    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);
     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);
    10381028
    10391029        if (mem_avail_req > 0)
     
    10451035        }
    10461036
    1047         mutex_unlock(&mem_avail_mtx);
    1048         interrupts_restore(ipl);
     1037        irq_spinlock_unlock(&mem_avail_lock, true);
    10491038
    10501039        if (!(flags & FRAME_NO_RESERVE))
  • kernel/generic/src/sysinfo/sysinfo.c

    r0b47781 rc626117  
    5757
    5858/** Sysinfo lock */
    59 static MUTEX_INITIALIZE(sysinfo_lock, MUTEX_ACTIVE);
     59static IRQ_SPINLOCK_INITIALIZE(sysinfo_lock);
    6060
    6161/** Sysinfo item constructor
     
    327327{
    328328        /* Protect sysinfo tree consistency */
    329         mutex_lock(&sysinfo_lock);
     329        irq_spinlock_lock(&sysinfo_lock, true);
    330330
    331331        if (root == NULL)
     
    340340        }
    341341
    342         mutex_unlock(&sysinfo_lock);
     342        irq_spinlock_unlock(&sysinfo_lock, true);
    343343}
    344344
     
    360360{
    361361        /* Protect sysinfo tree consistency */
    362         mutex_lock(&sysinfo_lock);
     362        irq_spinlock_lock(&sysinfo_lock, true);
    363363
    364364        if (root == NULL)
     
    374374        }
    375375
    376         mutex_unlock(&sysinfo_lock);
     376        irq_spinlock_unlock(&sysinfo_lock, true);
    377377}
    378378
     
    390390{
    391391        /* Protect sysinfo tree consistency */
    392         mutex_lock(&sysinfo_lock);
     392        irq_spinlock_lock(&sysinfo_lock, true);
    393393
    394394        if (root == NULL)
     
    404404        }
    405405
    406         mutex_unlock(&sysinfo_lock);
     406        irq_spinlock_unlock(&sysinfo_lock, true);
    407407}
    408408
     
    425425{
    426426        /* Protect sysinfo tree consistency */
    427         mutex_lock(&sysinfo_lock);
     427        irq_spinlock_lock(&sysinfo_lock, true);
    428428
    429429        if (root == NULL)
     
    439439        }
    440440
    441         mutex_unlock(&sysinfo_lock);
     441        irq_spinlock_unlock(&sysinfo_lock, true);
    442442}
    443443
     
    452452{
    453453        /* Protect sysinfo tree consistency */
    454         mutex_lock(&sysinfo_lock);
     454        irq_spinlock_lock(&sysinfo_lock, true);
    455455
    456456        if (root == NULL)
     
    463463                printf("Could not set sysinfo item %s.\n", name);
    464464
    465         mutex_unlock(&sysinfo_lock);
     465        irq_spinlock_unlock(&sysinfo_lock, true);
    466466}
    467467
     
    479479{
    480480        /* Protect sysinfo tree consistency */
    481         mutex_lock(&sysinfo_lock);
     481        irq_spinlock_lock(&sysinfo_lock, true);
    482482
    483483        if (root == NULL)
     
    498498        }
    499499
    500         mutex_unlock(&sysinfo_lock);
     500        irq_spinlock_unlock(&sysinfo_lock, true);
    501501}
    502502
     
    596596         * while we are dumping it
    597597         */
    598         mutex_lock(&sysinfo_lock);
     598        irq_spinlock_lock(&sysinfo_lock, true);
    599599
    600600        if (root == NULL)
     
    603603                sysinfo_dump_internal(root, 0);
    604604
    605         mutex_unlock(&sysinfo_lock);
     605        irq_spinlock_unlock(&sysinfo_lock, true);
    606606}
    607607
     
    695695                 * are reading it.
    696696                 */
    697                 mutex_lock(&sysinfo_lock);
     697                irq_spinlock_lock(&sysinfo_lock, true);
    698698                ret = sysinfo_get_item(path, NULL, dry_run);
    699                 mutex_unlock(&sysinfo_lock);
     699                irq_spinlock_unlock(&sysinfo_lock, true);
    700700        }
    701701
     
    806806                 * are reading it.
    807807                 */
    808                 mutex_lock(&sysinfo_lock);
     808                irq_spinlock_lock(&sysinfo_lock, true);
    809809                ret = sysinfo_get_keys(path, NULL, dry_run);
    810                 mutex_unlock(&sysinfo_lock);
     810                irq_spinlock_unlock(&sysinfo_lock, true);
    811811        }
    812812
Note: See TracChangeset for help on using the changeset viewer.