Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Mar 2014 14:38:59 +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:  <20140327123859.GP21331@kib.kiev.ua>
In-Reply-To: <CAHNYxxNa_3cABhPMV5WxCot-%2BYn9jS6aJ8puWGWw-tRRDKMFYg@mail.gmail.com>
References:  <CAHNYxxPZ%2BLpVGhgJXRhpMJkotXEY1Hyezye79XB_xHNazVgdng@mail.gmail.com> <20140326155429.GK21331@kib.kiev.ua> <CAHNYxxNa_3cABhPMV5WxCot-%2BYn9jS6aJ8puWGWw-tRRDKMFYg@mail.gmail.com>

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

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

On Thu, Mar 27, 2014 at 12:45:59PM +0800, Jia-Shiun Li wrote:
> 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=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.
> >>
> >> Please comment.
> >>
> >> 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 @@
> >>
> >>  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.
>=20
>=20
> 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.

=46rom what I remember, in the multi-socket configuration Intel allows
CPUs to only differ by stepping. Due to this, I see only one possible
uses of executing CPUID on specific core, to get the stepping of the
package, to either test for the presence of the specific CPU bug, or to
select the proper microcode update.

That said, I am curious why do you want this feature.

--0WzQiIesntPPsVaS
Content-Type: application/pgp-signature

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

iQIcBAEBAgAGBQJTNBvjAAoJEJDCuSvBvK1BQSsP/iFjQEPrzRf/37cSr/GbtIIx
At6wxK+OzyAkZ7NPeCI74SZb4fbFATDeef/n4RtOeYvgeWK9PEMTytIxgL/AReQ9
xNlnyUjtrJ0cyi8ALxGC3A5wa0gvmmTBHF7P0tm1mez0kIoI7912nd5agsk84u+j
F/zqr4a4ytdrVb3nHUMrhGeLXas9xSCLVrSiZDb5vpSUTn748FzLrA839s/8a9Tt
iondfcsLhQSSUaczHkZFkIy/Lf8GmqDI4qbsZ42Y5+pp7dOl1PU1s9+kOpmZvjge
2YbwLEmQS3Z9mSBdVwl6Zp8bzg6XU/4noGOBte5nxqfMagXnFkZ9lUSo77h4m6O1
rd3TI8S6v/4inUrfh2Wye+Emgy57gb/nTpFvQCbnvLwg7Qj3rn+dcAlu6Rb/WUrf
eDZrACh8s08s5YTdveXGdVyHALivN5AZbscWvu42L2RwcZFcFiwX6/BXIryi5HXd
u5ZGFAa1UVNkxDF0m6eJIoEUvxDcl0ZU6GtbBHuKgO3l2wdSX3Fx77VWlY4s/kay
m9LNJq9PL5S4cGCMn78YRuexTdkjqoJjZOjmBR0igGNUhSDBTBD3MLpJMDifZ+Mn
Eb8+Mvv5baZ0weM/YpqiGb7J7OfQPb99nQY7ajVpyAFPu394PmFRQfj7yJ+YbG7C
RrQ3BQTi0b+g5CFgfLoe
=s7S8
-----END PGP SIGNATURE-----

--0WzQiIesntPPsVaS--



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