File Cleanup-move-has_preferred_many-to-numa_init-again.patch of Package numactl

From: Thomas Renninger <trenn@suse.de>
Subject: Cleanup: move has_preferred_many to numa_init again
References: 
Patch-Mainline: 
Git-commit: 391e4e254fc50f625114ceb8c1fecb178e395c47


Reverts: fd4ec69686ec

Above commit delays the check whether the system supports
has_preferred_many.
This makes initialization unnecessary complex and error prone.

The real fix of fd4ec69686ec (use {get,set}_mempolicy instead
of {get,set}pol)
is still included:
-               setpol(oldp, bmp);
+               (void)set_mempolicy(oldp, bmp->maskp, bmp->size+1);

Signed-off-by: Thomas Renninger <trenn@suse.com>


Signed-off-by:  <trenn@suse.de>
diff --git a/libnuma.c b/libnuma.c
index 380e8a6..29349ee 100644
--- a/libnuma.c
+++ b/libnuma.c
@@ -80,7 +80,7 @@ static int numproccpu = -1;
 static int nodemask_sz = 0;
 static int cpumask_sz = 0;
 
-static int has_preferred_many = -1;
+static int has_preferred_many = 0;
 
 int numa_exit_on_error = 0;
 int numa_exit_on_warn = 0;
@@ -623,19 +623,14 @@ set_configured_cpus(void)
 }
 
 static void
-set_preferred_many(void)
+set_kernel_abi(void)
 {
 	int oldp;
 	struct bitmask *bmp, *tmp;
 	int old_errno;
 
-	if (has_preferred_many >= 0)
-		return;
-
 	old_errno = errno;
 
-	has_preferred_many = 0;
-
 	bmp = numa_allocate_nodemask();
 	tmp = numa_get_mems_allowed();
 	if (!tmp || !bmp)
@@ -668,6 +663,7 @@ set_sizes(void)
 	set_numa_max_cpu();	/* size of kernel cpumask_t */
 	set_configured_cpus();	/* cpus listed in /sys/devices/system/cpu */
 	set_task_constraints(); /* cpus and nodes for current task */
+	set_kernel_abi();	/* man policy supported */
 }
 
 int
@@ -1164,7 +1160,6 @@ void *numa_alloc_local(size_t size)
 
 void numa_set_bind_policy(int strict)
 {
-	set_preferred_many();
 	if (strict)
 		bind_policy = MPOL_BIND;
 	else if (has_preferred_many)
@@ -1992,7 +1987,6 @@ void numa_set_preferred(int node)
 
 int numa_has_preferred_many(void)
 {
-	set_preferred_many();
 	return has_preferred_many;
 }
 
@@ -2000,7 +1994,6 @@ void numa_set_preferred_many(struct bitmask *bitmask)
 {
 	int first_node = 0;
 
-	set_preferred_many();
 	if (!has_preferred_many) {
 		numa_warn(W_nodeparse,
 			"Unable to handle MANY preferred nodes. Falling back to first node\n");
openSUSE Build Service is sponsored by