From owner-svn-src-head@FreeBSD.ORG Thu Apr 26 01:07:04 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B9699106566B; Thu, 26 Apr 2012 01:07:04 +0000 (UTC) (envelope-from rstone@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 896288FC08; Thu, 26 Apr 2012 01:07:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3Q174ao023011; Thu, 26 Apr 2012 01:07:04 GMT (envelope-from rstone@svn.freebsd.org) Received: (from rstone@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3Q174k2023007; Thu, 26 Apr 2012 01:07:04 GMT (envelope-from rstone@svn.freebsd.org) Message-Id: <201204260107.q3Q174k2023007@svn.freebsd.org> From: Ryan Stone Date: Thu, 26 Apr 2012 01:07:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234691 - in head: cddl/contrib/opensolaris/lib/libdtrace/common sys/cddl/contrib/opensolaris/uts/common/dtrace sys/cddl/contrib/opensolaris/uts/common/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Apr 2012 01:07:04 -0000 Author: rstone Date: Thu Apr 26 01:07:03 2012 New Revision: 234691 URL: http://svn.freebsd.org/changeset/base/234691 Log: Implement the D "cpu" variable, which returns curcpu. I have chosen not to follow the example of OpenSolaris and its descendants, which implemented cpu as an inline that took a value out of curthread. At certain points in the FreeBSD scheduler curthread->td_oncpu will no longer be valid (in particukar, just before the thread gets descheduled) so instead I have implemented this as its own built-in variable. Sponsored by: Sandvine Inc. MFC after: 1 week Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c Thu Apr 26 00:51:43 2012 (r234690) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c Thu Apr 26 01:07:03 2012 (r234691) @@ -497,6 +497,12 @@ static const dt_ident_t _dtrace_globals[ { "zonename", DT_IDENT_SCALAR, 0, DIF_VAR_ZONENAME, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" }, #endif + +#if !defined(sun) +{ "cpu", DT_IDENT_SCALAR, 0, DIF_VAR_CPU, + DT_ATTR_STABCMN, DT_VERS_1_6_3, &dt_idops_type, "int" }, +#endif + { NULL, 0, 0, 0, { 0, 0, 0 }, 0, NULL, NULL } }; Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Thu Apr 26 00:51:43 2012 (r234690) +++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Thu Apr 26 01:07:03 2012 (r234691) @@ -3143,6 +3143,11 @@ dtrace_dif_variable(dtrace_mstate_t *mst return (curthread->td_errno); #endif } +#if !defined(sun) + case DIF_VAR_CPU: { + return curcpu; + } +#endif default: DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP); return (0); Modified: head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h Thu Apr 26 00:51:43 2012 (r234690) +++ head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h Thu Apr 26 01:07:03 2012 (r234691) @@ -251,6 +251,10 @@ typedef enum dtrace_probespec { #define DIF_VAR_ERRNO 0x0120 /* thread errno */ #define DIF_VAR_EXECARGS 0x0121 /* process arguments */ +#if !defined(sun) +#define DIF_VAR_CPU 0x0200 +#endif + #define DIF_SUBR_RAND 0 #define DIF_SUBR_MUTEX_OWNED 1 #define DIF_SUBR_MUTEX_OWNER 2