Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Dec 2009 23:23:06 +0000 (UTC)
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r201231 - stable/7/sys/opencrypto
Message-ID:  <200912292323.nBTNN6Hq039706@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bz
Date: Tue Dec 29 23:23:05 2009
New Revision: 201231
URL: http://svn.freebsd.org/changeset/base/201231

Log:
  MFC r199885:
  
    Add SDT probes for opencrypto:deflate:deflate_gobal:*.
    They are not nice but they were helpful.

Modified:
  stable/7/sys/opencrypto/deflate.c
Directory Properties:
  stable/7/sys/   (props changed)
  stable/7/sys/cddl/contrib/opensolaris/   (props changed)
  stable/7/sys/contrib/dev/acpica/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)

Modified: stable/7/sys/opencrypto/deflate.c
==============================================================================
--- stable/7/sys/opencrypto/deflate.c	Tue Dec 29 23:21:07 2009	(r201230)
+++ stable/7/sys/opencrypto/deflate.c	Tue Dec 29 23:23:05 2009	(r201231)
@@ -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:



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