pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

suricata: threads cpu affinity funcs compile



Module Name:	pkgsrc-wip
Committed By:	kami <kisskamizeg%gmail.com@localhost>
Pushed By:	kami
Date:		Sat Sep 20 21:48:59 2025 +0200
Changeset:	939905f732af1e07e9ad884443e24f6a55fb3204

Modified Files:
	suricata/distinfo
Added Files:
	suricata/patches/patch-src_tm-threads.c
	suricata/patches/patch-src_util-affinity.h

Log Message:
suricata: threads cpu affinity funcs compile

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=939905f732af1e07e9ad884443e24f6a55fb3204

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 suricata/distinfo                          |  2 ++
 suricata/patches/patch-src_tm-threads.c    | 56 ++++++++++++++++++++++++++++++
 suricata/patches/patch-src_util-affinity.h | 18 ++++++++++
 3 files changed, 76 insertions(+)

diffs:
diff --git a/suricata/distinfo b/suricata/distinfo
index 287868fe80..3e081668e0 100644
--- a/suricata/distinfo
+++ b/suricata/distinfo
@@ -5,4 +5,6 @@ SHA512 (suricata-8.0.1.tar.gz) = e87c2049b783c9d4c6b688b84e67330fb4600911a2ae222
 Size (suricata-8.0.1.tar.gz) = 44098838 bytes
 SHA1 (patch-configure) = 379edddcef392fecd2d1f3cb2a66b2223a0fca33
 SHA1 (patch-src_threads.h) = bd3764e1ac575d2b2c7b6b88ea2dbd93c3c5a4cb
+SHA1 (patch-src_tm-threads.c) = cf2e747c3c26f72844184baf8dbdbf1aa9407665
+SHA1 (patch-src_util-affinity.h) = a5ede16436ae6b1d28615726bf8afa4a94159694
 SHA1 (patch-src_util-byte.h) = 2f4dd27b60eccc55a684d513765346bdbd120552
diff --git a/suricata/patches/patch-src_tm-threads.c b/suricata/patches/patch-src_tm-threads.c
new file mode 100644
index 0000000000..fdac01aafa
--- /dev/null
+++ b/suricata/patches/patch-src_tm-threads.c
@@ -0,0 +1,56 @@
+$NetBSD$
+
+--- src/tm-threads.c.orig	2025-09-16 02:07:13.000000000 +0000
++++ src/tm-threads.c
+@@ -65,13 +65,15 @@ thread_local uint64_t rwr_lock_wait_tick
+ thread_local uint64_t rwr_lock_cnt;
+ #endif
+ 
+-#ifdef OS_FREEBSD
++#if defined OS_FREEBSD
+ #include <sched.h>
+ #include <sys/param.h>
+ #include <sys/resource.h>
+ #include <sys/cpuset.h>
+ #include <sys/thr.h>
+ #define cpu_set_t cpuset_t
++#elif defined __NetBSD__
++#include <err.h>
+ #endif /* OS_FREEBSD */
+ 
+ /* prototypes */
+@@ -705,6 +707,8 @@ static int SetCPUAffinitySet(cpu_set_t *
+ #if defined OS_FREEBSD
+     int r = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID,
+                                SCGetThreadIdLong(), sizeof(cpu_set_t),cs);
++#elif defined __NetBSD__
++    int r = pthread_setaffinity_np(SCGetThreadIdLong(), cpuset_size(*cs), *cs);
+ #elif OS_DARWIN
+     int r = thread_policy_set(mach_thread_self(), THREAD_AFFINITY_POLICY,
+                               (void*)cs, THREAD_AFFINITY_POLICY_COUNT);
+@@ -751,7 +755,25 @@ static int SetCPUAffinity(uint16_t cpuid
+                SCGetThreadIdLong(), cpu);
+ 
+     return 0;
++#elif defined __NetBSD__
++    cpuset_t *cset = cpuset_create();
++    if (cset == NULL) {
++      SCLogError("Error creating cpu set " "cpu %d", cpu);
++      //      warnc(EXIT_FAILURE, "cpuset_create");
++      return -1;
++    }
++    cpuset_set((cpuid_t)cpu, cset);
++
++    int r = SetCPUAffinitySet(&cset);
++    if (r) {
++      SCLogError("Error setting affinity for "
++		 "cpu %d: %s",
++		 cpu, strerror(r));
++      //      warnc(EXIT_FAILURE, "pthread_setaffinity_np failed: %d, %s", r, strerror(r));
++    }
++    cpuset_destroy(cset);
+ 
++    return r;
+ #else
+     cpu_set_t cs;
+     memset(&cs, 0, sizeof(cs));
diff --git a/suricata/patches/patch-src_util-affinity.h b/suricata/patches/patch-src_util-affinity.h
new file mode 100644
index 0000000000..f2ef1fef0f
--- /dev/null
+++ b/suricata/patches/patch-src_util-affinity.h
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/util-affinity.h.orig	2025-09-16 02:07:13.000000000 +0000
++++ src/util-affinity.h
+@@ -43,6 +43,13 @@
+ #include <sched.h>
+ #include <sys/param.h>
+ #include <sys/resource.h>
++#elif defined __NetBSD__
++#include <pthread.h>
++#include <sched.h>
++#define cpu_set_t cpuset_t *
++#define CPU_SET(cpu_id, cset) (cpuset_set(cpu_id, *cset))
++#define CPU_ISSET(cpu_id, cset) (cpuset_isset(cpu_id, *cset) > 0)
++#define CPU_ZERO(cset) (cpuset_zero(*cset))
+ #elif defined OS_DARWIN
+ #include <mach/mach.h>
+ #include <mach/mach_init.h>


Home | Main Index | Thread Index | Old Index