Skip to content

Commit

Permalink
Remove CRYPTO_TIMING.
Browse files Browse the repository at this point in the history
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

(cherry picked from commit a5c053f)
  • Loading branch information
markjdb authored and mjguzik committed Sep 16, 2021
1 parent 2fc0550 commit 16ffd82
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 94 deletions.
81 changes: 4 additions & 77 deletions sys/opencrypto/crypto.c
Expand Up @@ -54,8 +54,6 @@ __FBSDID("$FreeBSD$");
* PURPOSE.
*/

#define CRYPTO_TIMING /* enable timing support */

#include "opt_ddb.h"

#include <sys/param.h>
Expand Down Expand Up @@ -223,12 +221,6 @@ static struct cryptostats cryptostats;
SYSCTL_STRUCT(_kern, OID_AUTO, crypto_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;

Expand Down Expand Up @@ -1014,11 +1006,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)) {
Expand Down Expand Up @@ -1224,32 +1211,6 @@ crypto_kinvoke(struct cryptkop *krp, int crid)
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)
{
Expand Down Expand Up @@ -1279,10 +1240,6 @@ crypto_invoke(struct cryptocap *cap, struct cryptop *crp, int hint)
("%s: crp->crp_callback == NULL", __func__));
KASSERT(crp->crp_desc != NULL, ("%s: crp->crp_desc == 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 cryptodesc *crd;
crypto_session_t nses;
Expand Down Expand Up @@ -1394,10 +1351,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
Expand All @@ -1414,20 +1368,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;
Expand Down Expand Up @@ -1732,22 +1673,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);
Expand Down
17 changes: 0 additions & 17 deletions sys/opencrypto/cryptodev.h
Expand Up @@ -348,13 +348,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 */
Expand All @@ -364,16 +357,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
Expand Down

0 comments on commit 16ffd82

Please sign in to comment.