From owner-freebsd-net@FreeBSD.ORG Thu Jun 10 09:45:37 2010 Return-Path: Delivered-To: freebsd-net@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6304A106564A; Thu, 10 Jun 2010 09:45:37 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail08.syd.optusnet.com.au (mail08.syd.optusnet.com.au [211.29.132.189]) by mx1.freebsd.org (Postfix) with ESMTP id F3EC58FC16; Thu, 10 Jun 2010 09:45:36 +0000 (UTC) Received: from c122-106-175-69.carlnfd1.nsw.optusnet.com.au (c122-106-175-69.carlnfd1.nsw.optusnet.com.au [122.106.175.69]) by mail08.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o5A9jXPe003494 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 10 Jun 2010 19:45:34 +1000 Date: Thu, 10 Jun 2010 19:45:32 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Jung-uk Kim In-Reply-To: <201006091444.50560.jkim@FreeBSD.org> Message-ID: <20100610173950.T33647@delplex.bde.org> References: <201006091444.50560.jkim@FreeBSD.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-net@FreeBSD.org Subject: Re: [RFC] BPF timestamping X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jun 2010 09:45:37 -0000 On Wed, 9 Jun 2010, Jung-uk Kim wrote: > bpf(4) can only timestamp packets with microtime(9). I want to expand > it to be able to use different format and resolution. The patch is > here: > > http://people.freebsd.org/~jkim/bpf_tstamp.diff > > With this patch, we can select different format and resolution of the > timestamps. It is done via ioctl(2) with BIOCSTSTAMP command. > Similarly, you can get the current format and resolution with > BIOCGTSTAMP command. Currently, the following functions are > available: > > BPF_T_MICROTIME microtime(9) > BPF_T_NANOTIME nanotime(9) > BPF_T_BINTIME bintime(9) > BPF_T_MICROTIME_FAST getmicrotime(9) > BPF_T_NANOTIME_FAST getnanotime(9) > BPF_T_BINTIME_FAST getbintime(9) > BPF_T_NONE ignore time stamps This has too many timestamp types, yet not one timestamp type which is any good except possibly BPF_T_NONE, and not one monotonic timestamp type. Only external uses and compatibility require use of CLOCK_REALTIME. I recently tried looking at timeout resolution on FreeBSD cluster machines using ktrace, and found ktrace unusable for this. At first I blamed the slowness of the default misconfiguered timecounter ACPI-fast, but the main problem was that I forgot my home directory was on nfs, and nfs makes writing ktrace records take hundreds of times longer than on local file systems. ACPI-fast seemed to be taking nearly 1000 uS, but it was nfs taking that long. Anyway, ACPI-fast takes nearly 1000 nS, which is many times too long to be good for timestamping individual syscalls or packets, and makes sub-microseconds resolution useless. The above non-get *time() interfaces still use the primary timecounter, and this might be slow even if it is not misconfigured. The above get*time() interfaces are fast only at the cost of being broken. Among other bugs, their times only change at relatively large intervals which should become infinity with tickless kernels. (BTW, icmp timestamps are still broken on systems with hz < 100. Someone changed microtime() to getmicrotime(), but getmicrotime() cannot deliver the resolution of 1 mS supported by icmp timestamps unless these intervals are <= 1 mS.) Bruce