]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r324335,r327393,r327397,r327401,r327402:
authormjg <mjg@FreeBSD.org>
Tue, 2 Jan 2018 00:02:36 +0000 (00:02 +0000)
committermjg <mjg@FreeBSD.org>
Tue, 2 Jan 2018 00:02:36 +0000 (00:02 +0000)
commit075f7f627bb213a5cb1c0805bac208ef1e3f9391
tree4c419ca04e581aae799937f68e698c35686779c4
parentf093435243dbee1884073422f5b85ed45185da2f
MFC r324335,r327393,r327397,r327401,r327402:

    locks: take the number of readers into account when waiting

    Previous code would always spin once before checking the lock. But a lock
    with e.g. 6 readers is not going to become free in the duration of once spin
    even if they start draining immediately.

    Conservatively perform one for each reader.

    Note that the total number of allowed spins is still extremely small and is
    subject to change later.

=============

    rwlock: tidy up __rw_runlock_hard similarly to r325921

=============

    sx: read the SX_NOADAPTIVE flag and Giant ownership only once

    These used to be read multiple times when waiting for the lock the become
    free, which had the potential to issue completely avoidable traffic.

=============

    locks: re-check the reason to go to sleep after locking sleepq/turnstile

    In both rw and sx locks we always go to sleep if the lock owner is not
    running.

    We do spin for some time if the lock is read-locked.

    However, if we decide to go to sleep due to the lock owner being off cpu
    and after sleepq/turnstile gets acquired the lock is read-locked, we should
    fallback to the aforementioned wait.

=============

    sx: fix up non-smp compilation after r327397

=============

    locks: adjust loop limit check when waiting for readers

    The check was for the exact value, but since the counter started being
    incremented by the number of readers it could have jumped over.

=============

    Return a non-NULL owner only if the lock is exclusively held in owner_sx().

    Fix some whitespace bugs while here.
sys/kern/kern_rwlock.c
sys/kern/kern_sx.c
sys/sys/lock.h