Re: (almost working) patch to make opencrypto use mutex/condvar
Pawel Jakub Dawidek <[email protected]>
| Newsgroups | gmane.os.netbsd.devel.crypto,gmane.os.netbsd.devel.kernel |
|---|---|
| Message-ID | <[email protected]> |
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
[email protected] http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!
signature.asc
(application/pgp-signature, 187 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iD8DBQFHpA0iForvXbEpPzQRAmE7AKC2V83BE766Sflb5GQ4s6irlhVsegCfWB2n +4b3pDsTYTgk18iaUsfW1jg= =gDRb -----END PGP SIGNATURE-----