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);
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to