Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Mar 2014 17:54:29 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Jia-Shiun Li <jiashiun@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Add CPUID subleaf capability to cpuctl/cpucontrol
Message-ID:  <20140326155429.GK21331@kib.kiev.ua>
In-Reply-To: <CAHNYxxPZ%2BLpVGhgJXRhpMJkotXEY1Hyezye79XB_xHNazVgdng@mail.gmail.com>
References:  <CAHNYxxPZ%2BLpVGhgJXRhpMJkotXEY1Hyezye79XB_xHNazVgdng@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--Tw5XVHq4jmAOFG53
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Mar 26, 2014 at 11:18:02PM +0800, Jia-Shiun Li wrote:
> Hi all,
>=20
> 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.
>=20
> ECX is used to specify sub-leaf for some EAX leaf value. For example
>   EAX=3D0x04: Deterministic Cache Parameters Leaf
>   EAX=3D0x0b: 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.
>=20
> Please comment.
>=20
> Regards,
> Jia-Shiun.

> Index: sys/dev/cpuctl/cpuctl.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- sys/dev/cpuctl/cpuctl.c	(revision 263420)
> +++ sys/dev/cpuctl/cpuctl.c	(working copy)
> @@ -204,7 +204,7 @@
>  	oldcpu =3D td->td_oncpu;
>  	is_bound =3D 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
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- sys/sys/cpuctl.h	(revision 263420)
> +++ sys/sys/cpuctl.h	(working copy)
> @@ -36,6 +36,7 @@
> =20
>  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.

--Tw5XVHq4jmAOFG53
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (FreeBSD)

iQIcBAEBAgAGBQJTMvg0AAoJEJDCuSvBvK1BcZgQAJixSRY0/ifHDdsvBF5qVl/Y
i6CQITdSsiExUvORMO3NVerpfQIAlJ0yTwBRLP+ASN3uaP6AYR7S6ry8duMikP8/
AYSxffv52S6fxomb4zWxqmnn9o688wfMC0tIHPQXu4406YxLOg5ocYB56tRL+r4o
A7+O3rKAGbHAsaMpTbhXnaUUf8RMMVFjPWpIdOvdB96VQ8oHvXe6fVpJOj7cSAye
pYOehMlUxHK34Z+20U6GVJ7i6e4ons2wfLDH6iaY5RxgezqilfEWmjUlKxy8Leoe
IQ3aty/qwRlVajC9a2nn/rU0pH/0T9aENULDxvxSwBih1m2zC7wTno2XH2xiH3r0
wnotmEVcp1A9xvpxKOFE6xVSeaTJNV11sNnoMApV7qF7WP7ph9ITvkO0GfMwajkP
umHa2L9KVHkblBD39gpwBfTMHOUs3sKx5wJSlPiz3dev/9V/Xv/RSOgmrg1G+wvw
w7u3DGyu5a17rdYd2I4DDpBaZYFDPH8c/YPP8MKKQDR3yOkkNF1TQ76jPUZTOZzQ
FwjItqRunIVgWHDG5zLGuzNX4BVHGDjJ8rENvhzv1FJOnePkHrTqJsUr9na7ixHI
9AmG6uNvO9k9mW8mUgMFo3LNi4Y+5cw7ZydPtei0v8jHXc6J9vaYBqa9rYFKibhZ
S9PkWVIEHRRTBDsUfcG3
=NS/n
-----END PGP SIGNATURE-----

--Tw5XVHq4jmAOFG53--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140326155429.GK21331>