Permalink
Browse files

1456 DTrace profile and tick probes sometimes don't fire in a zone

Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Gordon Ross <gwr@nexenta.com>
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Approved by: Garrett D'Amore <garrett@nexenta.com>
  • Loading branch information...
1 parent c090e5d commit 7d5c9b5fdaad32a290692afde7867bd051784395 @bcantrill bcantrill committed Jul 6, 2011
@@ -0,0 +1,72 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2011, Joyent, Inc. All rights reserved.
+#
+
+ppriv -s A=basic,dtrace_user $$
+
+#
+# We expect some number of these profile probes to be silently dropped.
+# Note that this test will fail if something is stuck on all CPUs that
+# whomever is running the test happens to own.
+#
+count=$(/usr/sbin/dtrace -q -s /dev/stdin <<EOF
+BEGIN
+{
+ start = timestamp;
+ @ = count();
+}
+
+ERROR
+{
+ exit(1);
+}
+
+profile-1000hz
+{
+ @ = count();
+}
+
+tick-10ms
+{
+ ticks++;
+}
+
+tick-10ms
+/ticks > 100/
+{
+ printa("%@d", @);
+ exit(0);
+}
+EOF)
+
+cpus=`psrinfo | grep -- on-line | wc -l`
+max=`expr $cpus \* 500`
+
+if [[ $count -gt $max ]]; then
+ echo "count ($count) is greater than allowed max ($max)"
+ exit 1
+fi
+
+echo "count ($count) is within allowed max ($max)"
+exit 0
@@ -0,0 +1,61 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2011, Joyent, Inc. All rights reserved.
+#
+
+ppriv -s A=basic,dtrace_user $$
+
+#
+# We expect at least one of these tick probes to error out because only
+# dtrace_user is set, and we are attempting to access arguments. Note that
+# this test will fail if something is stuck on CPU that whomever is running
+# the test happens to own.
+#
+/usr/sbin/dtrace -q -s /dev/stdin <<EOF
+BEGIN
+{
+ start = timestamp;
+}
+
+tick-1000hz
+{
+ @[arg0] = count();
+}
+
+ERROR
+{
+ errcnt++;
+}
+
+tick-10ms
+{
+ ticks++;
+}
+
+tick-10ms
+/ticks > 100/
+{
+ printf("error count is %d\n", errcnt);
+ exit(errcnt != 0 ? 0 : 1);
+}
+EOF
@@ -0,0 +1,55 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2011, Joyent, Inc. All rights reserved.
+#
+
+ppriv -s A=basic,dtrace_user $$
+
+#
+# We expect tick probes to fire if dtrace_user is set
+#
+/usr/sbin/dtrace -q -s /dev/stdin <<EOF
+BEGIN
+{
+ start = timestamp;
+}
+
+tick-10ms
+{
+ ticks++;
+}
+
+tick-10ms
+/ticks > 10 && (this->ms = (timestamp - start) / 1000000) > 2000/
+{
+ printf("expected completion in 100 ms, found %d!\n", this->ms);
+ exit(1);
+}
+
+tick-10ms
+/ticks > 10/
+{
+ printf("completed in %d ms\n", this->ms);
+ exit(0);
+}
+EOF
@@ -1300,7 +1300,10 @@ file path=opt/SUNWdtrt/tst/common/printf/tst.widths1.d mode=0444
file path=opt/SUNWdtrt/tst/common/printf/tst.wp.d mode=0444
file path=opt/SUNWdtrt/tst/common/printf/tst.wp.d.out mode=0444
file path=opt/SUNWdtrt/tst/common/privs/tst.func_access.ksh mode=0444
+file path=opt/SUNWdtrt/tst/common/privs/tst.noprivdrop.ksh mode=0444
+file path=opt/SUNWdtrt/tst/common/privs/tst.noprivrestrict.ksh mode=0444
file path=opt/SUNWdtrt/tst/common/privs/tst.op_access.ksh mode=0444
+file path=opt/SUNWdtrt/tst/common/privs/tst.tick.ksh mode=0444
file path=opt/SUNWdtrt/tst/common/privs/tst.unpriv_funcs.ksh mode=0444
file path=opt/SUNWdtrt/tst/common/probes/err.D_PDESC_ZERO.probeqtn.d mode=0444
file path=opt/SUNWdtrt/tst/common/probes/err.D_PDESC_ZERO.probestar.d \
@@ -339,9 +339,13 @@ dcpc_destroy(void *arg, dtrace_id_t id, void *parg)
/*ARGSUSED*/
static int
-dcpc_usermode(void *arg, dtrace_id_t id, void *parg)
+dcpc_mode(void *arg, dtrace_id_t id, void *parg)
{
- return (CPU->cpu_cpcprofile_pc == 0);
+ if (CPU->cpu_cpcprofile_pc == 0) {
+ return (DTRACE_MODE_NOPRIV_DROP | DTRACE_MODE_USER);
+ } else {
+ return (DTRACE_MODE_NOPRIV_DROP | DTRACE_MODE_KERNEL);
+ }
}
static void
@@ -1013,7 +1017,7 @@ static dtrace_pops_t dcpc_pops = {
NULL,
NULL,
NULL,
- dcpc_usermode,
+ dcpc_mode,
dcpc_destroy
};
Oops, something went wrong.

0 comments on commit 7d5c9b5

Please sign in to comment.