From owner-freebsd-current@FreeBSD.ORG Sat Sep 12 15:42:36 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FCAA106568B; Sat, 12 Sep 2009 15:42:36 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id 001718FC12; Sat, 12 Sep 2009 15:42:35 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id D9FDC730DA; Sat, 12 Sep 2009 17:48:36 +0200 (CEST) Date: Sat, 12 Sep 2009 17:48:36 +0200 From: Luigi Rizzo To: John Baldwin Message-ID: <20090912154836.GA47410@onelab2.iet.unipi.it> References: <4A93BF0C.8040601@web.de> <200909111123.00257.jhb@freebsd.org> <20090911170317.GA33232@onelab2.iet.unipi.it> <200909111301.55692.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200909111301.55692.jhb@freebsd.org> User-Agent: Mutt/1.4.2.3i Cc: Juergen Lock , Avi Kivity , qemu-devel@nongnu.org, freebsd-current@freebsd.org, Jan Kiszka , Mohammed Gamal Subject: Re: FreeBSD timing issues and qemu (was: Re: [Qemu-devel] Re: Breakage with local APIC routing) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Sep 2009 15:42:36 -0000 On Fri, Sep 11, 2009 at 01:01:54PM -0400, John Baldwin wrote: > On Friday 11 September 2009 1:03:17 pm Luigi Rizzo wrote: ... > > Note that the per-cpu ticks i was proposing were only visible to the > > timing wheels, which don't use absolute timeouts anyways. > > So i think the mechanism would be quite safe: right now, when you > > request a callout after x ticks, the code first picks a CPU > > (with some criteria), then puts the request in the timer wheel for > > that CPU using (now) the global 'ticks'. Replacing ticks with cc->cc_ticks, > > would completely remove the races in insertion and removal. > > > > I actually find the per-cpu ticks even less intrusive than this change. > > Well, it depends. If TCP ever started using per-CPU callouts (i.e. > callout_reset_on()) It seems that this is already the case in practice. callout_reset() is just #defined to callout_reset_on(c, ... c->cc_cpu) so all calls end up there. c->cc_cpu is initialized in callout_init as c->c_cpu = timeout_cpu; (which is a static int variable; i still don't understand what is the final value it gets, because the comment says that kern_timeout_callwheel_alloc() can be called multiple times and here is where timeout_cpu is initialized.) cheers luigi