15
15
*/
16
16
static void fpu__init_cpu_ctx_switch (void )
17
17
{
18
- if (!boot_cpu_has (X86_FEATURE_EAGER_FPU ))
19
- stts ();
20
- else
21
- clts ();
18
+ clts ();
22
19
}
23
20
24
21
/*
@@ -234,83 +231,17 @@ static void __init fpu__init_system_xstate_size_legacy(void)
234
231
setup_clear_cpu_cap (X86_FEATURE_XSAVES );
235
232
}
236
233
237
- /*
238
- * FPU context switching strategies:
239
- *
240
- * Against popular belief, we don't do lazy FPU saves, due to the
241
- * task migration complications it brings on SMP - we only do
242
- * lazy FPU restores.
243
- *
244
- * 'lazy' is the traditional strategy, which is based on setting
245
- * CR0::TS to 1 during context-switch (instead of doing a full
246
- * restore of the FPU state), which causes the first FPU instruction
247
- * after the context switch (whenever it is executed) to fault - at
248
- * which point we lazily restore the FPU state into FPU registers.
249
- *
250
- * Tasks are of course under no obligation to execute FPU instructions,
251
- * so it can easily happen that another context-switch occurs without
252
- * a single FPU instruction being executed. If we eventually switch
253
- * back to the original task (that still owns the FPU) then we have
254
- * not only saved the restores along the way, but we also have the
255
- * FPU ready to be used for the original task.
256
- *
257
- * 'lazy' is deprecated because it's almost never a performance win
258
- * and it's much more complicated than 'eager'.
259
- *
260
- * 'eager' switching is by default on all CPUs, there we switch the FPU
261
- * state during every context switch, regardless of whether the task
262
- * has used FPU instructions in that time slice or not. This is done
263
- * because modern FPU context saving instructions are able to optimize
264
- * state saving and restoration in hardware: they can detect both
265
- * unused and untouched FPU state and optimize accordingly.
266
- *
267
- * [ Note that even in 'lazy' mode we might optimize context switches
268
- * to use 'eager' restores, if we detect that a task is using the FPU
269
- * frequently. See the fpu->counter logic in fpu/internal.h for that. ]
270
- */
271
- static enum { ENABLE , DISABLE } eagerfpu = ENABLE ;
272
-
273
234
/*
274
235
* Find supported xfeatures based on cpu features and command-line input.
275
236
* This must be called after fpu__init_parse_early_param() is called and
276
237
* xfeatures_mask is enumerated.
277
238
*/
278
239
u64 __init fpu__get_supported_xfeatures_mask (void )
279
240
{
280
- /* Support all xfeatures known to us */
281
- if (eagerfpu != DISABLE )
282
- return XCNTXT_MASK ;
283
-
284
- /* Warning of xfeatures being disabled for no eagerfpu mode */
285
- if (xfeatures_mask & XFEATURE_MASK_EAGER ) {
286
- pr_err ("x86/fpu: eagerfpu switching disabled, disabling the following xstate features: 0x%llx.\n" ,
287
- xfeatures_mask & XFEATURE_MASK_EAGER );
288
- }
289
-
290
- /* Return a mask that masks out all features requiring eagerfpu mode */
291
- return ~XFEATURE_MASK_EAGER ;
292
- }
293
-
294
- /*
295
- * Disable features dependent on eagerfpu.
296
- */
297
- static void __init fpu__clear_eager_fpu_features (void )
298
- {
299
- setup_clear_cpu_cap (X86_FEATURE_MPX );
241
+ return XCNTXT_MASK ;
300
242
}
301
243
302
- /*
303
- * Pick the FPU context switching strategy:
304
- *
305
- * When eagerfpu is AUTO or ENABLE, we ensure it is ENABLE if either of
306
- * the following is true:
307
- *
308
- * (1) the cpu has xsaveopt, as it has the optimization and doing eager
309
- * FPU switching has a relatively low cost compared to a plain xsave;
310
- * (2) the cpu has xsave features (e.g. MPX) that depend on eager FPU
311
- * switching. Should the kernel boot with noxsaveopt, we support MPX
312
- * with eager FPU switching at a higher cost.
313
- */
244
+ /* Legacy code to initialize eager fpu mode. */
314
245
static void __init fpu__init_system_ctx_switch (void )
315
246
{
316
247
static bool on_boot_cpu = 1 ;
@@ -320,17 +251,6 @@ static void __init fpu__init_system_ctx_switch(void)
320
251
321
252
WARN_ON_FPU (current -> thread .fpu .fpstate_active );
322
253
current_thread_info ()-> status = 0 ;
323
-
324
- if (boot_cpu_has (X86_FEATURE_XSAVEOPT ) && eagerfpu != DISABLE )
325
- eagerfpu = ENABLE ;
326
-
327
- if (xfeatures_mask & XFEATURE_MASK_EAGER )
328
- eagerfpu = ENABLE ;
329
-
330
- if (eagerfpu == ENABLE )
331
- setup_force_cpu_cap (X86_FEATURE_EAGER_FPU );
332
-
333
- printk (KERN_INFO "x86/fpu: Using '%s' FPU context switches.\n" , eagerfpu == ENABLE ? "eager" : "lazy" );
334
254
}
335
255
336
256
/*
@@ -339,11 +259,6 @@ static void __init fpu__init_system_ctx_switch(void)
339
259
*/
340
260
static void __init fpu__init_parse_early_param (void )
341
261
{
342
- if (cmdline_find_option_bool (boot_command_line , "eagerfpu=off" )) {
343
- eagerfpu = DISABLE ;
344
- fpu__clear_eager_fpu_features ();
345
- }
346
-
347
262
if (cmdline_find_option_bool (boot_command_line , "no387" ))
348
263
setup_clear_cpu_cap (X86_FEATURE_FPU );
349
264
0 commit comments