From owner-cvs-all Sun Jun 30 0:56:57 2002 Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6C95737B401; Sun, 30 Jun 2002 00:56:50 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0D82F43E0A; Sun, 30 Jun 2002 00:56:50 -0700 (PDT) (envelope-from luigi@FreeBSD.org) Received: from freefall.freebsd.org (luigi@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g5U7unJU089254; Sun, 30 Jun 2002 00:56:49 -0700 (PDT) (envelope-from luigi@freefall.freebsd.org) Received: (from luigi@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g5U7unht089253; Sun, 30 Jun 2002 00:56:49 -0700 (PDT) Message-Id: <200206300756.g5U7unht089253@freefall.freebsd.org> From: Luigi Rizzo Date: Sun, 30 Jun 2002 00:56:49 -0700 (PDT) To: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: cvs commit: src/sys/i386/isa clock.c src/sys/i386/include param.h src/sys/conf options.i386 X-FreeBSD-CVS-Branch: RELENG_4 Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG luigi 2002/06/30 00:56:49 PDT Modified files: (Branch: RELENG_4) sys/i386/isa clock.c sys/i386/include param.h sys/conf options.i386 Log: Add one function and one macro to timestamp events in the kernel using the TSC register and which are just too conveninent not to have them around. The macro (defined in sys/i386/include/param.h) is called TSTMP(class:4, unit:4, event:8, par:16) which in turn calls _TSTMP(arg) (function defined in sys/i386/isa/clock.c) which stores a pair of u_int32_t values in a circular buffer exported to userland as the sysctl variable debug.timestamp The content of the buffer can be printed with something like sysctl -b debug.timestamp | hexdump -e '"%15u %15u\n"' This functionality must be enabled with "options KERN_TIMESTAMP", otherwise both the macro and the function are redefined as empty blocks. This code is i586+ specific, but it does not make any attempt to grab locks, identify which CPU it is running on, etc. etc. -- it is a debugging tool, and a very very simple and low level one, so you are supposed to know how to use it if you do not want to get random numbers out of it. I am committing this to RELENG_4 only because on -current parts of the kernel might run concurrently, so the use of a single unprotected static variable as the index of the next entry in the buffer might lead to inconsistent results. Plus, there might be similar stuff in -current already. If someone feels like porting this code to -current, it might be a good idea to keep separate per-cpu buffers to avoid the cost of protecting against concurrent accesses. Revision Changes Path 1.132.2.16 +1 -0 src/sys/conf/options.i386 1.54.2.7 +36 -1 src/sys/i386/include/param.h 1.149.2.5 +20 -0 src/sys/i386/isa/clock.c To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message