From e381af98dd2fd1699e6c88bdee4dea00367dbe96 Mon Sep 17 00:00:00 2001 From: Ken Steele Date: Fri, 21 Feb 2014 16:03:57 -0500 Subject: [PATCH] Only update mPipe stats occasionally around the packet loop. 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 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/source-mpipe.c b/src/source-mpipe.c index 3c696cf133..462b74e6dd 100644 --- a/src/source-mpipe.c +++ b/src/source-mpipe.c @@ -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); }