]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Only update mPipe stats occasionally around the packet loop.
authorKen Steele <ken@tilera.com>
Fri, 21 Feb 2014 21:03:57 +0000 (16:03 -0500)
committerVictor Julien <victor@inliniac.net>
Wed, 26 Feb 2014 11:06:35 +0000 (12:06 +0100)
Check for termination or stats update only once every 10,000 times
around the mPipe packet processing loop, to reduce locking.

src/source-mpipe.c

index 3c696cf133a9d3272bfb187a7d17edfbdb178ab0..462b74e6dd0e86a53be3fd2fa206f28914e9806e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2013 Open Information Security Foundation
+/* Copyright (C) 2011-2014 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
@@ -349,12 +349,11 @@ TmEcode ReceiveMpipeLoop(ThreadVars *tv, void *data, void *slot)
     /* Open Ingress Queue for this worker thread. */
     MpipeReceiveOpenIqueue(rank);
     gxio_mpipe_iqueue_t* iqueue = thread_iqueue;
+    int update_counter = 0;
 
     for (;;) {
-        if (suricata_ctl_flags != 0) {
-            break;
-        }
 
+        /* Check to see how many packets are available to process. */
         gxio_mpipe_idesc_t *idesc;
         int n = gxio_mpipe_iqueue_try_peek(iqueue, &idesc);
         if (likely(n > 0)) {
@@ -396,7 +395,15 @@ TmEcode ReceiveMpipeLoop(ThreadVars *tv, void *data, void *slot)
             /* Move forward M packets in ingress ring. */
             gxio_mpipe_iqueue_advance(iqueue, m);
         }
-        SCPerfSyncCountersIfSignalled(tv);
+        if (update_counter-- <= 0) {
+            /* Only periodically update and check for termination. */
+            SCPerfSyncCountersIfSignalled(tv);
+            update_counter = 10000;
+
+            if (suricata_ctl_flags != 0) {
+              break;
+            }
+        }
     }
     SCReturnInt(TM_ECODE_OK);
 }