Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Jul 2012 18:02:25 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        amd64@freebsd.org
Cc:        current@freebsd.org
Subject:   XSAVEOPT
Message-ID:  <20120708150225.GA2338@deviant.kiev.zoral.com.ua>

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

--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--



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