From owner-p4-projects@FreeBSD.ORG Tue Jun 13 00:50:26 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7A48E16A478; Tue, 13 Jun 2006 00:50:26 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 58F9816A41A for ; Tue, 13 Jun 2006 00:50:26 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5B4E643D58 for ; Tue, 13 Jun 2006 00:50:01 +0000 (GMT) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k5D0liA4052539 for ; Tue, 13 Jun 2006 00:47:44 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5D0liTa052536 for perforce@freebsd.org; Tue, 13 Jun 2006 00:47:44 GMT (envelope-from jb@freebsd.org) Date: Tue, 13 Jun 2006 00:47:44 GMT Message-Id: <200606130047.k5D0liTa052536@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 99099 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jun 2006 00:50:26 -0000 http://perforce.freebsd.org/chv.cgi?CH=99099 Change 99099 by jb@jb_freebsd2 on 2006/06/13 00:47:28 Add hooks for DTrace to register a function to be called when the scheduler chooses a new thread to run. This is required for DTrace vtime. Affected files ... .. //depot/projects/dtrace/src/sys/kern/kern_switch.c#3 edit .. //depot/projects/dtrace/src/sys/sys/proc.h#6 edit Differences ... ==== //depot/projects/dtrace/src/sys/kern/kern_switch.c#3 (text+ko) ==== @@ -88,6 +88,7 @@ #include __FBSDID("$FreeBSD: src/sys/kern/kern_switch.c,v 1.121 2006/06/01 22:45:56 cognet Exp $"); +#include "opt_kdtrace.h" #include "opt_sched.h" #ifndef KERN_SWITCH_INCLUDE @@ -126,6 +127,11 @@ #define td_kse td_sched +#ifdef KDTRACE +int dtrace_vtime_active; +dtrace_vtime_switch_func_t dtrace_vtime_switch_func; +#endif + /* * kern.sched.preemption allows user space to determine if preemption support * is compiled in or not. It is not currently a boot or runtime flag that ==== //depot/projects/dtrace/src/sys/sys/proc.h#6 (text+ko) ==== @@ -484,7 +484,17 @@ #define TD_CLR_SUSPENDED(td) TD_CLR_INHIB((td), TDI_SUSPENDED) #define TD_CLR_IWAIT(td) TD_CLR_INHIB((td), TDI_IWAIT) +#ifdef KDTRACE +typedef void (*dtrace_vtime_switch_func_t)(struct thread *); + +extern int dtrace_vtime_active; +extern dtrace_vtime_switch_func_t dtrace_vtime_switch_func; +#define TD_SET_RUNNING(td) if (dtrace_vtime_active) \ + (*dtrace_vtime_switch_func)(td); \ + (td)->td_state = TDS_RUNNING +#else #define TD_SET_RUNNING(td) (td)->td_state = TDS_RUNNING +#endif #define TD_SET_RUNQ(td) (td)->td_state = TDS_RUNQ #define TD_SET_CAN_RUN(td) (td)->td_state = TDS_CAN_RUN