Page MenuHomeFreeBSD

D25466.id73694.diff
No OneTemporary

D25466.id73694.diff

Index: sys/opencrypto/crypto.c
===================================================================
--- sys/opencrypto/crypto.c
+++ sys/opencrypto/crypto.c
@@ -59,7 +59,7 @@
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/eventhandler.h>
+#include <sys/counter.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
#include <sys/linker.h>
@@ -232,9 +232,32 @@
static void crypto_task_invoke(void *ctx, int pending);
static void crypto_batch_enqueue(struct cryptop *crp);
-static struct cryptostats cryptostats;
-SYSCTL_STRUCT(_kern_crypto, OID_AUTO, stats, CTLFLAG_RW, &cryptostats,
- cryptostats, "Crypto system statistics");
+static counter_u64_t
+ cryptostats[sizeof(struct cryptostats) / sizeof(counter_u64_t)];
+SYSCTL_COUNTER_U64_ARRAY(_kern_crypto, OID_AUTO, stats, CTLFLAG_RW,
+ cryptostats, nitems(cryptostats),
+ "Crypto system statistics");
+
+#define CRYPTOSTAT_INC(stat) do { \
+ counter_u64_add( \
+ cryptostats[offsetof(struct cryptostats, stat) / sizeof(uint64_t)],\
+ 1); \
+} while (0)
+
+static void
+cryptostats_init(void *arg __unused)
+{
+ COUNTER_ARRAY_ALLOC(cryptostats, nitems(cryptostats), M_WAITOK);
+}
+SYSINIT(cryptostats_init, SI_SUB_COUNTER, SI_ORDER_ANY, cryptostats_init, NULL);
+
+static void
+cryptostats_fini(void *arg __unused)
+{
+ COUNTER_ARRAY_FREE(cryptostats, nitems(cryptostats));
+}
+SYSUNINIT(cryptostats_fini, SI_SUB_COUNTER, SI_ORDER_ANY, cryptostats_fini,
+ NULL);
/* Try to avoid directly exposing the key buffer as a symbol */
static struct keybuf *keybuf;
@@ -1399,7 +1422,7 @@
crp_sanity(crp);
#endif
- cryptostats.cs_ops++;
+ CRYPTOSTAT_INC(cs_ops);
crp->crp_retw_id = ((uintptr_t)crp->crp_session) % crypto_workers_num;
@@ -1460,7 +1483,7 @@
{
int error;
- cryptostats.cs_kops++;
+ CRYPTOSTAT_INC(cs_kops);
krp->krp_cap = NULL;
error = crypto_kinvoke(krp);
@@ -1767,7 +1790,7 @@
("crypto_done: op already done, flags 0x%x", crp->crp_flags));
crp->crp_flags |= CRYPTO_F_DONE;
if (crp->crp_etype != 0)
- cryptostats.cs_errs++;
+ CRYPTOSTAT_INC(cs_errs);
/*
* CBIMM means unconditionally do the callback immediately;
@@ -1839,7 +1862,7 @@
struct cryptocap *cap;
if (krp->krp_status != 0)
- cryptostats.cs_kerrs++;
+ CRYPTOSTAT_INC(cs_kerrs);
CRYPTO_DRIVER_LOCK();
cap = krp->krp_cap;
KASSERT(cap->cc_koperations > 0, ("cc_koperations == 0"));
@@ -1979,7 +2002,7 @@
*/
cap->cc_qblocked = 1;
TAILQ_INSERT_HEAD(&crp_q, submit, crp_next);
- cryptostats.cs_blocks++;
+ CRYPTOSTAT_INC(cs_blocks);
}
}
@@ -2016,7 +2039,7 @@
*/
krp->krp_cap->cc_kqblocked = 1;
TAILQ_INSERT_HEAD(&crp_kq, krp, krp_next);
- cryptostats.cs_kblocks++;
+ CRYPTOSTAT_INC(cs_kblocks);
}
}
@@ -2038,7 +2061,7 @@
crp_sleep = 0;
if (cryptoproc == NULL)
break;
- cryptostats.cs_intrs++;
+ CRYPTOSTAT_INC(cs_intrs);
}
}
CRYPTO_Q_UNLOCK();
@@ -2099,7 +2122,7 @@
"crypto_ret_wait", 0);
if (ret_worker->cryptoretproc == NULL)
break;
- cryptostats.cs_rets++;
+ CRYPTOSTAT_INC(cs_rets);
}
}
CRYPTO_RETW_UNLOCK(ret_worker);
Index: sys/opencrypto/cryptodev.h
===================================================================
--- sys/opencrypto/cryptodev.h
+++ sys/opencrypto/cryptodev.h
@@ -334,14 +334,14 @@
};
struct cryptostats {
- u_int32_t cs_ops; /* symmetric crypto ops submitted */
- u_int32_t cs_errs; /* symmetric crypto ops that failed */
- u_int32_t cs_kops; /* asymetric/key ops submitted */
- u_int32_t cs_kerrs; /* asymetric/key ops that failed */
- u_int32_t cs_intrs; /* crypto swi thread activations */
- 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 */
+ uint64_t cs_ops; /* symmetric crypto ops submitted */
+ uint64_t cs_errs; /* symmetric crypto ops that failed */
+ uint64_t cs_kops; /* asymetric/key ops submitted */
+ uint64_t cs_kerrs; /* asymetric/key ops that failed */
+ uint64_t cs_intrs; /* crypto swi thread activations */
+ uint64_t cs_rets; /* crypto return thread activations */
+ uint64_t cs_blocks; /* symmetric op driver block */
+ uint64_t cs_kblocks; /* symmetric op driver block */
};
#ifdef _KERNEL

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 17, 2:56 PM (1 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25422359
Default Alt Text
D25466.id73694.diff (4 KB)

Event Timeline