tech-crypto archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: (almost working) patch to make opencrypto use mutex/condvar



On Fri, Feb 01, 2008 at 04:45:13PM -0500, Thor Lancelot Simon wrote:
> On Fri, Feb 01, 2008 at 01:34:39PM -0500, Thor Lancelot Simon wrote:
> >
> > The enclosed doesn't work for me (disappointing, since I wrote it!)
> > with the cryptosoft backend, but one of my coworkers swears it works
> > fine for him with a hardware driver.  Comments?  This is the first
> > code I've tried to convert to our modern synchronization primitives.
> 
> It's much better now, but somehow if I run several consumers at once,
> e.g.:
>       sysctl -w kern.cryptodevallowsoft=0
>       openssl speed -engine cryptodev -multi 64 -evp des-ede3-cbc
> 
> Most of them end up sleeping on crydev.  I'm not sure how that's
> possible, since it didn't happen with the old tsleep/wakeup_one()
> code and the condvar code does the analogous operation in the same
> place each time.
> 
> But it's suitable for playing with.  And if anyone sees where that
> cv_signal() is going missing... I owe you one.
> 
> Attached, and at http://www.panix.com/~tls/ocf-mtx2.diff
[...]
> @@ -621,10 +635,13 @@
>  
>       error = crypto_kdispatch(krp);
>       if (error == 0)
> -             error = tsleep(krp, PSOCK, "crydev", 0);
> -     if (error)
> +             mutex_spin_enter(&crypto_mtx);
> +             cv_wait(&krp->krp_cv, &crypto_mtx);     /* XXX cv_wait_sig? */
> +             mutex_spin_exit(&crypto_mtx);
> +#if 0
> +     if (error)                      /* see XXX above -- wait intr? */
>               goto fail;
> -
> +#endif

You changed:

        if (error == 0)
                error = tsleep(krp, PSOCK, "crydev", 0);

to this:

        if (error == 0)
                mutex_spin_enter(&crypto_mtx);
                cv_wait(&krp->krp_cv, &crypto_mtx);     /* XXX cv_wait_sig? */
                mutex_spin_exit(&crypto_mtx);

and it should be of course:

        if (error == 0) {
                mutex_spin_enter(&crypto_mtx);
                cv_wait(&krp->krp_cv, &crypto_mtx);     /* XXX cv_wait_sig? */
                mutex_spin_exit(&crypto_mtx);
        }

-- 
Pawel Jakub Dawidek                       http://www.wheel.pl
pjd%FreeBSD.org@localhost                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!

Attachment: pgpqMWeWR56sw.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index