svn commit: r184759 - user/kmacy/HEAD_fast_multi_xmit/sys/net

Attilio Rao attilio at freebsd.org
Sat Nov 8 05:52:36 PST 2008


2008/11/8, Kip Macy <kmacy at 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


More information about the svn-src-user mailing list