From owner-freebsd-bugs@FreeBSD.ORG Mon Apr 8 09:50:00 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 949EAC72 for ; Mon, 8 Apr 2013 09:50:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 79535EE3 for ; Mon, 8 Apr 2013 09:50:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.6/8.14.6) with ESMTP id r389o06Y041895 for ; Mon, 8 Apr 2013 09:50:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.6/8.14.6/Submit) id r389o0c4041894; Mon, 8 Apr 2013 09:50:00 GMT (envelope-from gnats) Resent-Date: Mon, 8 Apr 2013 09:50:00 GMT Resent-Message-Id: <201304080950.r389o0c4041894@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Tiwei Bie Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 55484B93 for ; Mon, 8 Apr 2013 09:41:58 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 2BD3BEA4 for ; Mon, 8 Apr 2013 09:41:58 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r389fvpM058958 for ; Mon, 8 Apr 2013 09:41:57 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id r389fvji058950; Mon, 8 Apr 2013 09:41:57 GMT (envelope-from nobody) Message-Id: <201304080941.r389fvji058950@red.freebsd.org> Date: Mon, 8 Apr 2013 09:41:57 GMT From: Tiwei Bie To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: kern/177706: DTrace sched:::off-cpu args[0] should point to newtd X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Apr 2013 09:50:00 -0000 >Number: 177706 >Category: kern >Synopsis: DTrace sched:::off-cpu args[0] should point to newtd >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Apr 08 09:50:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Tiwei Bie >Release: FreeBSD 9.1-RELEASE-p2 >Organization: zzu(school) >Environment: FreeBSD thinkCentre 9.1-RELEASE-p2 FreeBSD 9.1-RELEASE-p2 #2 r+4b79fde-dirty: Mon Apr 8 14:02:34 CST 2013 btw@thinkCentre:/usr/obj/usr/src/sys/CUSTOM amd64 >Description: According to Solaris Dynamic Tracing Guide[1], in off-cpu, args[0] should point to the lwpsinfo_t (in FreeBSD, it is struct thread) structure of the thread that the current CPU will next execute. But in the current implementation (including -CURRENT), args[0] points to the thread that is ending execution. [1] http://docs.oracle.com/cd/E18752_01/html/817-6223/gelro.html >How-To-Repeat: Using the following scripts can repeat the problem: #!/usr/sbin/dtrace -s dtrace:::BEGIN { printf("%19s %19s %19s %19s", "curthread", "curproc", "nextthread", "nextproc"); } sched:::off-cpu { printf("%19s %19s %19s %19s", curthread->td_name, curthread->td_proc->p_comm, args[0]->td_name, args[1]->p_comm); } >Fix: Just something like this: --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -1903,7 +1903,7 @@ sched_switch(struct thread *td, struct thread *newtd, int if (PMC_PROC_IS_USING_PMCS(td->td_proc)) PMC_SWITCH_CONTEXT(td, PMC_FN_CSW_OUT); #endif - SDT_PROBE2(sched, , , off_cpu, td, td->td_proc); + SDT_PROBE2(sched, , , off_cpu, newtd, newtd->td_proc); lock_profile_release_lock(&TDQ_LOCKPTR(tdq)->lock_object); TDQ_LOCKPTR(tdq)->mtx_lock = (uintptr_t)newtd; sched_pctcpu_update(newtd->td_sched, 0); >Release-Note: >Audit-Trail: >Unformatted: