From owner-p4-projects Thu Feb 13 22: 0:13 2003 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 523BA37B405; Thu, 13 Feb 2003 22:00:10 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D793537B401 for ; Thu, 13 Feb 2003 22:00:09 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6869C43F3F for ; Thu, 13 Feb 2003 22:00:09 -0800 (PST) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h1E609bv080446 for ; Thu, 13 Feb 2003 22:00:09 -0800 (PST) (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h1E608JV080443 for perforce@freebsd.org; Thu, 13 Feb 2003 22:00:08 -0800 (PST) Date: Thu, 13 Feb 2003 22:00:08 -0800 (PST) Message-Id: <200302140600.h1E608JV080443@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler Subject: PERFORCE change 25139 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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