Add CPUID subleaf capability to cpuctl/cpucontrol
Konstantin Belousov
kostikbel at gmail.com
Wed Mar 26 15:54:39 UTC 2014
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20140326/0573a216/attachment.sig>
More information about the freebsd-hackers
mailing list