From owner-freebsd-amd64@FreeBSD.ORG Sun Jul 8 15:02:30 2012 Return-Path: Delivered-To: amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 59005106566C; Sun, 8 Jul 2012 15:02:30 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id B2E428FC0A; Sun, 8 Jul 2012 15:02:29 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q68F2cFH079795; Sun, 8 Jul 2012 18:02:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q68F2Qcq045687; Sun, 8 Jul 2012 18:02:26 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q68F2P0l045686; Sun, 8 Jul 2012 18:02:25 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 8 Jul 2012 18:02:25 +0300 From: Konstantin Belousov To: amd64@freebsd.org Message-ID: <20120708150225.GA2338@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Jsn5+Lu/ZvzbAGtZ" Content-Disposition: inline User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: current@freebsd.org Subject: XSAVEOPT X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 15:02:30 -0000 --Jsn5+Lu/ZvzbAGtZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Please find at http://people.freebsd.org/~kib/misc/xsaveopt.1.patch a patch to finally add suport for using XSAVEOPT for our amd64 context switch code. See Intel SDM for description of the XSAVEOPT instruction. Summary is that the instruction allows to not write parts of the FPU state which was not touched by the thread. Context switch then would write less to the PCB when thread is moved out from CPU. This is mainly to facilitate the ever-growing size of the FPU register file, in particular, AVX/YMM registers. Normal applications do not touch YMM, so saving them on each context switch if FPU was used is waste. Main complication is that any consumer of the ucontext_t still expect to see fully populated machine state, including the extended states which were not saved. Since CPU only avoids save when corresponding state is pristine, we can use the copy of initial state. CPUID provides an enumerator that allows OS to easily pick up neccesary area and copy over. I tried hard, but was unable to measure any statistically significant difference in the context switch times between XSAVE and XSAVEOPT using lmbench lat_ctx, on Core i7 2600K. --Jsn5+Lu/ZvzbAGtZ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk/5oQEACgkQC3+MBN1Mb4jQTQCggprKu1UUYowMeCiIXyzewViq VuAAn2UY0I/7AhGmFB+1x0OylSnd24VC =9G5R -----END PGP SIGNATURE----- --Jsn5+Lu/ZvzbAGtZ--