From owner-svn-src-head@FreeBSD.ORG Sun Dec 4 12:31:19 2011 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7AB36106567C; Sun, 4 Dec 2011 12:31:19 +0000 (UTC) (envelope-from lstewart@freebsd.org) Received: from lauren.room52.net (lauren.room52.net [210.50.193.198]) by mx1.freebsd.org (Postfix) with ESMTP id 05E9F8FC15; Sun, 4 Dec 2011 12:31:18 +0000 (UTC) Received: from lstewart1.loshell.room52.net (ppp59-167-184-191.static.internode.on.net [59.167.184.191]) by lauren.room52.net (Postfix) with ESMTPSA id 6F1C47E84A; Sun, 4 Dec 2011 23:31:16 +1100 (EST) Message-ID: <4EDB6814.9040403@freebsd.org> Date: Sun, 04 Dec 2011 23:31:16 +1100 From: Lawrence Stewart User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:7.0.1) Gecko/20111016 Thunderbird/7.0.1 MIME-Version: 1.0 To: Jung-uk Kim References: <201111210417.pAL4HOdi023556@svn.freebsd.org> <4ED8575D.2010405@freebsd.org> <201112021927.25234.jkim@FreeBSD.org> <201112022002.49618.jkim@FreeBSD.org> In-Reply-To: <201112022002.49618.jkim@FreeBSD.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY autolearn=unavailable version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on lauren.room52.net Cc: src-committers@FreeBSD.org, John Baldwin , svn-src-all@FreeBSD.org, Julien Ridoux , Ben Kaduk , Benjamin Kaduk , svn-src-head@FreeBSD.org Subject: Re: svn commit: r227778 - head/sys/net X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Dec 2011 12:31:19 -0000 On 12/03/11 12:02, Jung-uk Kim wrote: > On Friday 02 December 2011 07:27 pm, Jung-uk Kim wrote: >> On Thursday 01 December 2011 11:43 pm, Lawrence Stewart wrote: >>> On 12/02/11 03:43, Jung-uk Kim wrote: >>>> On Thursday 01 December 2011 10:11 am, Lawrence Stewart wrote: >>>>> On 11/30/11 05:09, Jung-uk Kim wrote: >>>>>> On Tuesday 29 November 2011 11:13 am, Lawrence Stewart wrote: [snip] >>>>>>> Here's the first of the patches: >>>>>>> >>>>>>> http://people.freebsd.org/~lstewart/patches/misc/ffclock_bpf >>>>>>> _i nt act abi_10.x.r228130.patch >>>>>> >>>>>> I only glanced at it but it looks very close to what I wanted >>>>>> to suggest. >>>>> >>>>> Final candidate patch is at: >>>>> >>>>> http://people.freebsd.org/~lstewart/patches/misc/ffclock_bpf_i >>>>> nt act abi_10.x.r228180.patch >>>>> >>>>> Assuming it passes the "make tinderbox" build I'm currently >>>>> running and no further input is received from interested >>>>> parties, I plan to commit it in ~10 hours. >>>>> >>>>> Changes since the r228130 patch I sent previously: >>>>> >>>>> - The new flags in bpf.h are added unconditionally so that >>>>> they can always be referenced at compile time and a decision >>>>> made at runtime as to whether a flag will be set or not. Using >>>>> one of the new flags when the kernel doesn't have FFCLOCK >>>>> compiled in results in the flag being ignored. An app should >>>>> check for the existence of the "ffclock" kernel feature or the >>>>> "kern.sysclock" sysctl tree before attempting to use the >>>>> flags. >>>>> >>>>> - This patch will hopefully be MFCed at some point, so I added >>>>> a CTASSERT to bpf.c to ensure that the ABI of structs >>>>> bpf_hdr32, bpf_hdr and bpf_xhdr remains intact when FFCLOCK is >>>>> enabled and the union of a ffcounter and struct >>>>> timeval32/timeval/bpf_ts is switched in. >>>>> >>>>> - bpf_gettime() more comprehensively covers all the possible >>>>> cases of flag combination and does sensible things for each >>>>> case (even though some cases are rather silly). >>>>> >>>>> - The snippet of code at the beginning of catchpacket() that >>>>> was manipulating the struct bintime derived from bpf_gettime() >>>>> was gross and has been removed in favour of selecting the >>>>> right {get}bin{up}time() function call in bpf_gettime(). >>>> >>>> I did that to reduce branching. Since you are introducing more >>>> branches, it warrants a function pointer now. >> >> There's another reason, BTW. If mbufs are tagged with timestamps >> (where only monotonic timestamps are allowed), they must be >> converted within the bpf.c. I forgot all the details. :-( We should document this knowledge in some code comments. >>> I see, thanks for the explanation. Could you elaborate a bit more >>> about how you would implement the function pointer idea? I'm also >>> curious in the !FFCLOCK case just how much overhead having the >>> 2-layer nested if/else adds. I'm not an very optimisation savvy >>> person, but I'm wondering if it's actually worth micro-optimising >>> this code. >>> >>> My initial thoughts about your function pointer idea lead to >>> adding a function pointer in the bpf_d and setting it to the >>> appropriate function to get the timestamp from at bpf_d creation >>> or ioctl time. Whilst I like this idea, I can't see how it would >>> work given that the various functions involved in time/ffcounter >>> stamp generation all have different signatures. >>> >>> We could have multiple variants of bpf_gettime() which each call >>> the appropriate underlying functions to generate the appropriate >>> stamp. Would add quite a lot of code but would reduce the >>> overhead of calling bpf_gettime() to an indirect function call + >>> the underlying stamp generation function call. This also solves >>> the problem of multiple function signatures. >> >> Please see my patch: >> >> http://people.freebsd.org/~jkim/bpf_ffclock.diff > > I booted up the kernel and found it just crashes because of stupid > typos. Now a new patch is uploaded in place. Sorry. > > Anyway, I see no regression nor ABI breakage. :-) struct bpf_d being part of the ABI was the main thing I was concerned about, so given that it isn't I like your approach a lot. As noted by Julien, this approach does introduce problems with respect to the follow up patch that adds a permanent bh_ffcounter member to the bpf header. I thought the fromclock() API would sufficiently meet the needs of consumers like BPF, but if we were to proceed with something like Jung-uk's proposed patch I don't think that's true anymore. We decided to bite the bullet and devise an API that is more compact and can return all appropriate time information from all underlying sysclocks in an efficient manner - something like a more generic version of ffclock_abstime(). Julien and I spent quite some time today nutting out details, and Julien has done a proof of concept patch against my proposed BPF patch which looks good as a starting point for discussion: http://www.cubinlab.ee.unimelb.edu.au/~jrid/patches/r228254/sysclock_snap.patch It needs a bit more work and should be split into two patches (one introducing the API and the other being the BPF changes). With something like this though, the BPF patch becomes radically simplified in the FFCLOCK case. We don't even need a function pointer cached in the bpf_d anymore, but could cache a struct sysclock_snap there instead if we really wanted to minimise overhead in bpf_gettime(). We'll have a go at refining the patch tomorrow hopefully, but wanted to put this out there for early consideration. Cheers, Lawrence