]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Rework Tile CPU affinity setting to handle non-contiguous sets of CPUs.
authorKen Steele <ken@tilera.com>
Fri, 20 Jun 2014 18:53:16 +0000 (14:53 -0400)
committerVictor Julien <victor@inliniac.net>
Mon, 23 Jun 2014 09:27:27 +0000 (11:27 +0200)
It is possible to have a non-contiguous CPU set, which was not being
handled correctly on the TILE architecture.

Added a "rank" field in the ThreadVar to store the worker's rank separately
from the cpu for this case.

src/runmode-tile.c
src/source-mpipe.c
src/threadvars.h

index 46e115da8cd8ee3507feeb9eb618ead71aaa001a..9e12fd9e851284afecdc87b3ed5bd04100471bea 100644 (file)
@@ -194,6 +194,16 @@ int RunModeTileMpipeWorkers(DetectEngineCtx *de_ctx)
         }
     }
 
+    /* Get affinity for worker */
+    cpu_set_t cpus;
+    //int result = tmc_cpus_get_my_affinity(&cpus);
+    int result = tmc_cpus_get_dataplane_cpus(&cpus);
+    if (result < 0) {
+        SCLogError(SC_ERR_INVALID_ARGUMENT,
+                   "tmc_cpus_get_my_affinity() returned=%d", result);
+        SCReturnInt(TM_ECODE_FAILED);
+    }
+
     for (pipe = 0; pipe < tile_num_pipelines; pipe++) {
         char *mpipe_devc;
 
@@ -231,8 +241,10 @@ int RunModeTileMpipeWorkers(DetectEngineCtx *de_ctx)
         }
         TmSlotSetFuncAppend(tv_worker, tm_module, (void *)mpipe_devc);
 
-        /* set affinity for worker */
-        int pipe_cpu = pipe + 1;
+       /* Bind to a single cpu. */
+       int pipe_cpu = tmc_cpus_find_nth_cpu(&cpus, pipe);
+       tv_worker->rank = pipe;
+
         TmThreadSetCPUAffinity(tv_worker, pipe_cpu);
 
         tm_module = TmModuleGetByName("DecodeMpipe");
index 0574f180071340d27f4d04013d9eef31b2b3ba91..675882efff423f14f15bcf2a418b411285a40726 100644 (file)
@@ -331,7 +331,7 @@ TmEcode ReceiveMpipeLoop(ThreadVars *tv, void *data, void *slot)
     ptv->slot = s->slot_next;
     Packet *p = NULL;
     int cpu = tmc_cpus_get_my_cpu();
-    int rank = cpu - 1;
+    int rank = tv->rank;
     int max_queued = 0;
     char *ctype;
 
@@ -875,8 +875,7 @@ static int MpipeReceiveOpenEgress(char *out_iface, int iface_idx,
 TmEcode ReceiveMpipeThreadInit(ThreadVars *tv, void *initdata, void **data)
 {
     SCEnter();
-    int cpu = tmc_cpus_get_my_cpu();
-    int rank = (cpu-1); // FIXME: Assumes worker CPUs start at 1.
+    int rank = tv->rank;
     int num_buckets = 4096; 
     int num_workers = tile_num_pipelines;
 
@@ -896,13 +895,6 @@ TmEcode ReceiveMpipeThreadInit(ThreadVars *tv, void *initdata, void **data)
     int result;
     char *link_name = (char *)initdata;
   
-    /* Bind to a single cpu. */
-    cpu_set_t cpus;
-    result = tmc_cpus_get_my_affinity(&cpus);
-    VERIFY(result, "tmc_cpus_get_my_affinity()");
-    result = tmc_cpus_set_my_cpu(tmc_cpus_find_first_cpu(&cpus));
-    VERIFY(result, "tmc_cpus_set_my_cpu()");
-
     MpipeRegisterPerfCounters(ptv, tv);
 
     *data = (void *)ptv;
index 6502072b90cd1c25617e923c8ea46314320a896d..0e04af2ca93cfc10daf294b2d5d47b2763c8363e 100644 (file)
@@ -93,6 +93,7 @@ typedef struct ThreadVars_ {
     uint8_t type;
 
     uint16_t cpu_affinity; /** cpu or core number to set affinity to */
+    uint16_t rank;
     int thread_priority; /** priority (real time) for this thread. Look at threads.h */
 
     /* the perf counter context and the perf counter array */