rpms/numactl/devel numactl-64bit-cpu-mask.patch, NONE, 1.1 numactl-64bit-overruns.patch, NONE, 1.1 numactl.spec, 1.27, 1.28

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Thu Apr 27 14:38:55 UTC 2006


Author: nhorman

Update of /cvs/dist/rpms/numactl/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv4770

Modified Files:
	numactl.spec 
Added Files:
	numactl-64bit-cpu-mask.patch numactl-64bit-overruns.patch 
Log Message:
adding new patches

numactl-64bit-cpu-mask.patch:
 libnuma.c |   73 +++++++++++++++++++++++++++++++++-----------------------------
 numaint.h |    2 -
 2 files changed, 41 insertions(+), 34 deletions(-)

--- NEW FILE numactl-64bit-cpu-mask.patch ---
--- numactl-0.6.4/libnuma.c.orig	2006-04-24 12:09:46.000000000 -0400
+++ numactl-0.6.4/libnuma.c	2006-04-24 12:15:28.000000000 -0400
@@ -439,6 +439,9 @@
 	int buflen_needed;
 	unsigned long *mask, prev;
 	int ncpus = number_of_cpus();
+	int i;
+	int mask_words;
+	int bits_in_mask_0;
 
 	buflen_needed = CPU_BYTES(ncpus);
 	if ((unsigned)node > maxnode || bufferlen < buflen_needed) { 
@@ -467,41 +470,45 @@
 		set_bit(node, (unsigned long *)mask);
 		goto out;
 	} 
-	n = 0;
-	s = line;
-	prev = 0; 
-	while (*s) {
- 		unsigned num; 
-		int i;
-		num = 0;
-		for (i = 0; s[i] && s[i] != ','; i++) { 
-			static const char hexdigits[] = "0123456789abcdef";
-			char *w = strchr(hexdigits, tolower(s[i]));
-			if (!w) { 
-				if (isspace(s[i]))
-					break;
-				numa_warn_int(W_cpumap, 
-					  "Unexpected character `%c' in sysfs cpumap", s[i]);
-				set_bit(node, mask);
-				goto out;
-			}
-			num = (num*16) + (w - hexdigits); 
-		}
-		if (i == 0) 
-			break; 
-		s += i;
-		if (*s == ',')
-			s++;
-		/* skip leading zeros */
-		if (num == 0 && prev == 0) 
-			continue;
-		prev |= num; 
-		memmove(mask + 1, mask, buflen_needed - sizeof(unsigned)); 
-		mask[0] = num; 
-	}
+	mask_words = 0;
+        bits_in_mask_0 = 0;
+        n = 0;
+        s = line;
+        prev = 0;
+	for (i = 0; s[i]; i++) {
+                static const char hexdigits[] = "0123456789abcdef";
+                char *w = strchr(hexdigits, tolower(s[i]));
+                if (!w) {
+                        if (isspace(s[i]) || s[i] == ',')
+                                continue;
+                        numa_warn_int(W_cpumap,
+                                  "Unexpected character `%c' in sysfs cpumap",
+                                        s[i]);
+                        set_bit(node, mask);
+                        goto out;
+                }
+
+                /* if mask[0] is full shift left before adding another */
+                if (bits_in_mask_0 >= sizeof(mask[0])*8) {
+                        /* skip any leading zeros */
+                        if (prev || mask[0]){
+			    /* shift over any previously loaded masks */
+                                memmove(mask+mask_words+1, mask+mask_words,
+                                        sizeof(mask[0]) * mask_words);
+                                mask_words++;
+                                bits_in_mask_0 = 0;
+                                mask[0] = 0;
+                                prev = 1;
+                        }
+                }
+
+                mask[0] = (mask[0]*16) + (w - hexdigits);
+                bits_in_mask_0 += 4; /* 4 bits per hex char */
+        }
  out:
 	free(line);
-	fclose(f);
+	if (f)
+                fclose(f);
 	memcpy(buffer, mask, buflen_needed);
 
 	/* slightly racy, see above */ 
--- numactl-0.6.4/numaint.h.orig	2006-04-24 12:08:57.000000000 -0400
+++ numactl-0.6.4/numaint.h	2006-04-24 12:09:14.000000000 -0400
@@ -22,7 +22,7 @@
 #define round_up(x,y) (((x) + (y) - 1) & ~((y)-1))
 
 
-#define CPU_BYTES(x) round_up(x, BITS_PER_LONG)
+#define CPU_BYTES(x) (round_up(x, BITS_PER_LONG)/8)
 #define CPU_WORDS(x) (CPU_BYTES(x) / sizeof(long))
 
 

numactl-64bit-overruns.patch:
 libnuma.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

--- NEW FILE numactl-64bit-overruns.patch ---
--- numactl-0.6.4/libnuma.c.orig	2006-01-10 10:10:38.000000000 -0500
+++ numactl-0.6.4/libnuma.c	2006-01-10 10:13:09.000000000 -0500
@@ -115,7 +115,7 @@
 
 static void dombind(void *mem, size_t size, int pol, nodemask_t *nodes)
 { 
-	if (mbind_int(mem, size, pol, nodes->n, nodes ? NUMA_NUM_NODES+1 : 0, mbind_flags) 
+	if (mbind_int(mem, size, pol, nodes ? nodes->n : NULL, nodes ? NUMA_NUM_NODES+1 : 0, mbind_flags) 
 	    < 0) 
 		numa_error_int("mbind"); 
 } 
@@ -437,7 +437,7 @@
 	char *s;
 	int n;
 	int buflen_needed;
-	unsigned *mask, prev;
+	unsigned long *mask, prev;
 	int ncpus = number_of_cpus();
 
 	buflen_needed = CPU_BYTES(ncpus);
@@ -455,7 +455,7 @@
 
 	mask = malloc(buflen_needed);
 	if (!mask) 
-		mask = (unsigned *)buffer; 
+		mask = (unsigned long *)buffer; 
 	memset(mask, 0, buflen_needed); 
 			
 	sprintf(fn, "/sys/devices/system/node/node%d/cpumap", node); 
@@ -506,7 +506,7 @@
 
 	/* slightly racy, see above */ 
 	if (node_cpu_mask[node]) {
-		if (mask != (unsigned *)buffer)
+		if (mask != (unsigned long *)buffer)
 			free(mask); 	       
 	} else {
 		node_cpu_mask[node] = (unsigned long *)mask; 
@@ -543,6 +543,7 @@
 nodemask_t numa_get_run_node_mask(void)
 { 
 	int ncpus = number_of_cpus();
+	int max_nodes = numa_max_node();
 	nodemask_t mask;
 	int i, k;
 	unsigned long cpus[CPU_WORDS(ncpus)], nodecpus[CPU_WORDS(ncpus)];
@@ -552,7 +553,7 @@
 	if (numa_sched_getaffinity_int(getpid(), CPU_BYTES(ncpus), cpus) < 0) 
 		return numa_no_nodes_int; 
 	/* somewhat dumb algorithm */
-	for (i = 0; i < NUMA_NUM_NODES; i++) {
+	for (i = 0; i < max_nodes; i++) {
 		if (numa_node_to_cpus_int(i, nodecpus, CPU_BYTES(ncpus)) < 0) {
 			numa_warn_int(W_noderunmask, "Cannot read node cpumask from sysfs");
 			continue;


Index: numactl.spec
===================================================================
RCS file: /cvs/dist/rpms/numactl/devel/numactl.spec,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- numactl.spec	10 Mar 2006 06:06:35 -0000	1.27
+++ numactl.spec	27 Apr 2006 14:38:52 -0000	1.28
@@ -13,6 +13,8 @@
 Patch1:	numactl-lib.patch
 Patch2: numactl-0.6.4-ppc.patch
 Patch3: numactl-0.6.4-commonalias.patch
+Patch4: numactl-64bit-overruns.patch
+Patch5: numactl-64bit-cpu-mask.patch
 
 %description
 Simple NUMA policy support. It consists of a numactl program to run
@@ -33,6 +35,12 @@
 # Fix breakage with aliases to tentatitive common symbols.
 %patch3
 
+# Fix 64 bit overruns
+%patch4
+
+# Fix cpu mask computation for > 7 nodes
+%patch5
+
 %build
 cd numactl-%{version}
 make CFLAGS="$RPM_OPT_FLAGS -I. -fPIC"
@@ -71,6 +79,9 @@
 %{_mandir}/man8/*.8*
 
 %changelog
+* Wed Apr 26 2006 Neil Horman <nhorman at redhat.com>
+- Added patches for 64 bit overflows and cpu mask problem
+
 * Fri Mar 10 2006 Bill Nottingham <notting at redhat.com>
 - rebuild for ppc TLS issue (#184446)
 




More information about the fedora-cvs-commits mailing list