svn commit: r214510 - in head: include lib/libc/gen sys/kern

Pawel Jakub Dawidek pjd at FreeBSD.org
Fri Oct 29 22:22:52 UTC 2010


On Fri, Oct 29, 2010 at 01:31:10PM +0000, David Xu wrote:
> Author: davidxu
> Date: Fri Oct 29 13:31:10 2010
> New Revision: 214510
> URL: http://svn.freebsd.org/changeset/base/214510
> 
> Log:
>   Add sysctl kern.sched.cpusetsize to export the size of kernel cpuset,
>   also add sysconf() key _SC_CPUSET_SIZE to get sysctl value.
>   
>   Submitted by: gcooper
[...]
> +#ifdef _SC_CPUSET_SIZE
> +	case _SC_CPUSET_SIZE:
> +		len = sizeof(lvalue);
> +		if (sysctlbyname("kern.sched.cpusetsize", &lvalue, &len, NULL,
> +		    0) == -1)
> +			return (-1);
> +		return (lvalue);
> +#endif
[...]
> +static size_t _kern_cpuset_size = sizeof(cpuset_t);
[...]
> +/* 
> + * Return the size of cpuset_t at the kernel level
> + *
> + * XXX (gcooper): replace ULONG with SIZE once CTLTYPE_SIZE is implemented.
> + */
> +SYSCTL_ULONG(_kern_sched, OID_AUTO, cpusetsize, CTLFLAG_RD,
> +    &_kern_cpuset_size, 0, "Kernel-level cpuset_t struct size");
> +

Because it is used via sysconf(3), I don't think it should be converted
to CTLTYPE_SIZE at all. I even think it would be safer to make
_kern_cpuset_size a long (sysconf's lvalue is long) and (just for
consistency) use SYSCTL_LONG().

Also note, that on i386 long is 32bit and on amd64 long is 64bit, so
32bit process running on 64bit system won't be able to read this sysctl.
Or do we detect 32bit processes on 64bit systems and convert such types
in the kernel?

-- 
Pawel Jakub Dawidek                       http://www.wheelsystems.com
pjd at FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20101029/31a150ea/attachment.pgp


More information about the svn-src-head mailing list