From owner-freebsd-hackers@FreeBSD.ORG Thu Mar 27 12:39:05 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 50297188 for ; Thu, 27 Mar 2014 12:39:05 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E26CDB48 for ; Thu, 27 Mar 2014 12:39:04 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.8/8.14.8) with ESMTP id s2RCd0L0057482; Thu, 27 Mar 2014 14:39:00 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.3 kib.kiev.ua s2RCd0L0057482 Received: (from kostik@localhost) by tom.home (8.14.8/8.14.8/Submit) id s2RCcx9K057481; Thu, 27 Mar 2014 14:38:59 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 27 Mar 2014 14:38:59 +0200 From: Konstantin Belousov To: Jia-Shiun Li Subject: Re: Add CPUID subleaf capability to cpuctl/cpucontrol Message-ID: <20140327123859.GP21331@kib.kiev.ua> References: <20140326155429.GK21331@kib.kiev.ua> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="0WzQiIesntPPsVaS" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Mar 2014 12:39:05 -0000 --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 > 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--