Date: Wed, 27 Oct 2010 17:44:04 +0000 From: David Xu <davidxu@freebsd.org> To: Garrett Cooper <gcooper@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r214412 - in head: lib/libthr/thread sys/kern Message-ID: <4CC864E4.5050606@freebsd.org> In-Reply-To: <AANLkTi=2gJv5nkNHD0=BTm5h4CY4VeYfEPOXMex-yXPF@mail.gmail.com> References: <201010270929.o9R9T4oI097923@svn.freebsd.org> <AANLkTi=2gJv5nkNHD0=BTm5h4CY4VeYfEPOXMex-yXPF@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Garrett Cooper wrote: > On Wed, Oct 27, 2010 at 2:29 AM, David Xu <davidxu@freebsd.org> wrote: >> 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); > > Are you sure this won't break 32-bit on 64-bit architectures, i.e. > amd64, mips, powerpc64, sparc64? > Thanks, > -Garrett > Unfortunately, I have not thought 32-bit on 64-bit kernel, we have a bunch of system calls, but still can not get a simple size.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4CC864E4.5050606>