[Oisf-devel] [PATCH 07/10] Make runmode parse affinity settings.

Eric Leblond eleblond at edenwall.com
Sun Nov 21 13:30:50 UTC 2010


This patch modifies runmode to parse configuration file related
to affinity settings. It also prepare the export of the
set_cpu_affinity which was previously local. It is now used
in the affinity and tm-threads files.

Signed-off-by: Eric Leblond <eleblond at edenwall.com>
---
 src/runmodes.c |    7 ++++++-
 src/runmodes.h |    3 +++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/runmodes.c b/src/runmodes.c
index 6975fa4..612389a 100644
--- a/src/runmodes.c
+++ b/src/runmodes.c
@@ -33,6 +33,7 @@
 #include "util-affinity.h"
 #include "conf.h"
 #include "queue.h"
+#include "runmodes.h"
 
 #include "alert-fastlog.h"
 #include "alert-prelude.h"
@@ -149,7 +150,6 @@ static void SetupOutputs(ThreadVars *tv)
     }
 }
 
-static int threading_set_cpu_affinity = FALSE;
 static float threading_detect_ratio = 1;
 
 /**
@@ -157,9 +157,14 @@ static float threading_detect_ratio = 1;
  */
 static void RunModeInitialize(void)
 {
+    threading_set_cpu_affinity = FALSE;
     if ((ConfGetBool("threading.set_cpu_affinity", &threading_set_cpu_affinity)) == 0) {
         threading_set_cpu_affinity = FALSE;
     }
+    /* try to get custom cpu mask value if needed */
+    if (threading_set_cpu_affinity == TRUE) {
+	AffinitySetupLoadFromConfig();
+    }
     if ((ConfGetFloat("threading.detect_thread_ratio", &threading_detect_ratio)) != 1) {
         threading_detect_ratio = 1;
     }
diff --git a/src/runmodes.h b/src/runmodes.h
index 3582712..fa8aa71 100644
--- a/src/runmodes.h
+++ b/src/runmodes.h
@@ -53,5 +53,8 @@ int RunModeErfDagAuto(DetectEngineCtx *, char *);
 void RunModeShutDown(void);
 
 int RunModeFilePcapAutoFp(DetectEngineCtx *de_ctx, char *file);
+
+
+int threading_set_cpu_affinity;
 #endif /* __RUNMODES_H__ */
 
-- 
1.7.2.3




More information about the Oisf-devel mailing list