Skip to content

Commit 99dc26b

Browse files
author
Ingo Molnar
committed
x86/fpu: Remove struct fpu::fpregs_active
The previous changes paved the way for the removal of the fpu::fpregs_active state flag - we now only have the fpu::fpstate_active and fpu::last_cpu fields left. Cc: Andrew Morton <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Eric Biggers <[email protected]> Cc: Fenghua Yu <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Yu-cheng Yu <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 6cf4edb commit 99dc26b

File tree

5 files changed

+1
-43
lines changed

5 files changed

+1
-43
lines changed

arch/x86/include/asm/fpu/internal.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,14 +526,12 @@ static inline int fpregs_state_valid(struct fpu *fpu, unsigned int cpu)
526526
*/
527527
static inline void fpregs_deactivate(struct fpu *fpu)
528528
{
529-
fpu->fpregs_active = 0;
530529
this_cpu_write(fpu_fpregs_owner_ctx, NULL);
531530
trace_x86_fpu_regs_deactivated(fpu);
532531
}
533532

534533
static inline void fpregs_activate(struct fpu *fpu)
535534
{
536-
fpu->fpregs_active = 1;
537535
this_cpu_write(fpu_fpregs_owner_ctx, fpu);
538536
trace_x86_fpu_regs_activated(fpu);
539537
}
@@ -552,16 +550,13 @@ static inline void fpregs_activate(struct fpu *fpu)
552550
static inline void
553551
switch_fpu_prepare(struct fpu *old_fpu, int cpu)
554552
{
555-
WARN_ON_FPU(old_fpu->fpregs_active != old_fpu->fpstate_active);
556-
557553
if (old_fpu->fpstate_active) {
558554
if (!copy_fpregs_to_fpstate(old_fpu))
559555
old_fpu->last_cpu = -1;
560556
else
561557
old_fpu->last_cpu = cpu;
562558

563559
/* But leave fpu_fpregs_owner_ctx! */
564-
old_fpu->fpregs_active = 0;
565560
trace_x86_fpu_regs_deactivated(old_fpu);
566561
} else
567562
old_fpu->last_cpu = -1;

arch/x86/include/asm/fpu/types.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -298,29 +298,6 @@ struct fpu {
298298
*/
299299
unsigned char fpstate_active;
300300

301-
/*
302-
* @fpregs_active:
303-
*
304-
* This flag determines whether a given context is actively
305-
* loaded into the FPU's registers and that those registers
306-
* represent the task's current FPU state.
307-
*
308-
* Note the interaction with fpstate_active:
309-
*
310-
* # task does not use the FPU:
311-
* fpstate_active == 0
312-
*
313-
* # task uses the FPU and regs are active:
314-
* fpstate_active == 1 && fpregs_active == 1
315-
*
316-
* # the regs are inactive but still match fpstate:
317-
* fpstate_active == 1 && fpregs_active == 0 && fpregs_owner == fpu
318-
*
319-
* The third state is what we use for the lazy restore optimization
320-
* on lazy-switching CPUs.
321-
*/
322-
unsigned char fpregs_active;
323-
324301
/*
325302
* @state:
326303
*

arch/x86/include/asm/trace/fpu.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,21 @@ DECLARE_EVENT_CLASS(x86_fpu,
1212

1313
TP_STRUCT__entry(
1414
__field(struct fpu *, fpu)
15-
__field(bool, fpregs_active)
1615
__field(bool, fpstate_active)
1716
__field(u64, xfeatures)
1817
__field(u64, xcomp_bv)
1918
),
2019

2120
TP_fast_assign(
2221
__entry->fpu = fpu;
23-
__entry->fpregs_active = fpu->fpregs_active;
2422
__entry->fpstate_active = fpu->fpstate_active;
2523
if (boot_cpu_has(X86_FEATURE_OSXSAVE)) {
2624
__entry->xfeatures = fpu->state.xsave.header.xfeatures;
2725
__entry->xcomp_bv = fpu->state.xsave.header.xcomp_bv;
2826
}
2927
),
30-
TP_printk("x86/fpu: %p fpregs_active: %d fpstate_active: %d xfeatures: %llx xcomp_bv: %llx",
28+
TP_printk("x86/fpu: %p fpstate_active: %d xfeatures: %llx xcomp_bv: %llx",
3129
__entry->fpu,
32-
__entry->fpregs_active,
3330
__entry->fpstate_active,
3431
__entry->xfeatures,
3532
__entry->xcomp_bv

arch/x86/kernel/fpu/core.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ void fpu__save(struct fpu *fpu)
147147
WARN_ON_FPU(fpu != &current->thread.fpu);
148148

149149
preempt_disable();
150-
WARN_ON_FPU(fpu->fpstate_active != fpu->fpregs_active);
151-
152150
trace_x86_fpu_before_save(fpu);
153151
if (fpu->fpstate_active) {
154152
if (!copy_fpregs_to_fpstate(fpu)) {
@@ -191,7 +189,6 @@ EXPORT_SYMBOL_GPL(fpstate_init);
191189

192190
int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu)
193191
{
194-
dst_fpu->fpregs_active = 0;
195192
dst_fpu->last_cpu = -1;
196193

197194
if (!src_fpu->fpstate_active || !static_cpu_has(X86_FEATURE_FPU))
@@ -264,7 +261,6 @@ EXPORT_SYMBOL_GPL(fpu__activate_curr);
264261
*/
265262
void fpu__activate_fpstate_read(struct fpu *fpu)
266263
{
267-
WARN_ON_FPU(fpu->fpstate_active != fpu->fpregs_active);
268264
/*
269265
* If fpregs are active (in the current CPU), then
270266
* copy them to the fpstate:
@@ -365,7 +361,6 @@ void fpu__current_fpstate_write_end(void)
365361
{
366362
struct fpu *fpu = &current->thread.fpu;
367363

368-
WARN_ON_FPU(fpu->fpstate_active != fpu->fpregs_active);
369364
/*
370365
* 'fpu' now has an updated copy of the state, but the
371366
* registers may still be out of date. Update them with
@@ -419,17 +414,13 @@ void fpu__drop(struct fpu *fpu)
419414
preempt_disable();
420415

421416
if (fpu == &current->thread.fpu) {
422-
WARN_ON_FPU(fpu->fpstate_active != fpu->fpregs_active);
423-
424417
if (fpu->fpstate_active) {
425418
/* Ignore delayed exceptions from user space */
426419
asm volatile("1: fwait\n"
427420
"2:\n"
428421
_ASM_EXTABLE(1b, 2b));
429422
fpregs_deactivate(fpu);
430423
}
431-
} else {
432-
WARN_ON_FPU(fpu->fpregs_active);
433424
}
434425

435426
fpu->fpstate_active = 0;

arch/x86/kernel/fpu/signal.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,6 @@ int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size)
171171
sizeof(struct user_i387_ia32_struct), NULL,
172172
(struct _fpstate_32 __user *) buf) ? -1 : 1;
173173

174-
WARN_ON_FPU(fpu->fpstate_active != fpu->fpregs_active);
175-
176174
if (fpu->fpstate_active || using_compacted_format()) {
177175
/* Save the live register state to the user directly. */
178176
if (copy_fpregs_to_sigframe(buf_fx))

0 commit comments

Comments
 (0)