Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Mar 2014 12:45:59 +0800
From:      Jia-Shiun Li <jiashiun@gmail.com>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Add CPUID subleaf capability to cpuctl/cpucontrol
Message-ID:  <CAHNYxxNa_3cABhPMV5WxCot-%2BYn9jS6aJ8puWGWw-tRRDKMFYg@mail.gmail.com>
In-Reply-To: <20140326155429.GK21331@kib.kiev.ua>
References:  <CAHNYxxPZ%2BLpVGhgJXRhpMJkotXEY1Hyezye79XB_xHNazVgdng@mail.gmail.com> <20140326155429.GK21331@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Mar 26, 2014 at 11:54 PM, Konstantin Belousov
<kostikbel@gmail.com> wrote:
> On Wed, Mar 26, 2014 at 11:18:02PM +0800, Jia-Shiun Li wrote:
>> Hi all,
>>
>> I am recently writing a small tool playing msr with cpuctl(4).
>> Meanwhile I found that it is currently not passing value but 0 in ECX
>> register to CPUID instruction as input. So I have the attached patch
>> to do it.
>>
>> ECX is used to specify sub-leaf for some EAX leaf value. For example
>>   EAX=0x04: Deterministic Cache Parameters Leaf
>>   EAX=0x0b: Extended Topology Enumeration Leaf
>> with the attached patch user will be able to get subleaf info by
>> writing applications using cpuctl(4) ioctl or by using cpucontrol(8)
>> with -s flag.
>>
>> Please comment.
>>
>> Regards,
>> Jia-Shiun.
>
>> Index: sys/dev/cpuctl/cpuctl.c
>> ===================================================================
>> --- sys/dev/cpuctl/cpuctl.c   (revision 263420)
>> +++ sys/dev/cpuctl/cpuctl.c   (working copy)
>> @@ -204,7 +204,7 @@
>>       oldcpu = td->td_oncpu;
>>       is_bound = cpu_sched_is_bound(td);
>>       set_cpu(cpu, td);
>> -     cpuid_count(data->level, 0, data->data);
>> +     cpuid_count(data->level, data->sublevel, data->data);
>>       restore_cpu(oldcpu, is_bound, td);
>>       return (0);
>>  }
>> Index: sys/sys/cpuctl.h
>> ===================================================================
>> --- sys/sys/cpuctl.h  (revision 263420)
>> +++ sys/sys/cpuctl.h  (working copy)
>> @@ -36,6 +36,7 @@
>>
>>  typedef struct {
>>       int             level;  /* CPUID level */
>> +     int             sublevel; /* sublevel */
>>       uint32_t        data[4];
>>  } cpuctl_cpuid_args_t;
>
> This breaks the ABI.  If you want to extend the CPUCTL_CPUID,
> define new ioctl number for the extended structure, and keep the
> old arg structure and old number handled by the compat shims. Due
> to the construction of the CPUCTL_CPUID using _IOWR(), you in fact
> get the new number due to the structure size change.
>
> But IMO adding this functionality to a driver does not make much sense
> at all.  I remember that at time when initial version of cpuctl(4)
> was written, we did not have useful implementation of cpuset(2).
> Now, when it is possible to bind thread to a core from usermode,
> you do not need a driver providing interface to CPUID, since CPUID
> is usermode instruction.


thank you. I did not realize the ABI issue. I will try using affinity
to get CPUID
info in user space. It looks better with both regards.

Thanks,
Jia-shiun.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAHNYxxNa_3cABhPMV5WxCot-%2BYn9jS6aJ8puWGWw-tRRDKMFYg>