pkgsrc-WIP-changes archive

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

will-it-scale-git: Replace a local patch with a better one



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Sat Mar 17 21:59:40 2018 +0100
Changeset:	6b75e00c8df657a350d22e47f7bb0dd8ba408858

Modified Files:
	will-it-scale-git/distinfo
	will-it-scale-git/patches/patch-main.c

Log Message:
will-it-scale-git: Replace a local patch with a better one

Cherry-pick a patch by mjoras.

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

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

diffstat:
 will-it-scale-git/distinfo             |   2 +-
 will-it-scale-git/patches/patch-main.c | 185 ++++++++++++++++-----------------
 2 files changed, 88 insertions(+), 99 deletions(-)

diffs:
diff --git a/will-it-scale-git/distinfo b/will-it-scale-git/distinfo
index 97e515e50c..8c57f54ca8 100644
--- a/will-it-scale-git/distinfo
+++ b/will-it-scale-git/distinfo
@@ -1,7 +1,7 @@
 $NetBSD$
 
 SHA1 (patch-Makefile) = fdf09838fe367c554f108aa92aef76264b790512
-SHA1 (patch-main.c) = 9646ce29dca1269597d77c06c695fcbfecf34414
+SHA1 (patch-main.c) = 892b4fee8745289f1b4befedf527e5f3db8c575d
 SHA1 (patch-tests_eventfd1.c) = 290598658b7cbf564b0b34317f0f2c550b243fde
 SHA1 (patch-tests_fallocate1.c) = b6820c120ce5b8e1ddf7bbc925a17f567d5a9df5
 SHA1 (patch-tests_futex1.c) = a45ffd09e0300e5f6c2b70d95fb3a2454112e588
diff --git a/will-it-scale-git/patches/patch-main.c b/will-it-scale-git/patches/patch-main.c
index 022d2344f3..215e4ad6ab 100644
--- a/will-it-scale-git/patches/patch-main.c
+++ b/will-it-scale-git/patches/patch-main.c
@@ -1,150 +1,139 @@
 $NetBSD$
 
---- main.c.orig	2018-03-02 23:24:04.000000000 +0000
+--- main.c.orig	2018-03-17 15:30:11.000000000 +0000
 +++ main.c
-@@ -15,11 +15,31 @@
+@@ -15,7 +15,6 @@
  #include <string.h>
  #include <sys/mman.h>
  #include <hwloc.h>
-+#if __linux__
- #include <hwloc/glibc-sched.h>
-+#endif
+-#include <hwloc/glibc-sched.h>
  #include <sys/types.h>
  #include <signal.h>
  #include <poll.h>
+@@ -80,6 +79,8 @@ struct args
+ 	unsigned long long *arg1;
+ 	unsigned long arg2;
+ 	int poll_fd;
++	hwloc_topology_t topology;
++	hwloc_cpuset_t cpuset;
+ };
  
-+#ifdef __NetBSD__
-+#define cpu_set_t cpuset_t
-+#define sched_setaffinity sched_setaffinity_np
-+#define sched_getaffinity sched_getaffinity_np
-+static inline int
-+hwloc_cpuset_to_glibc_sched_affinity(hwloc_topology_t topology __unused, hwloc_const_cpuset_t hwlocset,
-+				    cpu_set_t *schedset, size_t schedsetsize)
-+{
-+  unsigned cpu;
-+  cpuset_zero(schedset);
-+  hwloc_bitmap_foreach_begin(cpu, hwlocset)
-+    cpuset_set(cpu, schedset);
-+  hwloc_bitmap_foreach_end();
-+
-+  return 0;
-+}
-+#endif
-+
- #define MAX_TASKS 1024
- #define CACHELINE_SIZE 128
- #define WARMUP_ITERATIONS 5
-@@ -103,11 +123,27 @@ void new_task(void *(func)(void *), void
+ static void *testcase_trampoline(void *p)
+@@ -103,17 +104,29 @@ void new_task(void *(func)(void *), void
  	pthread_create(&tid, NULL, func, arg);
  }
  
-+#ifdef __NetBSD__
-+struct nb_args {
+-void new_task_affinity(struct args *args,
+-		       size_t cpuset_size, cpu_set_t *mask)
++static void *thread_pre_trampoline(void *p)
++{
 +	struct args *args;
-+	cpuset_t *mask;
-+};
 +
-+void *
-+testcase_trampoline_nb(void *a)
-+{
-+	struct nb_args *A = (struct nb_args *)a;
-+	pthread_setaffinity_np(pthread_self(), cpuset_size(A->mask), A->mask);
-+	return testcase_trampoline(A->args);
++	args = (struct args *)p;
++	if (hwloc_set_thread_cpubind(args->topology, pthread_self(),
++	    args->cpuset, 0)) {
++		perror("hwloc_set_thread_cpubind");
++		exit(1);
++	}
++	hwloc_topology_destroy(args->topology);
++	hwloc_bitmap_free(args->cpuset);
++	return testcase_trampoline(args);
 +}
-+#endif
 +
- void new_task_affinity(struct args *args,
- 		       size_t cpuset_size, cpu_set_t *mask)
++void new_task_affinity(struct args *args)
  {
--	pthread_attr_t attr;
+ 	pthread_attr_t attr;
  	pthread_t tid;
-+#ifdef __linux__
-+	pthread_attr_t attr;
  
  	pthread_attr_init(&attr);
  
-@@ -116,6 +152,13 @@ void new_task_affinity(struct args *args
- 	pthread_create(&tid, &attr, testcase_trampoline, args);
+-	pthread_attr_setaffinity_np(&attr, cpuset_size, mask);
+-
+-	pthread_create(&tid, &attr, testcase_trampoline, args);
++	pthread_create(&tid, &attr, thread_pre_trampoline, args);
  
  	pthread_attr_destroy(&attr);
-+#else
-+	struct nb_args nba = {
-+		.args = args,
-+		.mask = mask
-+	};
-+	pthread_create(&tid, NULL, testcase_trampoline_nb, &nba);
-+#endif
+ }
+@@ -166,14 +179,27 @@ void new_task(void *(func)(void *), void
+ 	pids[nr_pids++] = pid;
  }
  
- /* All threads will die when we exit */
-@@ -169,10 +212,18 @@ void new_task(void *(func)(void *), void
- void new_task_affinity(struct args *args,
- 		       size_t cpuset_size, cpu_set_t *mask)
+-void new_task_affinity(struct args *args,
+-		       size_t cpuset_size, cpu_set_t *mask)
++void new_task_affinity(struct args *args)
  {
-+#ifdef __linux__
- 	cpu_set_t old_mask;
-+#elif defined(__NetBSD__)
-+	cpu_set_t *old_mask = cpuset_create();
-+#endif
+-	cpu_set_t old_mask;
++	hwloc_cpuset_t old_set;
  	int pid;
  
 -	sched_getaffinity(0, sizeof(old_mask), &old_mask);
-+	sched_getaffinity(0, sizeof(old_mask),
-+#ifdef __linux__
-+	&
-+#endif
-+	old_mask);
- 	sched_setaffinity(0, cpuset_size, mask);
+-	sched_setaffinity(0, cpuset_size, mask);
++
++	old_set = hwloc_bitmap_alloc();
++	if (old_set == NULL) {
++		perror("hwloc_bitmap_alloc");
++		exit(1);
++	}
++	if (hwloc_get_cpubind(args->topology, old_set,
++	    HWLOC_CPUBIND_PROCESS) < 0) {
++		perror("hwloc_get_cpubind");
++		exit(1);
++	}
++	if (hwloc_set_cpubind(args->topology, args->cpuset,
++	    HWLOC_CPUBIND_PROCESS) < 0) {
++		perror("hwloc_set_cpubind");
++		exit(1);
++	}
  
  	parent_pid = getpid();
-@@ -195,7 +246,15 @@ void new_task_affinity(struct args *args
+ 
+@@ -195,9 +221,17 @@ void new_task_affinity(struct args *args
  		testcase_trampoline(args);
  	}
  
 -	sched_setaffinity(0, sizeof(old_mask), &old_mask);
-+	sched_setaffinity(0, sizeof(old_mask),
-+#ifdef __linux__
-+	&
-+#endif
-+	old_mask);
-+
-+#ifdef __NetBSD__
-+	cpuset_destroy(old_mask);
-+#endif
++	if (hwloc_set_cpubind(args->topology, old_set,
++	    HWLOC_CPUBIND_PROCESS) < 0) {
++		perror("hwloc_set_cpubind");
++		exit(1);
++	}
  
  	pids[nr_pids++] = pid;
++	hwloc_topology_destroy(args->topology);
++	hwloc_bitmap_free(args->cpuset);
++	hwloc_bitmap_free(old_set);
++
  }
-@@ -273,7 +332,11 @@ int main(int argc, char *argv[])
+ 
+ 
+@@ -273,7 +307,6 @@ int main(int argc, char *argv[])
  			smt_affinity ? HWLOC_OBJ_PU : HWLOC_OBJ_CORE);
  	for (i = 0; i < opt_tasks; i++) {
  		hwloc_obj_t obj;
-+#if __linux__
- 		cpu_set_t mask;
-+#elif defined(__NetBSD__)
-+		cpuset_t *mask = cpuset_create();
-+#endif
+-		cpu_set_t mask;
  		struct args *args;
  
  		args = malloc(sizeof(struct args));
-@@ -290,8 +353,19 @@ int main(int argc, char *argv[])
+@@ -285,13 +318,18 @@ int main(int argc, char *argv[])
+ 		args->arg1 = results[i];
+ 		args->arg2 = i;
+ 		args->poll_fd = fd[0];
+-
+ 		obj = hwloc_get_obj_by_type(topology,
  				smt_affinity ? HWLOC_OBJ_PU : HWLOC_OBJ_CORE,
  				i % n);
- 		hwloc_cpuset_to_glibc_sched_affinity(topology,
+-		hwloc_cpuset_to_glibc_sched_affinity(topology,
 -				obj->cpuset, &mask, sizeof(mask));
 -		new_task_affinity(args, sizeof(mask), &mask);
-+				obj->cpuset,
-+#ifdef	__linux__
-+				&
-+#endif
-+				mask, sizeof(mask));
-+		new_task_affinity(args, sizeof(mask),
-+#ifdef __linux__
-+				&
-+#endif
-+				mask);
-+#ifdef __NetBSD__
-+		cpuset_destroy(mask);
-+#endif
++		if ((args->cpuset = hwloc_bitmap_dup(obj->cpuset)) == NULL) {
++			perror("hwloc_bitmap_dup");
++			exit(1);
++		}
++		if (hwloc_topology_dup(&args->topology, topology)) {
++			perror("hwloc_topology_dup");
++			exit(1);
++		}
++		new_task_affinity(args);
  	}
  
  	if (write(fd[1], &i, 1) != 1) {


Home | Main Index | Thread Index | Old Index