Project

General

Profile

Actions

Bug #852

closed

1.4.3: src/util-affinity.h: Solaris doesn't have cpu set_t

Added by Mark Solaris almost 11 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
Affected Versions:
Effort:
Difficulty:
Label:

Description

Patch is needed to compile on Solaris:

--- suricata-1.4.3/src/util-affinity.h.orig     Sat Jul  6 15:30:10 2013
+++ suricata-1.4.3/src/util-affinity.h  Sat Jul  6 15:30:49 2013
@@ -66,13 +66,13 @@

 typedef struct ThreadsAffinityType_ {
     char *name;
-#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__
+#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
     cpu_set_t cpu_set;
 #endif
     uint8_t mode_flag;
     int prio;
     int nb_threads;
-#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__
+#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
     cpu_set_t lowprio_cpu;
     cpu_set_t medprio_cpu;
     cpu_set_t hiprio_cpu;

Files

cpu_sets.diff (3.72 KB) cpu_sets.diff Mark Solaris, 07/09/2013 04:55 AM
Actions #1

Updated by Mark Solaris almost 11 years ago

Rolled cpu_set_t fixes into one file. It fixes:

src/util-affinity.h
src/util-affinity.c
tm-threads.c

Actions #2

Updated by Victor Julien almost 11 years ago

  • Target version deleted (1.4.3)
Actions #3

Updated by Victor Julien over 10 years ago

  • Target version set to TBD
Actions #4

Updated by Mark Solaris over 10 years ago

This is still a problem in the master tree dated 2013.12.02

Actions #5

Updated by Mark Solaris over 10 years ago

Some updates to add Solaris thread/cpu affinity. More work is needed on util-affinity.c which I'll tack on later.

--- ../../suricata-master.orig/src/threads.h    2013-12-01 21:37:52.000000000 +1100
+++ threads.h   2013-12-04 15:00:59.382631457 +1100
@@ -218,6 +218,13 @@
     u_long tid = (u_long)tmpthid; \
     tid; \
 })
+#elif OS_SOLARIS
+#define SCGetThreadIdLong(...) ({ \
+    pthread_t tpid; \
+    tpid = pthread_self(); \
+    u_long tid = (u_long)tpid; \
+    tid; \
+}) 
 #elif __OpenBSD__
 #define SCGetThreadIdLong(...) ({ \
     pid_t tpid; \
--- ../../suricata-master.orig/src/tm-threads.c 2013-12-01 21:37:52.000000000 +1100
+++ tm-threads.c        2013-12-04 15:12:31.613134151 +1100
@@ -70,6 +70,12 @@
 #define cpu_set_t cpuset_t
 #endif /* OS_FREEBSD */

+#if defined(OS_SOLARIS)
+#include <sys/types.h>
+#include <sys/processor.h>
+#include <sys/procset.h> 
+#endif /* SO_SOLARIS */
+
 /* prototypes */
 static int SetCPUAffinity(uint16_t cpu);

@@ -1143,7 +1149,7 @@
     return NULL;
 }

-#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__
+#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined(OS_SOLARIS)
 static int SetCPUAffinitySet(cpu_set_t *cs) {
 #if defined OS_FREEBSD
     int r = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID,
@@ -1195,6 +1201,15 @@

     return 0;

+#elif defined(OS_SOLARIS)
+    u_long my_thr_id = SCGetThreadIdLong();
+    int rc = processor_bind(P_MYID, my_thr_id, cpuid, 0);
+    if (rc != 0) {
+        printf("Warning: sched_setaffinity failed (%" PRId32 "): %s\n", rc, strerror(errno));
+        return -1;
+    }
+    SCLogDebug("CPU Affinity for thread %lu set to CPU %" PRId16, SCGetThreadIdLong(), cpuid); 
+    return 0;
 #else
     cpu_set_t cs;

@@ -1309,7 +1324,7 @@
         SetCPUAffinity(tv->cpu_affinity);
     }

-#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__
+#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined(OS_SOLARIS)
     if (tv->thread_setup_flags & THREAD_SET_PRIORITY)
         TmThreadSetPrio(tv);
     if (tv->thread_setup_flags & THREAD_SET_AFFTYPE) {
--- ../../suricata-master.orig/src/util-affinity.h      2013-12-01 21:37:52.000000000 +1100
+++ util-affinity.h     2013-12-03 11:54:43.138628057 +1100
@@ -66,13 +66,13 @@

 typedef struct ThreadsAffinityType_ {
     char *name;
-#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__
+#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
     cpu_set_t cpu_set;
 #endif
     uint8_t mode_flag;
     int prio;
     int nb_threads;
-#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__
+#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
     cpu_set_t lowprio_cpu;
     cpu_set_t medprio_cpu;
     cpu_set_t hiprio_cpu;
Actions #6

Updated by Andreas Herz over 8 years ago

  • Status changed from New to Closed
Actions #7

Updated by Victor Julien over 6 years ago

  • Target version deleted (TBD)
Actions

Also available in: Atom PDF