Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Jun 2020 15:56:55 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r362801 - head/sys/opencrypto
Message-ID:  <202006301556.05UFutOK016162@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Tue Jun 30 15:56:54 2020
New Revision: 362801
URL: https://svnweb.freebsd.org/changeset/base/362801

Log:
  Remove CRYPTO_TIMING.
  
  It was added a very long time ago.  It is single-threaded, so only
  really useful for basic measurements, and in the meantime we've gotten
  some more sophisticated profiling tools.
  
  Reviewed by:	cem, delphij, jhb
  Sponsored by:	Rubicon Communications, LLC (Netgate)
  Differential Revision:	https://reviews.freebsd.org/D25464

Modified:
  head/sys/opencrypto/crypto.c
  head/sys/opencrypto/cryptodev.h

Modified: head/sys/opencrypto/crypto.c
==============================================================================
--- head/sys/opencrypto/crypto.c	Tue Jun 30 15:53:52 2020	(r362800)
+++ head/sys/opencrypto/crypto.c	Tue Jun 30 15:56:54 2020	(r362801)
@@ -54,8 +54,6 @@ __FBSDID("$FreeBSD$");
  * PURPOSE.
  */
 
-#define	CRYPTO_TIMING				/* enable timing support */
-
 #include "opt_compat.h"
 #include "opt_ddb.h"
 
@@ -238,12 +236,6 @@ static	struct cryptostats cryptostats;
 SYSCTL_STRUCT(_kern_crypto, OID_AUTO, stats, CTLFLAG_RW, &cryptostats,
 	    cryptostats, "Crypto system statistics");
 
-#ifdef CRYPTO_TIMING
-static	int crypto_timing = 0;
-SYSCTL_INT(_debug, OID_AUTO, crypto_timing, CTLFLAG_RW,
-	   &crypto_timing, 0, "Enable/disable crypto timing support");
-#endif
-
 /* Try to avoid directly exposing the key buffer as a symbol */
 static struct keybuf *keybuf;
 
@@ -1409,11 +1401,6 @@ crypto_dispatch(struct cryptop *crp)
 
 	cryptostats.cs_ops++;
 
-#ifdef CRYPTO_TIMING
-	if (crypto_timing)
-		binuptime(&crp->crp_tstamp);
-#endif
-
 	crp->crp_retw_id = ((uintptr_t)crp->crp_session) % crypto_workers_num;
 
 	if (CRYPTOP_ASYNC(crp)) {
@@ -1647,33 +1634,7 @@ crypto_kinvoke(struct cryptkop *krp)
 	return (0);
 }
 
-#ifdef CRYPTO_TIMING
 static void
-crypto_tstat(struct cryptotstat *ts, struct bintime *bt)
-{
-	struct bintime now, delta;
-	struct timespec t;
-	uint64_t u;
-
-	binuptime(&now);
-	u = now.frac;
-	delta.frac = now.frac - bt->frac;
-	delta.sec = now.sec - bt->sec;
-	if (u < delta.frac)
-		delta.sec--;
-	bintime2timespec(&delta, &t);
-	timespecadd(&ts->acc, &t, &ts->acc);
-	if (timespeccmp(&t, &ts->min, <))
-		ts->min = t;
-	if (timespeccmp(&t, &ts->max, >))
-		ts->max = t;
-	ts->count++;
-
-	*bt = now;
-}
-#endif
-
-static void
 crypto_task_invoke(void *ctx, int pending)
 {
 	struct cryptocap *cap;
@@ -1700,10 +1661,6 @@ crypto_invoke(struct cryptocap *cap, struct cryptop *c
 	KASSERT(crp->crp_session != NULL,
 	    ("%s: crp->crp_session == NULL", __func__));
 
-#ifdef CRYPTO_TIMING
-	if (crypto_timing)
-		crypto_tstat(&cryptostats.cs_invoke, &crp->crp_tstamp);
-#endif
 	if (cap->cc_flags & CRYPTOCAP_F_CLEANUP) {
 		struct crypto_session_params csp;
 		crypto_session_t nses;
@@ -1811,10 +1768,7 @@ crypto_done(struct cryptop *crp)
 	crp->crp_flags |= CRYPTO_F_DONE;
 	if (crp->crp_etype != 0)
 		cryptostats.cs_errs++;
-#ifdef CRYPTO_TIMING
-	if (crypto_timing)
-		crypto_tstat(&cryptostats.cs_done, &crp->crp_tstamp);
-#endif
+
 	/*
 	 * CBIMM means unconditionally do the callback immediately;
 	 * CBIFSYNC means do the callback immediately only if the
@@ -1831,20 +1785,7 @@ crypto_done(struct cryptop *crp)
 		 * callback routine does very little (e.g. the
 		 * /dev/crypto callback method just does a wakeup).
 		 */
-#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);
+		crp->crp_callback(crp);
 	} else {
 		struct crypto_ret_worker *ret_worker;
 		bool wake;
@@ -2144,22 +2085,8 @@ crypto_ret_proc(struct crypto_ret_worker *ret_worker)
 			/*
 			 * Run callbacks unlocked.
 			 */
-			if (crpt != NULL) {
-#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 = crpt->crp_tstamp;
-					crypto_tstat(&cryptostats.cs_cb, &t);
-					crpt->crp_callback(crpt);
-					crypto_tstat(&cryptostats.cs_finis, &t);
-				} else
-#endif
-					crpt->crp_callback(crpt);
-			}
+			if (crpt != NULL)
+				crpt->crp_callback(crpt);
 			if (krpt != NULL)
 				krpt->krp_callback(krpt);
 			CRYPTO_RETW_LOCK(ret_worker);

Modified: head/sys/opencrypto/cryptodev.h
==============================================================================
--- head/sys/opencrypto/cryptodev.h	Tue Jun 30 15:53:52 2020	(r362800)
+++ head/sys/opencrypto/cryptodev.h	Tue Jun 30 15:56:54 2020	(r362801)
@@ -326,13 +326,6 @@ struct crypt_kop {
 #define	CIOCFINDDEV	_IOWR('c', 108, struct crypt_find_op)
 #define	CIOCCRYPTAEAD	_IOWR('c', 109, struct crypt_aead)
 
-struct cryptotstat {
-	struct timespec	acc;		/* total accumulated time */
-	struct timespec	min;		/* min time */
-	struct timespec	max;		/* max time */
-	u_int32_t	count;		/* number of observations */
-};
-
 struct cryptostats {
 	u_int32_t	cs_ops;		/* symmetric crypto ops submitted */
 	u_int32_t	cs_errs;	/* symmetric crypto ops that failed */
@@ -342,16 +335,6 @@ struct cryptostats {
 	u_int32_t	cs_rets;	/* crypto return thread activations */
 	u_int32_t	cs_blocks;	/* symmetric op driver block */
 	u_int32_t	cs_kblocks;	/* symmetric op driver block */
-	/*
-	 * When CRYPTO_TIMING is defined at compile time and the
-	 * sysctl debug.crypto is set to 1, the crypto system will
-	 * accumulate statistics about how long it takes to process
-	 * crypto requests at various points during processing.
-	 */
-	struct cryptotstat cs_invoke;	/* crypto_dipsatch -> crypto_invoke */
-	struct cryptotstat cs_done;	/* crypto_invoke -> crypto_done */
-	struct cryptotstat cs_cb;	/* crypto_done -> callback */
-	struct cryptotstat cs_finis;	/* callback -> callback return */
 };
 
 #ifdef _KERNEL



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