An idea for spin_lock_contested()

Matthew Dillon dillon at apollo.backplane.com
Tue Nov 1 20:12:00 PDT 2011


:Something like:
:        --gd->gd_curthread->td_critcount;
:        for (;;) {
:                if (spin->counta == 1)
:                        continue;
:
:                ++gd->gd_curthread->td_critcount;
:                cpu_ccfence();
:                if (atomic_swap_int(&spin->counta, 1) == 0)
:                        break;
:                --gd->gd_curthread->td_critcount;

    It's doable as long as there are no other spinlocks held and the
    critical section on entry was not being held.  But I don't think
    we'll get much out of it because we don't spin on spinlocks very much
    any more.

						-Matt






More information about the Kernel mailing list