Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Oct 2010 09:07:37 -0700
From:      Garrett Cooper <gcooper@freebsd.org>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Pawel Jakub Dawidek <pjd@freebsd.org>, David Xu <davidxu@freebsd.org>
Subject:   Re: svn commit: r214409 - head/sys/kern
Message-ID:  <AANLkTinzP%2Btj3y%2B-r4-%2BgHgCzg6BJ-ZpWru365zysSEF@mail.gmail.com>
In-Reply-To: <20101027133307.GQ2392@deviant.kiev.zoral.com.ua>
References:  <201010270232.o9R2Wsu3084553@svn.freebsd.org> <AANLkTi=2dTVmB8Goj%2BNXq4F6SmZBNS3bxn8gLjmQ%2BdfV@mail.gmail.com> <4CC803A8.3040602@freebsd.org> <20101027082122.GD1848@garage.freebsd.pl> <4CC85552.2020100@freebsd.org> <20101027133307.GQ2392@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
--0016364d1f159cc03b04939b6ccb
Content-Type: text/plain; charset=ISO-8859-1

On Wed, Oct 27, 2010 at 6:33 AM, Kostik Belousov <kostikbel@gmail.com> wrote:
> On Wed, Oct 27, 2010 at 04:37:38PM +0000, David Xu wrote:
>> Pawel Jakub Dawidek wrote:
>> >On Wed, Oct 27, 2010 at 10:49:12AM +0000, David Xu wrote:
>> >>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.
>> >
>> >Maybe you could just add sysctl and eventually put it into sysconf(3)?
>> >
>>
>> I just found a dirty method, use sizeof(long) and kern.smp.maxcpus
>> 32 to figure out the size the kernel is using, because it is how
>> cpuset_t is constructed, wish it will never be changed. ;-)
>>
> I think that sysctl is the way forward, but you may add non-portable
> FreeBSD function to get the value, and use an ELF aux vector interface
> to avoid sysctl most of the time.

    How about this patch? I implemented this as a readonly tunable and
sysconf tunable, because (AFAIK) the value that is being tested
shouldn't change during runtime after the system has been booted up,
and figuring that the value wasn't going to change it was better to
lose 4/8 bytes on the kernel stack instead of having to recompute the
value every time in a function call, with the associated lost heap /
stack memory in the process, as the assumption is that this libcall
was going to be called frequently by some programs.
Thanks!
-Garrett

--0016364d1f159cc03b04939b6ccb
Content-Type: text/x-patch; charset=US-ASCII; 
	name="cpuset_t-size-sysctl-and-sysconf-value.patch"
Content-Disposition: attachment; 
	filename="cpuset_t-size-sysctl-and-sysconf-value.patch"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_gfseer440

SW5kZXg6IGluY2x1ZGUvdW5pc3RkLmgKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gaW5jbHVkZS91bmlzdGQuaAko
cmV2aXNpb24gMjE0NDEzKQorKysgaW5jbHVkZS91bmlzdGQuaAkod29ya2luZyBjb3B5KQpAQCAt
Mjg4LDYgKzI4OCw3IEBACiAjaWYgX19CU0RfVklTSUJMRQogI2RlZmluZQlfU0NfTlBST0NFU1NP
UlNfQ09ORgk1NwogI2RlZmluZQlfU0NfTlBST0NFU1NPUlNfT05MTgk1OAorI2RlZmluZQlfU0Nf
Q1BVU0VUX1NJWkUJCTEyMgogI2VuZGlmCiAKIC8qIEV4dGVuc2lvbnMgZm91bmQgaW4gU29sYXJp
cyBhbmQgTGludXguICovCkluZGV4OiBsaWIvbGliYy9nZW4vc3lzY29uZi5jCj09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0K
LS0tIGxpYi9saWJjL2dlbi9zeXNjb25mLmMJKHJldmlzaW9uIDIxNDQxMykKKysrIGxpYi9saWJj
L2dlbi9zeXNjb25mLmMJKHdvcmtpbmcgY29weSkKQEAgLTU5Nyw2ICs1OTcsMTUgQEAKIAkJcmV0
dXJuIChsdmFsdWUpOwogI2VuZGlmCiAKKyNp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1BVIHRvcG9sb2d5Iik7CisKKy8qIAorICog
UmV0dXJuIHRoZSBzaXplIG9mIGNwdXNldF90IGF0IHRoZSBrZXJuZWwgbGV2ZWwKKyAqCisgKiBY
WFggKGdjb29wZXIpOiByZXBsYWNlIFVMT05HIHdpdGggU0laRSBvbmNlIENUTFRZUEVfU0laRSBp
cyBpbXBsZW1lbnRlZC4KKyAqLworU1lTQ1RMX1VMT05HKF9rZXJuX3NjaGVkLCBPSURfQVVUTywg
Y3B1c2V0c2l6ZSwgQ1RMRkxBR19SRFRVTiwKKyAgICAmX2tlcm5fY3B1c2V0X3NpemUsIDAsICJL
ZXJuZWwtbGV2ZWwgY3B1c2V0X3Qgc3RydWN0IHNpemUiKTsKKwogI2VuZGlmCiAKIC8qIHBzIGNv
bXBhdC4gIEFsbCBjcHUgcGVyY2VudGFnZXMgZnJvbSBVTEUgYXJlIHdlaWdodGVkLiAqLwo=
--0016364d1f159cc03b04939b6ccb--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTinzP%2Btj3y%2B-r4-%2BgHgCzg6BJ-ZpWru365zysSEF>