diff options
author | bz <bz@FreeBSD.org> | 2009-11-28 17:20:41 +0000 |
---|---|---|
committer | bz <bz@FreeBSD.org> | 2009-11-28 17:20:41 +0000 |
commit | fe50e0c755f8c366fef5ff65f3eb1911345ef4df (patch) | |
tree | e942c6ad6a77cbeebf3755081121439abc126178 /sys/opencrypto | |
parent | 6ecc5a340c9ced496b21c438f0005b7d30efe86d (diff) | |
download | FreeBSD-src-fe50e0c755f8c366fef5ff65f3eb1911345ef4df.zip FreeBSD-src-fe50e0c755f8c366fef5ff65f3eb1911345ef4df.tar.gz |
Add SDT probes for opencrypto:deflate:deflate_gobal:*.
They are not nice but they were helpful.
MFC after: 6 days
Diffstat (limited to 'sys/opencrypto')
-rw-r--r-- | sys/opencrypto/deflate.c | 68 |
1 files changed, 61 insertions, 7 deletions
diff --git a/sys/opencrypto/deflate.c b/sys/opencrypto/deflate.c index f4b4f48..239435e 100644 --- a/sys/opencrypto/deflate.c +++ b/sys/opencrypto/deflate.c @@ -35,16 +35,30 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "opt_kdtrace.h" + #include <sys/types.h> #include <sys/param.h> #include <sys/malloc.h> #include <sys/param.h> +#include <sys/kernel.h> +#include <sys/sdt.h> #include <sys/systm.h> #include <net/zlib.h> #include <opencrypto/cryptodev.h> #include <opencrypto/deflate.h> +SDT_PROVIDER_DECLARE(opencrypto); +SDT_PROBE_DEFINE2(opencrypto, deflate, deflate_global, entry, + "int", "u_int32_t"); +SDT_PROBE_DEFINE5(opencrypto, deflate, deflate_global, bad, + "int", "int", "int", "int", "int"); +SDT_PROBE_DEFINE5(opencrypto, deflate, deflate_global, iter, + "int", "int", "int", "int", "int"); +SDT_PROBE_DEFINE2(opencrypto, deflate, deflate_global, return, + "int", "u_int32_t"); + int window_inflate = -1 * MAX_WBITS; int window_deflate = -12; @@ -68,6 +82,8 @@ deflate_global(data, size, decomp, out) int error, i = 0, j; struct deflate_buf buf[ZBUF]; + SDT_PROBE2(opencrypto, deflate, deflate_global, entry, decomp, size); + bzero(&zbuf, sizeof(z_stream)); for (j = 0; j < ZBUF; j++) buf[j].flag = 0; @@ -81,8 +97,11 @@ deflate_global(data, size, decomp, out) if (!decomp) { buf[i].out = malloc((u_long) size, M_CRYPTO_DATA, M_NOWAIT); - if (buf[i].out == NULL) + if (buf[i].out == NULL) { + SDT_PROBE3(opencrypto, deflate, deflate_global, bad, + decomp, 0, __LINE__); goto bad; + } buf[i].size = size; buf[i].flag = 1; i++; @@ -96,8 +115,11 @@ deflate_global(data, size, decomp, out) buf[i].out = malloc((u_long) (size * 4), M_CRYPTO_DATA, M_NOWAIT); - if (buf[i].out == NULL) + if (buf[i].out == NULL) { + SDT_PROBE3(opencrypto, deflate, deflate_global, bad, + decomp, 0, __LINE__); goto bad; + } buf[i].size = size * 4; buf[i].flag = 1; i++; @@ -110,36 +132,67 @@ deflate_global(data, size, decomp, out) deflateInit2(&zbuf, Z_DEFAULT_COMPRESSION, Z_METHOD, window_deflate, Z_MEMLEVEL, Z_DEFAULT_STRATEGY); - if (error != Z_OK) + if (error != Z_OK) { + SDT_PROBE3(opencrypto, deflate, deflate_global, bad, + decomp, error, __LINE__); goto bad; + } for (;;) { error = decomp ? inflate(&zbuf, Z_PARTIAL_FLUSH) : deflate(&zbuf, Z_PARTIAL_FLUSH); - if (error != Z_OK && error != Z_STREAM_END) + if (error != Z_OK && error != Z_STREAM_END) { + /* + * Unfortunately we are limited to 5 arguments, + * thus use two probes. + */ + SDT_PROBE5(opencrypto, deflate, deflate_global, bad, + decomp, error, __LINE__, + zbuf.avail_in, zbuf.avail_out); + SDT_PROBE5(opencrypto, deflate, deflate_global, bad, + decomp, error, __LINE__, + zbuf.state->dummy, zbuf.total_out); goto bad; + } else if (zbuf.avail_in == 0 && zbuf.avail_out != 0) goto end; else if (zbuf.avail_out == 0 && i < (ZBUF - 1)) { /* we need more output space, allocate size */ buf[i].out = malloc((u_long) size, M_CRYPTO_DATA, M_NOWAIT); - if (buf[i].out == NULL) + if (buf[i].out == NULL) { + SDT_PROBE3(opencrypto, deflate, deflate_global, + bad, decomp, 0, __LINE__); goto bad; + } zbuf.next_out = buf[i].out; buf[i].size = size; buf[i].flag = 1; zbuf.avail_out = buf[i].size; i++; - } else + } else { + /* + * Unfortunately we are limited to 5 arguments, + * thus, again, use two probes. + */ + SDT_PROBE5(opencrypto, deflate, deflate_global, bad, + decomp, error, __LINE__, + zbuf.avail_in, zbuf.avail_out); + SDT_PROBE5(opencrypto, deflate, deflate_global, bad, + decomp, error, __LINE__, + zbuf.state->dummy, zbuf.total_out); goto bad; + } } end: result = count = zbuf.total_out; *out = malloc((u_long) result, M_CRYPTO_DATA, M_NOWAIT); - if (*out == NULL) + if (*out == NULL) { + SDT_PROBE3(opencrypto, deflate, deflate_global, bad, + decomp, 0, __LINE__); goto bad; + } if (decomp) inflateEnd(&zbuf); else @@ -160,6 +213,7 @@ end: } } *out = output; + SDT_PROBE2(opencrypto, deflate, deflate_global, return, decomp, result); return result; bad: |