Date: Thu, 13 Feb 2003 22:00:08 -0800 (PST) From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 25139 for review Message-ID: <200302140600.h1E608JV080443@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=25139 Change 25139 by sam@sam_ebb on 2003/02/13 21:59:17 o add CRYPTO_F_CBIMM flag to mark crypto op's that should have their callback function invoked immediately rather than switching to the callback thread o use this to eliminate a context switch for ops through /dev/crypto Affected files ... .. //depot/projects/crypto/opencrypto/crypto.c#2 edit .. //depot/projects/crypto/opencrypto/cryptodev.c#2 edit .. //depot/projects/crypto/opencrypto/cryptodev.h#2 edit Differences ... ==== //depot/projects/crypto/opencrypto/crypto.c#2 (text+ko) ==== @@ -917,21 +917,38 @@ void crypto_done(struct cryptop *crp) { - int wasempty; - if (crp->crp_etype != 0) cryptostats.cs_errs++; #ifdef CRYPTO_TIMING if (crypto_timing) crypto_tstat(&cryptostats.cs_done, &crp->crp_tstamp); #endif - CRYPTO_RETQ_LOCK(); - wasempty = TAILQ_EMPTY(&crp_ret_q); - TAILQ_INSERT_TAIL(&crp_ret_q, crp, crp_next); + if ((crp->crp_flags & CRYPTO_F_CBIMM) == 0) { + int wasempty; + + CRYPTO_RETQ_LOCK(); + wasempty = TAILQ_EMPTY(&crp_ret_q); + TAILQ_INSERT_TAIL(&crp_ret_q, crp, crp_next); - if (wasempty) - wakeup_one(&crp_ret_q); /* shared wait channel */ - CRYPTO_RETQ_UNLOCK(); + if (wasempty) + wakeup_one(&crp_ret_q); /* shared wait channel */ + CRYPTO_RETQ_UNLOCK(); + } else { +#ifdef CRYPTO_TIMING + if (crypto_timing) { + /* + * NB: We must copy the timestamp before + * doing the callback as the cryptop is + * likely to be reclaimed. + */ + struct bintime t = crp->crp_tstamp; + crypto_tstat(&cryptostats.cs_cb, &t); + crp->crp_callback(crp); + crypto_tstat(&cryptostats.cs_finis, &t); + } else +#endif + crp->crp_callback(crp); + } } /* ==== //depot/projects/crypto/opencrypto/cryptodev.c#2 (text+ko) ==== @@ -382,7 +382,7 @@ } crp->crp_ilen = cop->len; - crp->crp_flags = CRYPTO_F_IOV; + crp->crp_flags = CRYPTO_F_IOV | CRYPTO_F_CBIMM; crp->crp_buf = (caddr_t)&cse->uio; crp->crp_callback = (int (*) (struct cryptop *)) cryptodev_cb; crp->crp_sid = cse->sid; ==== //depot/projects/crypto/opencrypto/cryptodev.h#2 (text+ko) ==== @@ -262,6 +262,7 @@ #define CRYPTO_F_IOV 0x0002 /* Input/output are uio */ #define CRYPTO_F_REL 0x0004 /* Must return data in same place */ #define CRYPTO_F_NODELAY 0x0008 /* Dispatch as quickly as possible */ +#define CRYPTO_F_CBIMM 0x0010 /* Do callback immediately */ caddr_t crp_buf; /* Data to be processed */ caddr_t crp_opaque; /* Opaque pointer, passed along */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200302140600.h1E608JV080443>