Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Nov 2017 22:14:37 +0100
From:      Mateusz Guzik <mjguzik@gmail.com>
To:        Mateusz Guzik <mjg@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r326237 - head/sys/kern
Message-ID:  <CAGudoHF8xE1Sg0MUD5=uQ0sJGejFWCCwcp8vv6RK7HR3tTMRjA@mail.gmail.com>
In-Reply-To: <201711262110.vAQLAmNF043213@repo.freebsd.org>
References:  <201711262110.vAQLAmNF043213@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Nov 26, 2017 at 10:10 PM, Mateusz Guzik <mjg@freebsd.org> wrote:

> Author: mjg
> Date: Sun Nov 26 21:10:47 2017
> New Revision: 326237
> URL: https://svnweb.freebsd.org/changeset/base/326237
>
> Log:
>   rw: fix runlock_hard when new readers show up
>
>   When waiters/writer spinner flags are set no new readers can show up
> unless
>   they already have a different rw rock read locked. The change in r326195
> failed
>   to take that into account - in presence of new readers it would spin
> until
>   they all drain, which would be lead to trouble if e.g. they go off cpu
> and
>   can get scheduled because of this thread.
>
>
Now that's an amazingly bad commit message. Typos and whatnot aside,
I of course meant they *can't* get on the cpu. The thread in runlock slow
path holds a spinlock and loops with it.


>   Reported by:  pho
>
> Modified:
>   head/sys/kern/kern_rwlock.c
>
> Modified: head/sys/kern/kern_rwlock.c
> ============================================================
> ==================
> --- head/sys/kern/kern_rwlock.c Sun Nov 26 20:30:02 2017        (r326236)
> +++ head/sys/kern/kern_rwlock.c Sun Nov 26 21:10:47 2017        (r326237)
> @@ -769,6 +769,11 @@ __rw_runlock_hard(struct rwlock *rw, struct thread *td
>                 turnstile_chain_lock(&rw->lock_object);
>                 v = RW_READ_VALUE(rw);
>  retry_ts:
> +               if (__predict_false(RW_READERS(v) > 1)) {
> +                       turnstile_chain_unlock(&rw->lock_object);
> +                       continue;
> +               }
> +
>                 v &= (RW_LOCK_WAITERS | RW_LOCK_WRITE_SPINNER);
>                 MPASS(v & RW_LOCK_WAITERS);
>
> _______________________________________________
> svn-src-all@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/svn-src-all
> To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
>



-- 
Mateusz Guzik <mjguzik gmail.com>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGudoHF8xE1Sg0MUD5=uQ0sJGejFWCCwcp8vv6RK7HR3tTMRjA>