All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] x86/fpu: Simplify the FPU state machine
@ 2017-01-26 11:26 Ingo Molnar
  2017-01-26 11:26 ` [PATCH 1/7] x86/fpu: Simplify the fpu->last_cpu logic and rename it to fpu->fpregs_cached Ingo Molnar
                   ` (6 more replies)
  0 siblings, 7 replies; 22+ messages in thread
From: Ingo Molnar @ 2017-01-26 11:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Morton, Andy Lutomirski, Borislav Petkov, Dave Hansen,
	Fenghua Yu, H . Peter Anvin, Linus Torvalds, Oleg Nesterov,
	Peter Zijlstra, Rik van Riel, Thomas Gleixner, Yu-cheng Yu

Now that the lazy FPU switching code has been removed this series capitalizes
on the simpler FPU context switching machinery and simplifies the x86 FPU
handling state machine code.

The new code relies on just two obvious fields, ::fpstate_active and ::fpregs_cached:

/*
 * Highest level per task FPU state data structure that
 * contains the FPU register state plus various FPU
 * state fields:
 */
struct fpu {
	/*
	 * @fpstate_active:
	 *
	 * This flag indicates whether this context is active: if the task
	 * is not running then we can restore from this context, if the task
	 * is running then we should save into this context.
	 */
	unsigned char			fpstate_active;

	/*
	 * @fpregs_cached:
	 *
	 * This flag tells us whether this context is loaded into a CPU
	 * right now.
	 *
	 * This is set to 0 if a task is migrated to another CPU.
	 */
	unsigned char			fpregs_cached;

	/*
	 * @state:
	 *
	 * In-memory copy of all FPU registers that we save/restore
	 * over context switches. If the task is using the FPU then
	 * the registers in the FPU are more recent than this state
	 * copy. If the task context-switches away then they get
	 * saved here and represent the FPU state.
	 */
	union fpregs_state		state;
	/*
	 * WARNING: 'state' is dynamically-sized.  Do not put
	 * anything after it here.
	 */
};

In particular ::last_cpu is replaced by a single ::fpregs_cached field
(which is invalidated on migration), plus ::fpregs_state is gone.

There's some code size reduction:

 7 files changed, 41 insertions(+), 87 deletions(-)

... and the code is a lot more obvious now as well, I think.

Lightly tested.

The code can also be fetched from:

   git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git WIP.x86/fpu

Thanks,

	Ingo

Ingo Molnar (7):
  x86/fpu: Simplify the fpu->last_cpu logic and rename it to fpu->fpregs_cached
  x86/fpu: Simplify fpu->fpregs_active use
  x86/fpu: Make the fpu state change in fpu__clear() scheduler-atomic
  x86/fpu: Split the state handling in fpu__drop()
  x86/fpu: Change fpu->fpregs_active users to fpu->fpstate_active
  x86/fpu: Decouple fpregs_activate()/fpregs_deactivate() from fpu->fpregs_active
  x86/fpu: Remove struct fpu::fpregs_active

 arch/x86/include/asm/fpu/internal.h | 42 ++++++++++--------------------------------
 arch/x86/include/asm/fpu/types.h    | 37 +++++--------------------------------
 arch/x86/include/asm/switch_to.h    | 10 ++++++++++
 arch/x86/include/asm/trace/fpu.h    |  5 +----
 arch/x86/kernel/fpu/core.c          | 29 ++++++++++++++++-------------
 arch/x86/kernel/fpu/signal.c        |  9 +++++----
 arch/x86/mm/pkeys.c                 |  3 +--
 drivers/lguest/x86/core.c           |  2 +-
 kernel/sched/core.c                 |  2 ++
 kernel/sched/sched.h                |  8 ++++++++
 10 files changed, 59 insertions(+), 88 deletions(-)

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2017-01-26 18:04 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-26 11:26 [PATCH 0/7] x86/fpu: Simplify the FPU state machine Ingo Molnar
2017-01-26 11:26 ` [PATCH 1/7] x86/fpu: Simplify the fpu->last_cpu logic and rename it to fpu->fpregs_cached Ingo Molnar
2017-01-26 14:23   ` Rik van Riel
2017-01-26 14:53     ` Ingo Molnar
2017-01-26 15:05       ` [PATCH] x86/fpu: Unify the naming of the FPU register cache validity flags Ingo Molnar
2017-01-26 15:31         ` Peter Zijlstra
2017-01-26 14:54   ` [PATCH 1/7] x86/fpu: Simplify the fpu->last_cpu logic and rename it to fpu->fpregs_cached Rik van Riel
2017-01-26 15:09     ` Ingo Molnar
2017-01-26 16:51     ` Andy Lutomirski
2017-01-26 11:26 ` [PATCH 2/7] x86/fpu: Simplify fpu->fpregs_active use Ingo Molnar
2017-01-26 16:30   ` Andy Lutomirski
2017-01-26 11:26 ` [PATCH 3/7] x86/fpu: Make the fpu state change in fpu__clear() scheduler-atomic Ingo Molnar
2017-01-26 11:26 ` [PATCH 4/7] x86/fpu: Split the state handling in fpu__drop() Ingo Molnar
2017-01-26 11:26 ` [PATCH 5/7] x86/fpu: Change fpu->fpregs_active users to fpu->fpstate_active Ingo Molnar
2017-01-26 14:44   ` Rik van Riel
2017-01-26 15:16     ` Ingo Molnar
2017-01-26 15:45       ` Rik van Riel
2017-01-26 15:53         ` Ingo Molnar
2017-01-26 17:00           ` Andy Lutomirski
2017-01-26 18:04             ` Rik van Riel
2017-01-26 11:26 ` [PATCH 6/7] x86/fpu: Decouple fpregs_activate()/fpregs_deactivate() from fpu->fpregs_active Ingo Molnar
2017-01-26 11:26 ` [PATCH 7/7] x86/fpu: Remove struct fpu::fpregs_active Ingo Molnar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.