From owner-svn-src-all@FreeBSD.ORG Wed Oct 27 09:44:05 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 717081065672; Wed, 27 Oct 2010 09:44:05 +0000 (UTC) (envelope-from davidxu@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 44B6D8FC08; Wed, 27 Oct 2010 09:44:05 +0000 (UTC) Received: from xyf.my.dom (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o9R9i2HL063646; Wed, 27 Oct 2010 09:44:03 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4CC864E4.5050606@freebsd.org> Date: Wed, 27 Oct 2010 17:44:04 +0000 From: David Xu User-Agent: Thunderbird 2.0.0.24 (X11/20100630) MIME-Version: 1.0 To: Garrett Cooper References: <201010270929.o9R9T4oI097923@svn.freebsd.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Oct 2010 09:44:05 -0000 Garrett Cooper wrote: > On Wed, Oct 27, 2010 at 2:29 AM, David Xu 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.