Add SDT probes for opencrypto:deflate:deflate_gobal:*.
They are not nice but they were helpful. MFC after: 6 days
This commit is contained in:
parent
df21ad6e41
commit
d9c18e5627
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=199885
@ -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 @@ deflate_global(data, size, decomp, out)
|
||||
}
|
||||
}
|
||||
*out = output;
|
||||
SDT_PROBE2(opencrypto, deflate, deflate_global, return, decomp, result);
|
||||
return result;
|
||||
|
||||
bad:
|
||||
|
Loading…
Reference in New Issue
Block a user