]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Support for Tile Gx atomic instructions
authorKen Steele <ken@tilera.com>
Tue, 10 Sep 2013 18:04:40 +0000 (14:04 -0400)
committerVictor Julien <victor@inliniac.net>
Mon, 16 Sep 2013 11:18:51 +0000 (13:18 +0200)
Tilera's GCC supports the GCC __sync_ intrinsics.

Increase the size of some atomic variables for better performance on
Tile.  The Tile-Gx architecture has native support for 32-bit and
64-bit atomic operations, but not 8-bit and 16-bit, which are emulated
using 32-bit atomics, so changing some 16-bit and 8-bit atomic into
ints improves performance.

Increasing the size of the atomic variables modified in this change
does not increase the total size of the structures in which they
reside because of existing padding requirements. The one case that
would increase the size of the structure (Flow_) was confitionalized
to only change the size on Tile.

src/defrag.h
src/flow-hash.c
src/flow-manager.c
src/flow.c
src/flow.h
src/host.h
src/threadvars.h
src/util-atomic.h

index b5ba29c7286353e190d49907506482b6d69d0e19..6d4b399275f6b02034dbf66452b8c797b47fca79 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -111,7 +111,7 @@ typedef struct DefragTracker_ {
     uint32_t timeout; /**< When this tracker will timeout. */
 
     /** use cnt, reference counter */
-    SC_ATOMIC_DECLARE(unsigned short, use_cnt);
+    SC_ATOMIC_DECLARE(unsigned int, use_cnt);
 
     TAILQ_HEAD(frag_tailq, Frag_) frags; /**< Head of list of fragments. */
 
index 1a80a30f0db01e024a70b45a140c8b3ab425b1c3..9b20b9c807a034e30cdc3447ae98494bd8310981 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2012 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -45,7 +45,7 @@
 #define FLOW_DEFAULT_FLOW_PRUNE 5
 
 SC_ATOMIC_EXTERN(unsigned int, flow_prune_idx);
-SC_ATOMIC_EXTERN(unsigned char, flow_flags);
+SC_ATOMIC_EXTERN(unsigned int, flow_flags);
 
 static Flow *FlowGetUsedFlow(void);
 
index 0f57430dd71b90db5571205e8541940984146810..c1906f685e8ba7386a4af9566ab80a7bd4df2c63 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2012 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -67,7 +67,7 @@
 /* Run mode selected at suricata.c */
 extern int run_mode;
 
-SC_ATOMIC_EXTERN(unsigned char, flow_flags);
+SC_ATOMIC_EXTERN(unsigned int, flow_flags);
 
 /* 1 seconds */
 #define FLOW_NORMAL_MODE_UPDATE_DELAY_SEC 1
index 2b24d3298fee1b254dfc05e48a62203cef9125c6..52c405115aa21a6d6a68b614a52bc8f05cf740d8 100644 (file)
@@ -80,7 +80,7 @@
 SC_ATOMIC_DECLARE(unsigned int, flow_prune_idx);
 
 /** atomic flags */
-SC_ATOMIC_DECLARE(unsigned char, flow_flags);
+SC_ATOMIC_DECLARE(unsigned int, flow_flags);
 
 void FlowRegisterTests(void);
 void FlowInitFlowProto();
index b94882cd7ae35e331ff272820d9d05a29f48651c..98080626d0f85ac5e7507925c149020ee8c51108 100644 (file)
@@ -247,6 +247,13 @@ typedef struct FlowAddress_ {
 #define addr_data16 address.address_un_data16
 #define addr_data8  address.address_un_data8
 
+#ifdef __tile__
+/* Atomic Ints performance better on Tile. */
+typedef unsigned int FlowRefCount;
+#else
+typedef unsigned short FlowRefCount;
+#endif
+
 /**
  *  \brief Flow data structure.
  *
@@ -290,7 +297,7 @@ typedef struct Flow_
      *  On receiving a packet the counter is incremented while the flow
      *  bucked is locked, which is also the case on timeout pruning.
      */
-    SC_ATOMIC_DECLARE(unsigned short, use_cnt);
+    SC_ATOMIC_DECLARE(FlowRefCount, use_cnt);
 
     /** flow queue id, used with autofp */
     SC_ATOMIC_DECLARE(int, autofp_tmqh_flow_qid);
index 9f8d0c5dd2f87f294849fe2c2ed351a7c458403c..2616b4b35b002f3bb232679828cf56318bcbaab0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2012 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -63,7 +63,7 @@ typedef struct Host_ {
     Address a;
 
     /** use cnt, reference counter */
-    SC_ATOMIC_DECLARE(unsigned short, use_cnt);
+    SC_ATOMIC_DECLARE(unsigned int, use_cnt);
 
     /** pointers to iprep storage */
     void *iprep;
index c589cc4c592dc6eba3d08e9f38e5c0eaed97c0b3..58581a0f7919aaf60e01609e6babadeff9828f09 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -60,7 +60,7 @@ typedef struct ThreadVars_ {
     char *name;
     char *thread_group_name;
 
-    SC_ATOMIC_DECLARE(unsigned short, flags);
+    SC_ATOMIC_DECLARE(unsigned int, flags);
 
     /** aof(action on failure) determines what should be done with the thread
         when it encounters certain conditions like failures */
index 650bf7deda2e9a06736adf0522e968973a065055..cbcfc86873568050445c4f53a425ed0d3b51797b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
 #define __UTIL_ATOMIC_H__
 
 /* test if we have atomic operations support */
-#if !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) || !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) || \
-    !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) || !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1)
+#if (!defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) || !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) || \
+     !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) || !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1)) && \
+  !defined(__tile__)
+
+/* Do not have atomic operations support, so implement them with locks. */
 
 /**
  *  \brief wrapper to declare an atomic variable including a (spin) lock