Re: RFC: Adding a hw.features[2] sysctl

From: Igor Mozolevsky <igor_at_hybrid-lab.co.uk>
Date: Mon, 14 Jan 2008 17:03:42 +0000
On 14/01/2008, Csaba Henk <csaba-ml_at_creo.hu> wrote:

> I don't pretend that I'm an expert of the topic discussed, I just don't
> see any essential difference (in terms of convenience or expressive
> power) between these:
>
> ################################################
> /* your code sample */
> cpu_features_t mask;
>
> fd = open( "/dev/cpuinfo", O_RDONLY );
> ioctl( fd, SIOCGCPUFEATURES, (caddr_t)&mask );
> close( fd );
> ################################################
>
> ################################################
> cpu_features_t mask;
> size_t len = sizeof(mask);
>
> sysctlbyname("hw.features", &mask, &len, NULL, 0);
> ################################################
>
> (and then the macro based processing of the mask
> can be done exactly the same way).
>
> > If it can be done reasonably in a MIB, I won't say a word, but
> > nobody's proposed any data representation for a (or a number of)
> > MIB(s) yet...

I didn't ask for user-land implementation detail, I was asking how
you'd represent all of this:

"
Features=0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
Features2=0x1<SSE3>
AMD Features=0xe2500800<SYSCALL,NX,MMX+,FFXSR,LM,3DNow!+,3DNow!>
AMD Features2=0x3<LAHF,CMP>
Cores per package: 2
"

using MIBs?..

Would you need
...features=0x178bfbff
...features2=0x1
...amd.features=0xe2500800
...amd.features20x3; or
...features="1=0x178bfbff 2=0x1 AMD1=0xe2500800 AMD2=0x3", both of
which would make life on the user-land side much more difficult than a
few ioctls that hide all the details away, IMO.

> > What's the overhead of sysctl vs ioctl?
>
> Well, looking at the above code examples, the ioctl based implementation
> costs three syscalls, the sysctl based one costs only two.

syscall overhead != system overhead!

I genuinely don't know (and don't have the time to work out) the
actual overhead of a sysctl vs ioctl, so if someone knows please let
me know :-)


Igor
Received on Mon Jan 14 2008 - 16:03:44 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:25 UTC