Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Oct 2010 02:33:57 -0700
From:      Garrett Cooper <gcooper@FreeBSD.org>
To:        David Xu <davidxu@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:  <AANLkTi=2gJv5nkNHD0=BTm5h4CY4VeYfEPOXMex-yXPF@mail.gmail.com>
In-Reply-To: <201010270929.o9R9T4oI097923@svn.freebsd.org>
References:  <201010270929.o9R9T4oI097923@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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:
> =A0- Revert r214409.
> =A0- Use long word to figure out sizeof kernel cpuset, hope it works.
>
> Modified:
> =A0head/lib/libthr/thread/thr_attr.c
> =A0head/sys/kern/kern_cpuset.c
>
> Modified: head/lib/libthr/thread/thr_attr.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libthr/thread/thr_attr.c =A0 Wed Oct 27 07:14:46 2010 =A0 =
=A0 =A0 =A0(r214411)
> +++ head/lib/libthr/thread/thr_attr.c =A0 Wed Oct 27 09:29:03 2010 =A0 =
=A0 =A0 =A0(r214412)
> @@ -574,13 +574,14 @@ _get_kern_cpuset_size(void)
>
> =A0 =A0 =A0 =A0if (kern_cpuset_size =3D=3D 0) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0size_t len;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 int maxcpus;
>
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 len =3D sizeof(kern_cpuset_size);
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (sysctlbyname("kern.smp.maxcpus", &kern_=
cpuset_size,
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &len, NULL, 0))
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 len =3D sizeof(maxcpus);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (sysctlbyname("kern.smp.maxcpus", &maxcp=
us, &len, NULL, 0))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0PANIC("failed to get sysct=
l kern.smp.maxcpus");
> -
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 kern_cpuset_size =3D (kern_cpuset_size + 7)=
 / 8;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 int nbits_long =3D sizeof(long) * NBBY;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 int num_long =3D (maxcpus + nbits_long - 1)=
 / nbits_long;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 kern_cpuset_size =3D num_long * sizeof(long=
);
> =A0 =A0 =A0 =A0}
>
> =A0 =A0 =A0 =A0return (kern_cpuset_size);
>
> Modified: head/sys/kern/kern_cpuset.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/kern/kern_cpuset.c Wed Oct 27 07:14:46 2010 =A0 =A0 =A0 =A0(=
r214411)
> +++ head/sys/kern/kern_cpuset.c Wed Oct 27 09:29:03 2010 =A0 =A0 =A0 =A0(=
r214412)
> @@ -889,10 +889,6 @@ cpuset_getaffinity(struct thread *td, st
> =A0 =A0 =A0 =A0int error;
> =A0 =A0 =A0 =A0size_t size;
>
> - =A0 =A0 =A0 if (uap->cpusetsize =3D=3D 0) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 td->td_retval[0] =3D sizeof(cpuset_t);
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (0);
> - =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0if (uap->cpusetsize < sizeof(cpuset_t) ||
> =A0 =A0 =A0 =A0 =A0 =A0uap->cpusetsize > CPU_MAXSIZE / NBBY)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (ERANGE);

Are you sure this won't break 32-bit on 64-bit architectures, i.e.
amd64, mips, powerpc64, sparc64?
Thanks,
-Garrett



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTi=2gJv5nkNHD0=BTm5h4CY4VeYfEPOXMex-yXPF>