From owner-cvs-all@FreeBSD.ORG Sun Nov 16 00:39:46 2003 Return-Path: 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 2BEE416A4CE; Sun, 16 Nov 2003 00:39:46 -0800 (PST) Received: from xorpc.icir.org (xorpc.icir.org [192.150.187.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 17C5943FBD; Sun, 16 Nov 2003 00:39:43 -0800 (PST) (envelope-from rizzo@xorpc.icir.org) Received: from xorpc.icir.org (localhost [127.0.0.1]) by xorpc.icir.org (8.12.9p1/8.12.3) with ESMTP id hAG8deFw016417; Sun, 16 Nov 2003 00:39:40 -0800 (PST) (envelope-from rizzo@xorpc.icir.org) Received: (from rizzo@localhost) by xorpc.icir.org (8.12.9p1/8.12.3/Submit) id hAG8ddhf016415; Sun, 16 Nov 2003 00:39:39 -0800 (PST) (envelope-from rizzo) Date: Sun, 16 Nov 2003 00:39:39 -0800 From: Luigi Rizzo To: Peter Jeremy Message-ID: <20031116003939.A10853@xorpc.icir.org> References: <200311142102.hAEL2Nen073186@repoman.freebsd.org> <20031114153145.A54064@xorpc.icir.org> <3FB593F5.1053E7E2@pipeline.ch> <20031115002921.B68056@xorpc.icir.org> <3FB60181.4256A519@pipeline.ch> <20031116014814.GB74756@server.vk2pj.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20031116014814.GB74756@server.vk2pj.dyndns.org>; from peterjeremy@optushome.com.au on Sun, Nov 16, 2003 at 12:48:14PM +1100 cc: Andre Oppermann cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/netinet in_var.h ip_fastfwd.c ip_flow.c ip_flow.h ip_input.c ip_output.c src/sys/sys mbuf.h src/sys/conf files src/sys/net if_arcsubr.c if_ef.c if_ethersubr.c if_fddisubr.c if_iso88025subr.c if_ppp.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 08:39:46 -0000 On Sun, Nov 16, 2003 at 12:48:14PM +1100, Peter Jeremy wrote: ... > >I will try to measure that with more precision. You did have > >code which was able to record and timestamp events several > >thousand times per second. Do still have that code somewhere? there is some MD code in the RELENG_4 tree, the kernel option you need is "options KERN_TIMESTAMP" and a description on how to use it is in sys/i386/include/param.h Note that you have to be careful when timing very short sections of code, because the CPU can execute instruction out of order so something like rdtsc(); rdtsc() might result in the second timing call being executed before the section of code in the middle is complete. There is some nonintuitive instruction (which i now forget) to flush the execution pipeline which can be used around the section of code you want to time. In an SMP environment this code probably will not work well because it does not consider parallel access to the counters, nor the CPU where events occur (probably you could use a per-cpu index, and then in many cases you only care about relative measurements of events on the same CPU). cheers luigi > I've done similar things a couple of times using circular buffers > along the following lines: > > #define RING_SIZE (1 << some_suitable_value) > int next_entry; > struct entry { > some_time_t now; > foo_t event; > } ring[RING_SIZE]; > > void __inline insert_event(foo_t event) > { > int ix; > /* following two lines need to be atomic to make this re-entrant */ > ix = next_entry; > next_entry = (ix + 1) & (RING_SIZE - 1); > ring[ix].now = read_time(); > ring[ix].event = event; > } > > In userland, mmap(2) next_entry and ring to unload the events. Pick > RING_SIZE and the time types to suit requirements. The TSC has the > lowest overhead but worst jitter. > > Peter