From owner-svn-src-user@FreeBSD.ORG Sat Nov 8 13:52:36 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E241D1065679 for ; Sat, 8 Nov 2008 13:52:35 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.155]) by mx1.freebsd.org (Postfix) with ESMTP id 691918FC17 for ; Sat, 8 Nov 2008 13:52:35 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: by fg-out-1718.google.com with SMTP id l26so1390185fgb.35 for ; Sat, 08 Nov 2008 05:52:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=ixvKzqT9BsrgwpQd88q0wBt+mnTL5ZCBjBV6MGdhtzI=; b=qJ4wIZ7js9tfB6qAjcy8PeQMvEuH9dl3eF7LW/hw+v3n2yhM8wbMuor/OANI9VhRZe hnrg15vK8FaGOc3R6GD21rdLoAiB2G6kCV1l8fclZEET5S/zOEfko+xL5zaLqVARs+ej 95fiU7/LT4G9iz/OPIrqU/CNAcyrT7S8IQRG8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=JswUiXnHMFPojF4lnrbkEbOCQ+C1F8J2PZCE+QvoJoljqZZs6W3wa0N2yOp7JboJjd D4xINCsErnSF9YS/htA7DSJvdaivcDMx4cBpw/RQ7GTfXF1jLmNJMdjxmdhnH4DmFTiS IO2mU4CM6IjS1E+fqjvHdji1aUAOekyEJNAKo= Received: by 10.86.80.17 with SMTP id d17mr5038212fgb.14.1226151043766; Sat, 08 Nov 2008 05:30:43 -0800 (PST) Received: by 10.86.2.18 with HTTP; Sat, 8 Nov 2008 05:30:43 -0800 (PST) Message-ID: <3bbf2fe10811080530t6846fce8mdf62f755c1864ea2@mail.gmail.com> Date: Sat, 8 Nov 2008 14:30:43 +0100 From: "Attilio Rao" Sender: asmrookie@gmail.com To: "Kip Macy" In-Reply-To: <200811080202.mA822D0W098283@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200811080202.mA822D0W098283@svn.freebsd.org> X-Google-Sender-Auth: d29564649245db35 Cc: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: Re: svn commit: r184759 - user/kmacy/HEAD_fast_multi_xmit/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Nov 2008 13:52:36 -0000 2008/11/8, Kip Macy : > Author: kmacy > Date: Sat Nov 8 02:02:13 2008 > New Revision: 184759 > URL: http://svn.freebsd.org/changeset/base/184759 > > Log: > add memory barrier before critical_exit to ensure that all buffered updates are > committed to main memory before a preemption is permitted > > Modified: > user/kmacy/HEAD_fast_multi_xmit/sys/net/flowtable.c > > Modified: user/kmacy/HEAD_fast_multi_xmit/sys/net/flowtable.c > ============================================================================== > --- user/kmacy/HEAD_fast_multi_xmit/sys/net/flowtable.c Fri Nov 7 23:50:57 2008 (r184758) > +++ user/kmacy/HEAD_fast_multi_xmit/sys/net/flowtable.c Sat Nov 8 02:02:13 2008 (r184759) > @@ -35,6 +35,21 @@ > #define calloc(count, size) malloc((count)*(size), M_DEVBUF, M_WAITOK|M_ZERO) > > > + > +#if defined (__GNUC__) > + #if #cpu(i386) || defined __i386 || defined i386 || defined __i386__ || #cpu(x86_64) || defined __x86_64__ > + #define mb() __asm__ __volatile__ ("sfence;": : :"memory") > + #elif #cpu(sparc64) || defined sparc64 || defined __sparcv9 > + #define mb() __asm__ __volatile__ ("membar #MemIssue": : :"memory") > + #elif #cpu(sparc) || defined sparc || defined __sparc__ > + #define mb() __asm__ __volatile__ ("stbar;": : :"memory") > + #else > + #define mb() /* XXX just to make this compile */ > + #endif > +#else > + #error "unknown compiler" > +#endif > + > /* > * Taken from http://burtleburtle.net/bob/c/lookup3.c > */ > @@ -317,6 +332,7 @@ static void > flowtable_pcpu_unlock(struct flowtable *table, uint32_t hash) > { > > + mb(); > critical_exit(); > } Definitively, I'm not sure we need this. We alredy have memory barriers you could exploit which just require a "dummy" object. For example you could do: flowtable_pcpu_unlock(struct flowtable *table, uint32_t hash) { (void)atomic_load_acq_ptr(&dummy); ... -- Peace can only be achieved by understanding - A. Einstein