By allocating each SCDQDataQueue individually avoid the risk
of false sharing when accessing them from several threads.

Also align the data_queues array to cache line boundary.

I used this following semantic patch to change the references
to data_queues:

  @@
  identifier n;
  expression q;
  @@
  -data_queues[q].n
  +data_queues[q]->n

  @@
  expression queue;
  @@
  -&data_queues[queue]
  +data_queues[queue]

Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>

Index: oisf/src/suricata.c
===================================================================
--- oisf.orig/src/suricata.c
+++ oisf/src/suricata.c
@@ -180,6 +180,8 @@ SC_ATOMIC_DECLARE(unsigned int, engine_s
 
 PacketQueue *trans_q[NUM_QUEUES] __ALIGNED(CLS);
 
+SCDQDataQueue *data_queues[NUM_QUEUES] __ALIGNED(CLS);
+
 /** suricata engine control flags */
 uint8_t suricata_ctl_flags = 0;
 
@@ -307,11 +309,9 @@ void CreateLowercaseTable()
 void GlobalInits()
 {
 	int q;
-
-    memset(data_queues, 0, sizeof(data_queues));
-
-    /* Initialize the trans_q mutex */
     int r = 0;
+
+    /* Initialize trans_q[] and data_queues[] */
     for (q = 0; q < NUM_QUEUES; q++) {
 		trans_q[q] = calloc(1, sizeof(PacketQueue));
 		if (trans_q[q] == NULL) {
@@ -319,11 +319,17 @@ void GlobalInits()
 			break;
 		}
 
+		data_queues[q] = calloc(1, sizeof(SCDQDataQueue));
+		if (data_queues[q] = NULL) {
+			r = ENOMEM;
+			break;
+		}
+
         r |= SCMutexInit(&trans_q[q]->mutex_q, NULL);
         r |= SCCondInit(&trans_q[q]->cond_q, NULL);
 
-        r |= SCMutexInit(&data_queues[q].mutex_q, NULL);
-        r |= SCCondInit(&data_queues[q].cond_q, NULL);
+        r |= SCMutexInit(&data_queues[q]->mutex_q, NULL);
+        r |= SCCondInit(&data_queues[q]->cond_q, NULL);
    }
 
     if (r != 0) {
Index: oisf/src/flow-timeout.c
===================================================================
--- oisf.orig/src/flow-timeout.c
+++ oisf/src/flow-timeout.c
@@ -684,12 +684,12 @@ void FlowForceReassembly(void)
                 if (tv->inq->q_type == 0)
                     SCCondSignal(&trans_q[tv->inq->id]->cond_q);
                 else
-                    SCCondSignal(&data_queues[tv->inq->id].cond_q);
+                    SCCondSignal(&data_queues[tv->inq->id]->cond_q);
                 while (!TmThreadsCheckFlag(tv, THV_PAUSED)) {
                     if (tv->inq->q_type == 0)
                         SCCondSignal(&trans_q[tv->inq->id]->cond_q);
                     else
-                        SCCondSignal(&data_queues[tv->inq->id].cond_q);
+                        SCCondSignal(&data_queues[tv->inq->id]->cond_q);
                     usleep(100);
                 }
                 TmThreadsUnsetFlag(tv, THV_PAUSE);
Index: oisf/src/tm-threads.c
===================================================================
--- oisf.orig/src/tm-threads.c
+++ oisf/src/tm-threads.c
@@ -1673,7 +1673,7 @@ void TmThreadKillThread(ThreadVars *tv)
                 if (tv->inq->q_type == 0)
                     SCCondSignal(&trans_q[tv->inq->id]->cond_q);
                 else
-                    SCCondSignal(&data_queues[tv->inq->id].cond_q);
+                    SCCondSignal(&data_queues[tv->inq->id]->cond_q);
             }
             SCLogDebug("signalled tv->inq->id %" PRIu32 "", tv->inq->id);
         }
@@ -1765,7 +1765,7 @@ void TmThreadDisableThreadsWithTMS(uint8
                     if (tv->inq->q_type == 0)
                         SCCondSignal(&trans_q[tv->inq->id]->cond_q);
                     else
-                        SCCondSignal(&data_queues[tv->inq->id].cond_q);
+                        SCCondSignal(&data_queues[tv->inq->id]->cond_q);
                 }
                 SCLogDebug("signalled tv->inq->id %" PRIu32 "", tv->inq->id);
             }
Index: oisf/src/suricata.h
===================================================================
--- oisf.orig/src/suricata.h
+++ oisf/src/suricata.h
@@ -131,7 +131,7 @@ enum {
  */
 extern PacketQueue *trans_q[NUM_QUEUES];
 
-SCDQDataQueue data_queues[NUM_QUEUES];
+extern SCDQDataQueue *data_queues[NUM_QUEUES];
 
 typedef struct SCInstance_ {
     int run_mode;


