Date: Sat, 8 Nov 2008 14:30:43 +0100 From: "Attilio Rao" <attilio@freebsd.org> To: "Kip Macy" <kmacy@freebsd.org> Cc: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: Re: svn commit: r184759 - user/kmacy/HEAD_fast_multi_xmit/sys/net Message-ID: <3bbf2fe10811080530t6846fce8mdf62f755c1864ea2@mail.gmail.com> In-Reply-To: <200811080202.mA822D0W098283@svn.freebsd.org> References: <200811080202.mA822D0W098283@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
2008/11/8, Kip Macy <kmacy@freebsd.org>: > 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3bbf2fe10811080530t6846fce8mdf62f755c1864ea2>