https://github.com/torvalds/linux
Revision 7e16838d94b566a17b65231073d179bc04d590c8 authored by Linus Torvalds on 19 February 2012, 21:27:00 UTC, committed by Linus Torvalds on 20 February 2012, 18:58:54 UTC
This makes us recognize when we try to restore FPU state that matches
what we already have in the FPU on this CPU, and avoids the restore
entirely if so.

To do this, we add two new data fields:

 - a percpu 'fpu_owner_task' variable that gets written any time we
   update the "has_fpu" field, and thus acts as a kind of back-pointer
   to the task that owns the CPU.  The exception is when we save the FPU
   state as part of a context switch - if the save can keep the FPU
   state around, we leave the 'fpu_owner_task' variable pointing at the
   task whose FP state still remains on the CPU.

 - a per-thread 'last_cpu' field, that indicates which CPU that thread
   used its FPU on last.  We update this on every context switch
   (writing an invalid CPU number if the last context switch didn't
   leave the FPU in a lazily usable state), so we know that *that*
   thread has done nothing else with the FPU since.

These two fields together can be used when next switching back to the
task to see if the CPU still matches: if 'fpu_owner_task' matches the
task we are switching to, we know that no other task (or kernel FPU
usage) touched the FPU on this CPU in the meantime, and if the current
CPU number matches the 'last_cpu' field, we know that this thread did no
other FP work on any other CPU, so the FPU state on the CPU must match
what was saved on last context switch.

In that case, we can avoid the 'f[x]rstor' entirely, and just clear the
CR0.TS bit.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 80ab6f1
History
Tip revision: 7e16838d94b566a17b65231073d179bc04d590c8 authored by Linus Torvalds on 19 February 2012, 21:27:00 UTC
i387: support lazy restore of FPU state
Tip revision: 7e16838
File Mode Size
9p
bluetooth
caif
irda
iucv
netfilter
netns
nfc
phonet
sctp
tc_act
act_api.h -rw-r--r-- 4.2 KB
addrconf.h -rw-r--r-- 7.8 KB
af_ieee802154.h -rw-r--r-- 1.6 KB
af_rxrpc.h -rw-r--r-- 1.9 KB
af_unix.h -rw-r--r-- 2.1 KB
ah.h -rw-r--r-- 435 bytes
arp.h -rw-r--r-- 1.7 KB
atmclip.h -rw-r--r-- 1.4 KB
ax25.h -rw-r--r-- 15.0 KB
ax88796.h -rw-r--r-- 998 bytes
cfg80211-wext.h -rw-r--r-- 2.0 KB
cfg80211.h -rw-r--r-- 116.1 KB
checksum.h -rw-r--r-- 3.1 KB
cipso_ipv4.h -rw-r--r-- 7.4 KB
cls_cgroup.h -rw-r--r-- 1.4 KB
compat.h -rw-r--r-- 2.0 KB
datalink.h -rw-r--r-- 482 bytes
dcbevent.h -rw-r--r-- 1.3 KB
dcbnl.h -rw-r--r-- 3.9 KB
dn.h -rw-r--r-- 7.0 KB
dn_dev.h -rw-r--r-- 5.4 KB
dn_fib.h -rw-r--r-- 4.6 KB
dn_neigh.h -rw-r--r-- 824 bytes
dn_nsp.h -rw-r--r-- 6.0 KB
dn_route.h -rw-r--r-- 4.2 KB
dsa.h -rw-r--r-- 4.7 KB
dsfield.h -rw-r--r-- 1.1 KB
dst.h -rw-r--r-- 10.7 KB
dst_ops.h -rw-r--r-- 1.7 KB
esp.h -rw-r--r-- 434 bytes
ethoc.h -rw-r--r-- 502 bytes
fib_rules.h -rw-r--r-- 3.0 KB
flow.h -rw-r--r-- 5.7 KB
flow_keys.h -rw-r--r-- 319 bytes
garp.h -rw-r--r-- 2.6 KB
gen_stats.h -rw-r--r-- 1.7 KB
genetlink.h -rw-r--r-- 9.9 KB
gre.h -rw-r--r-- 410 bytes
icmp.h -rw-r--r-- 1.6 KB
ieee80211_radiotap.h -rw-r--r-- 10.0 KB
ieee802154.h -rw-r--r-- 5.6 KB
ieee802154_netdev.h -rw-r--r-- 3.4 KB
if_inet6.h -rw-r--r-- 7.0 KB
inet6_connection_sock.h -rw-r--r-- 1.4 KB
inet6_hashtables.h -rw-r--r-- 3.4 KB
inet_common.h -rw-r--r-- 1.5 KB
inet_connection_sock.h -rw-r--r-- 10.6 KB
inet_ecn.h -rw-r--r-- 3.3 KB
inet_frag.h -rw-r--r-- 2.0 KB
inet_hashtables.h -rw-r--r-- 13.3 KB
inet_sock.h -rw-r--r-- 6.1 KB
inet_timewait_sock.h -rw-r--r-- 6.7 KB
inetpeer.h -rw-r--r-- 3.0 KB
ip.h -rw-r--r-- 13.8 KB
ip6_checksum.h -rw-r--r-- 2.3 KB
ip6_fib.h -rw-r--r-- 5.3 KB
ip6_route.h -rw-r--r-- 5.1 KB
ip6_tunnel.h -rw-r--r-- 879 bytes
ip_fib.h -rw-r--r-- 7.1 KB
ip_vs.h -rw-r--r-- 40.0 KB
ipcomp.h -rw-r--r-- 620 bytes
ipconfig.h -rw-r--r-- 772 bytes
ipip.h -rw-r--r-- 1.6 KB
ipv6.h -rw-r--r-- 18.8 KB
ipx.h -rw-r--r-- 3.7 KB
iw_handler.h -rw-r--r-- 21.6 KB
lapb.h -rw-r--r-- 4.7 KB
lib80211.h -rw-r--r-- 4.1 KB
llc.h -rw-r--r-- 4.5 KB
llc_c_ac.h -rw-r--r-- 10.1 KB
llc_c_ev.h -rw-r--r-- 11.6 KB
llc_c_st.h -rw-r--r-- 1.7 KB
llc_conn.h -rw-r--r-- 4.1 KB
llc_if.h -rw-r--r-- 3.0 KB
llc_pdu.h -rw-r--r-- 14.4 KB
llc_s_ac.h -rw-r--r-- 1.6 KB
llc_s_ev.h -rw-r--r-- 2.3 KB
llc_s_st.h -rw-r--r-- 941 bytes
llc_sap.h -rw-r--r-- 1.2 KB
mac80211.h -rw-r--r-- 143.8 KB
mip6.h -rw-r--r-- 1.6 KB
mld.h -rw-r--r-- 1.9 KB
ndisc.h -rw-r--r-- 4.4 KB
neighbour.h -rw-r--r-- 11.0 KB
net_namespace.h -rw-r--r-- 6.8 KB
net_ratelimit.h -rw-r--r-- 181 bytes
netdma.h -rw-r--r-- 1.2 KB
netevent.h -rw-r--r-- 696 bytes
netlabel.h -rw-r--r-- 17.2 KB
netlink.h -rw-r--r-- 32.3 KB
netprio_cgroup.h -rw-r--r-- 1.8 KB
netrom.h -rw-r--r-- 8.0 KB
nexthop.h -rw-r--r-- 821 bytes
nl802154.h -rw-r--r-- 4.5 KB
p8022.h -rw-r--r-- 441 bytes
ping.h -rw-r--r-- 1.4 KB
pkt_cls.h -rw-r--r-- 9.1 KB
pkt_sched.h -rw-r--r-- 3.3 KB
protocol.h -rw-r--r-- 3.7 KB
psnap.h -rw-r--r-- 326 bytes
raw.h -rw-r--r-- 1.9 KB
rawv6.h -rw-r--r-- 558 bytes
red.h -rw-r--r-- 10.0 KB
regulatory.h -rw-r--r-- 4.3 KB
request_sock.h -rw-r--r-- 6.6 KB
rose.h -rw-r--r-- 7.9 KB
route.h -rw-r--r-- 9.4 KB
rtnetlink.h -rw-r--r-- 4.6 KB
sch_generic.h -rw-r--r-- 16.4 KB
scm.h -rw-r--r-- 3.1 KB
secure_seq.h -rw-r--r-- 819 bytes
slhc_vj.h -rw-r--r-- 6.6 KB
snmp.h -rw-r--r-- 5.9 KB
sock.h -rw-r--r-- 59.2 KB
stp.h -rw-r--r-- 358 bytes
tcp.h -rw-r--r-- 47.4 KB
tcp_memcontrol.h -rw-r--r-- 693 bytes
tcp_states.h -rw-r--r-- 1.2 KB
timewait_sock.h -rw-r--r-- 1.4 KB
transp_v6.h -rw-r--r-- 1.4 KB
udp.h -rw-r--r-- 8.1 KB
udplite.h -rw-r--r-- 3.7 KB
wext.h -rw-r--r-- 1.5 KB
wimax.h -rw-r--r-- 20.1 KB
wpan-phy.h -rw-r--r-- 2.2 KB
x25.h -rw-r--r-- 9.7 KB
x25device.h -rw-r--r-- 348 bytes
xfrm.h -rw-r--r-- 46.5 KB

back to top