From owner-svn-src-all@FreeBSD.ORG Wed Oct 27 03:19:22 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 ADA6A106564A; Wed, 27 Oct 2010 03:19:22 +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 7F0E58FC15; Wed, 27 Oct 2010 03:19:22 +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 o9R3JKqE027667; Wed, 27 Oct 2010 03:19:21 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4CC80ABA.3080404@freebsd.org> Date: Wed, 27 Oct 2010 11:19:22 +0000 From: David Xu User-Agent: Thunderbird 2.0.0.24 (X11/20100630) MIME-Version: 1.0 To: Garrett Cooper References: <201010270232.o9R2Wsu3084553@svn.freebsd.org> <4CC803A8.3040602@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: r214409 - head/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 03:19:22 -0000 Garrett Cooper wrote: > On Wed, Oct 27, 2010 at 3:49 AM, David Xu wrote: >> Garrett Cooper wrote: >>> On Tue, Oct 26, 2010 at 7:32 PM, David Xu wrote: >>>> Author: davidxu >>>> Date: Wed Oct 27 02:32:54 2010 >>>> New Revision: 214409 >>>> URL: http://svn.freebsd.org/changeset/base/214409 >>>> >>>> Log: >>>> If input parameter cpusetsize is zero, give userland size of cpuset mask >>>> kernel is using. >>>> >>>> Modified: >>>> head/sys/kern/kern_cpuset.c >>>> >>>> Modified: head/sys/kern/kern_cpuset.c >>>> >>>> ============================================================================== >>>> --- head/sys/kern/kern_cpuset.c Wed Oct 27 02:07:25 2010 (r214408) >>>> +++ head/sys/kern/kern_cpuset.c Wed Oct 27 02:32:54 2010 (r214409) >>>> @@ -889,6 +889,10 @@ 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); >>> Isn't this requirement partly broken now? >>> >>> [ERANGE] The cpusetsize was either preposterously large or >>> smaller than the kernel set size. >>> >>> Why should cpuset(2) be broken in favor of people not passing valid >>> values? >> I really hate to see such a problem that userland can not figure out >> what kernel is using, I try hardly to guess, but still can not find >> what it is using. yes, I think the doc may need to be fixed or >> another syscall is needed. > > Well... Jeff's code in cpuset(1) does some trivial sizeof(mask) > 's, but it just passes in cpuset_t for mask. I've seen different > calling conventions at the kernel level when I tried to get my brain > in sync with that for a bug I was looking at a few weeks ago (and > sadly, failed to some degree). > These syscalls are a bit confusing though, and apart from > cpuset(1) there aren't any really good examples in the sourcebase on > how to use them (at least not the last time I checked)... > Thanks, > -Garrett > The problem is that the size of cpuset is not fixed, it is tunable by the recompiling kernel with different parameter, so if you have a program which you want to adapt it to use any size of cpuset, it should be able to get the size the kernel is using, if you don't have source code of the program, you can not compile it with new parameter, then there is trouble.