Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Oct 2010 09:29:04 +0000 (UTC)
From:      David Xu <davidxu@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r214412 - in head: lib/libthr/thread sys/kern
Message-ID:  <201010270929.o9R9T4oI097923@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: davidxu
Date: Wed Oct 27 09:29:03 2010
New Revision: 214412
URL: http://svn.freebsd.org/changeset/base/214412

Log:
  - Revert r214409.
  - Use long word to figure out sizeof kernel cpuset, hope it works.

Modified:
  head/lib/libthr/thread/thr_attr.c
  head/sys/kern/kern_cpuset.c

Modified: head/lib/libthr/thread/thr_attr.c
==============================================================================
--- head/lib/libthr/thread/thr_attr.c	Wed Oct 27 07:14:46 2010	(r214411)
+++ head/lib/libthr/thread/thr_attr.c	Wed Oct 27 09:29:03 2010	(r214412)
@@ -574,13 +574,14 @@ _get_kern_cpuset_size(void)
 
 	if (kern_cpuset_size == 0) {
 		size_t len;
+		int maxcpus;
 
-		len = sizeof(kern_cpuset_size);
-		if (sysctlbyname("kern.smp.maxcpus", &kern_cpuset_size,
-		    &len, NULL, 0))
+		len = sizeof(maxcpus);
+		if (sysctlbyname("kern.smp.maxcpus", &maxcpus, &len, NULL, 0))
 			PANIC("failed to get sysctl kern.smp.maxcpus");
-
-		kern_cpuset_size = (kern_cpuset_size + 7) / 8;
+		int nbits_long = sizeof(long) * NBBY;
+		int num_long = (maxcpus + nbits_long - 1) / nbits_long;
+		kern_cpuset_size = num_long * sizeof(long);
 	}
 
 	return (kern_cpuset_size);

Modified: head/sys/kern/kern_cpuset.c
==============================================================================
--- head/sys/kern/kern_cpuset.c	Wed Oct 27 07:14:46 2010	(r214411)
+++ head/sys/kern/kern_cpuset.c	Wed Oct 27 09:29:03 2010	(r214412)
@@ -889,10 +889,6 @@ cpuset_getaffinity(struct thread *td, st
 	int error;
 	size_t size;
 
-	if (uap->cpusetsize == 0) {
-		td->td_retval[0] = sizeof(cpuset_t);
-		return (0);
-	}
 	if (uap->cpusetsize < sizeof(cpuset_t) ||
 	    uap->cpusetsize > CPU_MAXSIZE / NBBY)
 		return (ERANGE);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010270929.o9R9T4oI097923>